Skip to main content

07 Security

Status: Current Last verified: 604c95a

The summary and the pointers. The full identity model, isolation rules and threat model, credential by credential, are in MULTI_USER_ARCHITECTURE.md.

Principals​

Every request resolves to one principal, and every query filters by its account.

PrincipalPresented asAccepted by
Dashboard sessionHS256 JWT (JWT_SECRET, account_id), kept in an httpOnly cookie and sent by the dashboard server as a Bearer tokenAPI, Observatory
Personal access tokenghb_pat_..., scopes read or read writeAPI, MCP server
Agent tokenghb_agt_..., the /v1 run intake onlyAPI
Platform service (the dashboard's server, the MCP server, the Observatory)its own credential in X-Service-Credential (ADR 0009): the API keeps only SHA-256 hashes (SERVICE_CREDENTIALS), and a policy by operationId (routes/service.policy.go) gives each service only the operations it calls and, for each, whether it may name an account in X-Account-Id; it is checked after routing and before any account lookup, so a service learns nothing about accounts it may not act for. Audit events and the request log name it service:<name>. The Observatory keeps the same hashes and its own policy by route (SERVICE_POLICY in utils/auth.py): the dashboard's password logins (/auth/login), the MCP server's search (/search); a credential that does not verify is 401, another service 403 FORBIDDEN. Each service sends SERVICE_CREDENTIAL when it is set and INTERNAL_SECRET otherwise, never bothAPI, Observatory
Internal caller, deprecatedINTERNAL_SECRET with X-Account-Id: still accepted while it is set, every request counted by route (ghb_legacy_internal_requests_total, on each service's /metrics) and logged once per processAPI, Observatory
Metrics readerMETRICS_TOKEN, /metrics onlyAPI, Observatory
Password loginCHAT_USERNAME and CHAT_PASSWORD, the owner's accountObservatory
CronCRON_SECRET as a Bearer token, compared in constant time: GET /internal/jobs/pass only (one pass of the background jobs, for every account), which no session or service credential opensObservatory

What a principal may do also depends on its account's plan (ADR 0022): an account without a paid plan, other than the deployment owner's, links no worker, starts no run and queues no backup (402 PLAN_REQUIRED); the plan is read from the database at each of the three gates.

Tokens are stored as SHA-256 hashes only. Sign-up follows the API's SIGNUP_MODE (allowlist, open or closed); the Observatory admits any existing, enabled account. A revoked token or agent and a disabled or deleted account are refused at once by the API process that made the change and within 2 s by every other API process, which reads identity's revocations (identity.revocations_v1, 000025) at most every 2 s while it serves requests; other changes made in the database (scopes, expiry, plan) show within the 30 s principal cache. The Observatory refuses a disabled account within 60 s; the MCP server, which asks the API, within 10 s, and at once on a tool that forwards the token, since the API refuses it and the MCP server drops it from its cache.

Secrets​

SecretWho holds itWhere it is kept
SERVICE_CREDENTIAL (each calling service its own; the API and the Observatory hold only their hashes, SERVICE_CREDENTIALS), INTERNAL_SECRET, JWT_SECRET, METRICS_TOKEN, RESEARCH_HMAC_KEY, CREDENTIALS_ENCRYPTION_KEY, NOTIFY_ENCRYPTION_KEY, CRON_SECRET, OPENROUTER_API_KEY, Razorpay and GitHub OAuth credentialsthe services (each gets only what it reads)/etc/ghb/selfhost.env on the self-hosted machine (generated by install.sh), with a copy in the selfhost profile of fnox.toml, age-encrypted for the owner's key (SECRETS.md, ADR 0021)
Database URLsthe services, a self-hosted worker; each may hold its own role's (03 schemas and roles)as above; never on a linked machine
Users' OpenRouter keysObservatoryai_openrouter_credentials, Fernet-encrypted
Alert channels' Slack, Discord and webhook URLs, webhooks' signing secretsnotifynotify.channels, sealed with AES-256-GCM (NOTIFY_ENCRYPTION_KEY, the account and the field as associated data); never answered by the API, a signing secret shown once when created
Worker logins (GitHub App, destinations, OpenRouter)the user's machinethe OS keychain or a 0600 file
Dump decryption keythe owneroff the server
The age keys that open fnox.tomlthe owner (~/.config/fnox/age.txt, with an offline copy), CI only if a workflow needs production (FNOX_AGE_KEY)their machines; only public keys are committed

The pre-commit hook refuses .env files, private keys, known token patterns, an exported production.env, fnox.local.toml, and a value in fnox.toml that is not age ciphertext. The dev profile's secrets are public development values, which the API refuses when APP_ENV=production.

Exposure​

  • The browser talks only to the dashboard; the dashboard's proxies forward allowlisted paths and rebuild request headers, so cookies and browser-supplied Authorization headers never reach the backends.
  • The assistant is bring-your-own-key: every account's requests run on its own OpenRouter key, and the operator's server key pool is never spent on another account. With OPENROUTER_ALLOW_SERVER_KEYS=true (default false) the pool serves only the owner's account and background embedding.
  • The Observatory's LLM calls are capped per process, protecting the server key pool and users' keys: a few chat and rerank calls at a time (503 SERVICE_BUSY after a short wait), two chat turns per account (429 before the stream starts), four tools per model message, and a share of the embedding slots and 30 calls an hour across the deployment for background embedding, which uses only the server pool so no user's key ever embeds another account's text.
  • On a self-hosted machine only Caddy listens publicly (80, 443). The Observatory, Prometheus and Grafana are not public; /metrics answers 404 from outside. The API trusts X-Forwarded-For only from the compose network (TRUSTED_PROXIES), and Caddy replaces any value a client sends.
  • Rate limits apply per account, per agent and per address; unknown tokens count against their address. Each process counts on its own unless RATELIMIT_BACKEND is postgres or valkey. When that store fails or takes more than 500 ms, each process counts on its own again and a warning is logged: a limit's store being down neither takes the service down nor switches the limits off.
  • Repository contents never reach the platform: they go from GitHub through the worker into the user's own storage.
  • Alerts go only where an account sends them (ADR 0017). A webhook URL must be https; the notify service connects only to public addresses, checked on the address being dialled after the name resolved (loopback, private, link-local and cloud metadata addresses, NAT64 and 6to4 are refused), with no proxy, no redirect and a 15-second timeout, so a URL cannot reach the server's network or the metadata service. Slack and Discord channels take only those services' webhook URLs. The product sends no e-mail at all (ADR 0020): no user, agent or CLI can make it mail a report or an alert to an address. No error, log line or delivery record repeats a destination URL, which is often its own credential. Webhook bodies are signed (X-GHB-Signature, HMAC-SHA256 over the timestamp and the body).

Database​

With the service roles on, the database enforces who writes what: each service's role may use only the tables it reads and writes, none may change the schema (only the owner's URL migrates), and the worker reaches runs only: it reads and locks an account's research consent in runs.research_consent but cannot change it. A service role with more power than its grants (superuser-like attributes, or another role's membership) stops the next migrate, so least privilege is not lost quietly. The compatibility views check the caller's grants on their table (security_invoker), so they open nothing. Without the roles every service uses the owner, as before.

Research data​

Research telemetry is off unless an account turns it on. Samples hold HMACs (keyed with RESEARCH_HMAC_KEY) of repository ids and commits, never names, paths or files; turning it off deletes them at once, and they are kept 365 days. The Terms of Service and the Privacy page describe it.

Deletion and export​

  • A user deletes their own account on the dashboard's Settings > Your Data page (DELETE /api/me, a session only, with their GitHub login typed as confirmation). Identity deletes the account, its identity rows and its Observatory rows in one transaction with an account.deleted event; the runs service and insights delete the backup history and the rollup when their jobs run, within about 12 hours (the Privacy Policy says within 24 hours). A deletion job checks that the account is gone from identity.accounts_v1 before deleting anything, since any role may insert into platform_jobs. notify deletes its alert channels, rules and deliveries the same way. The account's tokens, agents and sessions are refused at once by that API process, within 2 s by other API processes and within 60 s by the Observatory. The owner's account cannot be deleted.
  • Deleting a chat deletes its messages, investigations, tool calls, confirmations and the search index entries cut from them.
  • The same page downloads one JSON file joining the API's export (GET /api/me/export) and the Observatory's (GET /me/export). Token hashes and the OpenRouter key are never in it. Both exports are session-only and limited to 3 per account per 10 minutes, and the dashboard route refuses requests another site started (Sec-Fetch-Site), which would spend that budget.

Audit​

audit_events records account changes: tokens and agents created or revoked, link approvals, research consent (written by the runs service, which owns consent, through a temporary grant). A deleted account's events go with it; the API logs the deletion (Account deleted, with the account id and row counts).