Skip to content

Security model ​

This page is for someone deciding whether to self-host Orbit. It describes what the code on development does today, and what it does not do yet. Orbit is not ready to run anywhere reachable from the internet: the open items at the end must be closed first.

Who is calling ​

  • People sign in through the auth sidecar (services/auth). The sidecar issues a JWT that lasts 15 minutes and names the user (sub), the active organisation (org_id) and the user's role in it (org_role: owner, admin or member).
  • Open email sign-up is off unless AUTH_ALLOW_SIGNUP=true (the dev stack sets it, the self-hosted stack does not). The first user and their organisation are created by deploy/bootstrap.sh, later ones by an admin's invitation (the random invitation id, emailed or handed over by the admin, lets its holder create the account for the invited address, joined to that organisation only; the inviter knows the id, so the account stays unverified and cannot accept another organisation's invitations until the address is verified). With sign-up on, an email must be verified before sign-in. The optional OIDC provider creates no users unless OIDC_ALLOW_SIGNUP=true with OIDC_ALLOWED_DOMAINS.
  • Orbit accepts only EdDSA-signed tokens (the header's algorithm and the verifier are both pinned) with the configured issuer and audience, a non-empty org_id, a key id found in the sidecar's JWKS, and a lifetime of at most 15 minutes. Keys are refetched at most once a minute, however many tokens with unknown key ids arrive, and keys older than 5 minutes are refreshed. The email claim is never read, so it never reaches a log; a malformed claim is logged without the parser's text.
  • Agents get an MCP token, never a sidecar token: a signed-in person asks for one at POST /mcp/token (ADR 0006). Orbit signs it (HS256, a key derived from ORBIT_AUDIT_KEY) for audience orbit-mcp; it names the person, the tenant and a fresh agent id and lasts one hour. Only /mcp accepts it, and /mcp accepts nothing else: an agent cannot use /graphql or the CLI, and a person's sidecar token does not work on /mcp. Each issue is audited and capped at 10 per person per hour. The agent acts as the person (their role and membership, checked on every call), on door mcp.
  • The tenant comes only from the token's organisation. An organisation becomes a tenant only when an operator runs orbit tenant provision. A token for any other organisation is refused as UNAUTHENTICATED. Signing in, or creating an organisation in the sidecar, never creates a tenant (ADR 0002).
  • Every caller today is a person, or an agent acting for one with an MCP token. The code also has actor types for API clients and agents, but no door issues tokens for them yet.
  • The web app keeps its token in memory only. The CLI stores its token in a file readable only by its owner (mode 0600, in a 0700 directory) and refuses a file others can read.

Tenant isolation ​

Tenants share one database. They are kept apart in three layers:

  1. Every handler filters every SQL statement by the request's tenant.
  2. Every tenant-owned table has forced row-level security. Each transaction is scoped to one tenant, and rows of other tenants are invisible and cannot be written. With no tenant set, no rows are visible at all.
  3. Before committing, the bus checks that the handler did not switch its transaction to another tenant.

A caller who is not a member of a tenant, and a request for a tenant that does not exist, get the same denial, so tenant ids cannot be probed.

Row-level security separates tenants for honest code. It is not a defence against someone holding the runtime login's credentials, who can set any tenant on their own transaction.

Processes and credentials ​

No serving process holds the database owner's credentials (ADR 0004).

  • Migrations run only in orbit migrate, a one-shot process. The owner login is also used by orbit tenant provision and orbit keys ..., and by nothing else.
  • Enabling or disabling a module is an ordinary audited command on the runtime login. It writes through kernel.set_module_enabled, which refuses a module that was not migrated, a tenant other than the transaction's, and a change that would break a dependency.
  • At startup each serving process refuses a connection it must not hold (the owner's always, the worker's in web, the doors' in worker and scheduler), and refuses a login that is a superuser, has BYPASSRLS or CREATEROLE, owns schema kernel, or is a member of any group but its own. See Process roles.
  • Each module's tables are granted only to its own role (orbit_mod_<id>); handlers, subscribers and jobs run as it. The database refuses another module's events, delivery records and jobs, and no runtime role may call set_config. See ADR 0005.

What this does not stop: code running as the runtime login (any module handler, or anyone with its credentials) can call kernel.set_module_enabled directly, outside the bus, with no Cedar check and no audit entry. Such a switch is detectable, not prevented: it leaves a row in kernel.module_switches with no matching kernel.module.* audit entry. It cannot enable a module that was not migrated or break a dependency.

Container (self-hosted)Holds
migrateOwner login, ORBIT_AUDIT_KEY. ORBIT_DATA_KEY only when passed to orbit keys rotate or rewrap
webRuntime and doors logins, ORBIT_AUDIT_KEY, ORBIT_DATA_KEY
worker (worker,scheduler)Runtime and worker logins, ORBIT_AUDIT_KEY, ORBIT_DATA_KEY

The full table, with the sidecar and Postgres, is in deploy/README.md.

Authorisation ​

Every action goes through the bus and is authorised by Cedar policies. There is no internal or admin path around it (ADR 0001).

  • Gate. Before the handler runs, Cedar decides whether the actor may attempt the action in this tenant at all.
  • Resource check. The handler loads the record it acts on and asks Cedar whether the actor may act on that record (its kind, tenant and owner). The bus refuses to commit a handler that skipped this check, unless the handler acts on the tenant as a whole.
  • Field check. Reading a personal field needs a third check, on a Field entity (row_kind, name, tenant, owner), after the row check. A permit on a row (resource is Resource) never reveals a field. A denied field is returned as {"value": null, "redacted": true}, not as an error, and is never decrypted.
  • Policies must be scoped. The policy loader rejects a module permit that does not limit who it applies to, and one that does not say what it applies to (resource is Tenant, resource is Resource or resource is Field).
  • Grants are a ceiling. API clients and agents will act through per-action grants. Base policies deny them any action they were not granted, whatever a module permits. A grant only opens the gate: acting on a record also needs a module policy that names that kind of caller.
  • Hidden records. A module returns NOT_FOUND, not FORBIDDEN, for a record the caller may not read, so its existence does not leak.
  • Opaque errors. Callers see one of six fixed error codes with a fixed message. Denial reasons, policy ids, SQL and handler text go to the server log only, under the request id (error codes).

Personal data ​

Personal fields (national IDs, bank accounts, salaries, addresses, dates of birth, health) are encrypted by Orbit before they reach Postgres (crates/pii). Core, leave, attendance and payroll store such fields; the inventory, with who reads each, is in the 1.0 security review.

  • Keys. One master key, ORBIT_DATA_KEY (32 random bytes as 64 hex characters), is held in the environment of web and worker and never stored in Postgres. It wraps a random data key per tenant and key version, kept in pii.tenant_keys. Field encryption keys and blind-index keys are derived from that data key.
  • Ciphertexts. XChaCha20-Poly1305 with a random nonce per value. Each ciphertext names its key version and is bound to its tenant, table, column and row, so a value copied to another row, column or tenant does not decrypt. Values are padded to 32-byte buckets, so a ciphertext's length does not reveal a salary's size or an ID's format.
  • Lookups. A module that must find a row by a personal value stores a keyed blind index (HMAC-SHA256) next to it. Equal values in one tenant and column match; other tenants and columns never do.
  • Redaction. A personal value is held as Pii<T>, which prints and serialises as [redacted]. Jobs and events carry ids or sealed values, never plaintext.
  • Files. crates/storage encrypts files with the same tenant data key. Core's employee documents and payroll's payslip PDFs and bank and statutory files use it, through the files door (ADR 0009).

Back up the master key ​

Back up ORBIT_DATA_KEY separately from the database, for example in a password manager or secret store, never next to the database backups. Without it every personal field is lost for good. With it, anyone holding a copy of the database can read them. Changing the master key re-wraps only the small key rows, not the data (Operations).

Crypto erasure and its limits ​

orbit keys destroy deletes one key version of one tenant for good. Every value, blind index and file sealed under it becomes unreadable, including in append-only history and in database copies, once backups that still hold the key row have expired. It refuses the tenant's current version: rotate first, so new writes never land under a key that is about to be destroyed. It is audited.

Limits:

  • Per tenant and version, not per person. Erasing one person's data alone is not possible this way.
  • Only re-encrypted tables are kept. orbit keys rotate starts a new version for later writes and queues the re-encryption of every table with sealed columns (core employees, leave applications, attendance check-in locations, payroll). orbit keys destroy refuses while any of those tables still holds a value under the version, and while the tenant has a module the running build does not include. Files are not part of that check: a file sealed under the version and not re-encrypted is erased with it.
  • Backups. A database backup taken before the destroy still holds the wrapped key, and with the master key it can be read until that backup is gone.
  • The audit digest. Audit rows store HMAC digests of command inputs and of records before and after, under the separate ORBIT_AUDIT_KEY. Crypto erasure does not reach them: while the audit key exists, someone holding it and the audit log can confirm a guessed value. Keep personal values out of command inputs that do not need them, and treat the audit key as the limit of erasure.
  • Replay. Someone with write access to the database can put back an older ciphertext of the same field and row while its key version is live (issue #7).

Audit log ​

Every executed command, every denied command or query, and every failed command writes one row to audit.entries. A command's row is written in the command's own transaction, so it commits or rolls back with the change. Denied and failed attempts are written on a separate connection after the rollback. Operator commands (orbit tenant provision, orbit keys rotate|rewrap|destroy) are recorded with the actor and door system.

  • Keyed digests, not values. A row stores no input values. It stores an HMAC-SHA256 digest of the input (with personal fields replaced by [redacted]), and of the record before and after the change. Each tenant has its own key, derived from ORBIT_AUDIT_KEY (at least 32 bytes). Keep that secret outside the database. Without it, a low-entropy value such as a salary cannot be recovered from a row by hashing guesses, and the same value in two tenants gives different digests. If the secret changes, later digests can no longer be compared with earlier ones.
  • Append-only. The runtime role can only insert rows and cannot set their timestamp. Triggers refuse updates, deletes and truncation. The owner role can drop those triggers, so the log is not tamper-evident against someone holding the owner's credentials.
  • What a row identifies. Actor, door, tenant, request id, action, outcome (allowed, denied, failed, read) and whether the attempt was confirmed. Failed queries are not audited.
  • Reads of personal data (#26). A query that reveals personal fields (a field check that allows) writes one read row, with fields naming the columns revealed: column names only, never values, digests of values or blind indexes, and the column refuses anything that is not a lowercase identifier. A query's row is written on a separate connection after its read-only transaction ends; if that write fails the caller gets an error, not the data. A lookup by a personal value (core.employee.find) is audited hit or miss. Its input digest, like every input digest, is taken with personal input fields (Pii<T>, marked x-orbit-personal in the input schema) replaced by [redacted], so it does not identify the value looked up. Reads of work fields only are not audited. A command lists the fields it revealed on its allowed row, or on its failed row when its error says something (a national ID that is already taken); a denied row never names any.
  • Reads by another module (ADR 0007). A published query that another module calls in-process (ctx.query) writes its own read row (or denied) with via naming the calling module, written with the calling request even when that request fails. The calling request's own row names only its own fields. Rows can carry flags a handler set (ctx.audit_flag, e.g. self_approved), on allowed and read rows only.
  • Every executed command reports its state. The bus refuses to commit a command that did not call both audit_before and audit_after (audited as failed), and the table refuses an allowed row without both hashes, so a command cannot pass as a read.
  • Denials shown as not found. A handler that hides a record from someone who may not read it (DomainError::Hidden) answers NOT_FOUND and writes a denied row, which counts in the doors' per-actor denial limiter like any denial.

Sensitive actions over MCP ​

A module can mark an action sensitive (leave.approve, leave.reject, attendance.request.approve, attendance.request.reject). Over MCP it runs only after the person the agent acts for approved that exact call in the web app (ADR 0006):

  1. The agent's first call runs nothing. It creates a request (the agents module) holding the tool and its exact arguments, valid for 30 minutes, and the inbox notifies the person.
  2. The person sees the tool and its canonical arguments in their approval queue and, for a leave or attendance decision, the application or request it decides (from the owning module); Approve is not offered when that cannot be shown. They approve or reject it, signed in with their own session. Approving and rejecting are refused on the mcp and cli doors (the CLI has no verb for them) and for anyone but that person in that tenant.
  3. The agent's second call, with the same arguments, confirm: true and the request id, redeems the approval once, for the same agent token, tool and arguments, before it expires. Only then does the action run, audited as confirmed.

A person has at most 20 undecided requests and one agent token may ask 20 times an hour; expired requests are closed in the inbox (at the next request, and hourly by inbox.expire). A person revokes all their agent tokens with "Revoke all" in the web app (POST /mcp/token/revoke), and MCP tokens are signed with ORBIT_MCP_KEY when it is set.

Every request, decision, refused redemption and redemption is audited. Refused redemptions count against the per-caller rejection limit. A tool that takes personal fields cannot be sensitive (its arguments are stored and shown for approval). The base Cedar policy refuses every sensitive action that was not confirmed on door mcp and for API-client and agent actors on every door.

The door name an attempt was audited under is trustworthy only as "MCP" or "not MCP". The CLI marks its requests with a header that any client can send.

HTTP hardening ​

  • The web role speaks plain HTTP/1.1 and expects a reverse proxy to terminate TLS and send Strict-Transport-Security (deploy/README.md).
  • Every response that does not set its own carries X-Content-Type-Options: nosniff, X-Frame-Options: DENY, Referrer-Policy: strict-origin-when-cross-origin and a Content-Security-Policy that allows scripts and connections from the same origin only, inline styles, images from the origin, data: and (on pages) the https:// origins in ORBIT_IMAGE_HOSTS, and no framing. The web app has no inline script. There are no CORS headers.
  • The sidecar is reached through the web role's /api/auth proxy, so its session cookie is first-party and the sidecar and Postgres publish no ports. The proxy sets x-forwarded-for itself (the TCP peer; when that peer is in ORBIT_TRUSTED_PROXIES, the nearest address in its x-forwarded-for that is not a trusted proxy; or with ORBIT_TRUSTED_PROXY_HOPS=N the Nth address from the right) and drops every other client-address header. Its own log lines about the sidecar omit URLs. The sidecar's sign-in rate limits (per address, and per email by network and overall, in Postgres) key on it.
  • The sidecar refuses an http:// public URL in production except on loopback hosts or with ORBIT_ALLOW_INSECURE_HTTP=1; with https:// its cookies are Secure. Sign-up and organisation creation are off by default, sign-up needs a verified email, invitations need a verified email, OIDC creates no users unless allowed for listed domains (and verified emails) and never links to an existing user by email, and email addresses are redacted from its logs (deploy/README.md).
  • The orbit and auth containers run with a read-only root filesystem, no capabilities and no-new-privileges. The orbit image runs as an unprivileged user.

Limits ​

LimitValue
Rejected attempts (denials and failed commands) per caller20 per minute, then FORBIDDEN without an audit row
Requests in flight per caller32, then HTTP 429 with FORBIDDEN
Role changes synced from tokens per caller5 per minute, then FORBIDDEN
Open agent requests (pending or approved) per person20
MCP tokens issued per person10 per hour, then FORBIDDEN
Request body1 MiB (413 above it), read only after authentication
Time to send the request body5 seconds, and no longer gap between its parts (408)
Request time30 seconds, then 503 (a command already dispatched still completes and is audited)
Requests handled at once256 per process
Time to send request headers10 seconds
Sidecar requests through /api/auth32 in flight (503 above it), 64 KiB body, 10-second answer
GraphQL fields per request20 (see API)

These limits are kept in each process's memory. With several web processes, each applies them separately.

Open items ​

These are tracked as GitHub issues and must be closed before Orbit runs anywhere reachable from the internet. Which of them block 1.0 and which are accepted is decided in the 1.0 security review. The main ones still open in the code:

Issue #7: deferred security findings

  • Membership roles are synced from tokens outside the bus and Cedar (audited and rate-limited). Anyone holding the orbit_doors credentials can set any mapped person's role in any mapped tenant: treat that connection string like the owner's.
  • Code on the runtime login can call kernel.set_module_enabled outside the bus (see above). A separate login used only by the bus for the kernel commands is deferred.
  • The sidecar's JWKS is fetched over plain HTTP on an internal network. Database connections have no TLS, so an external managed Postgres would see credentials in cleartext.
  • Secrets are passed as environment variables, visible to docker inspect and /proc/*/environ. There is no *_FILE variant yet.
  • The audit log is not tamper-evident (no hash chaining or write-once export), not partitioned for retention.
  • Before and after digests are supplied by handlers, not derived by the repository layer.
  • Subscribers and jobs do not yet run through the bus, so they are not authorised or audited per action.
  • Handler error text is not yet redacted before it reaches logs and dead-letter records.
  • A Pii<T> put into a job or event serialises as [redacted]; the job queue and outbox do not refuse it yet.
  • Encrypted fields have no per-row replay protection.
  • Commands have no idempotency keys: a request that times out with 503 still completes, so a client retry can run it twice.
  • With a CDN in front of the reverse proxy, the proxy must append the CDN's client address itself (ORBIT_TRUSTED_PROXIES does not know CDN address ranges).
  • deploy/bootstrap.sh is not atomic: a failed organisation create leaves the user behind.
  • Without SMTP the sidecar sends no email: password reset is unavailable and open sign-up (which requires email verification) refuses to start. A copied invitation link proves nothing about the address: the admin who hands it over vouches for it, for their own organisation only. Invitation links carry the id in the URL fragment, so it never reaches request logs. Self-service sign-up for the managed cloud (policy, organisation limits) is not decided.

Issue #10: per-module data isolation (addressed by ADR 0005)

  • Module roles stop bugs and accidental cross-module SQL, not hostile in-process code: the runtime login can switch to any module role with several statements.
  • Retiring a runtime login: revoke orbit_runtime and run orbit migrate, which removes its orbit_mod_* memberships; until then it can still switch to every module role.
  • Events held for a re-enabled module are pruned after 90 days.

Agent tokens and approvals (ADR 0006)

  • An agent that reads the person's sidecar token from disk (the CLI's credentials file) can call /graphql directly and approve its own request there; one that drives the person's signed-in browser can click Approve. A web-only step-up proof (fresh re-authentication or a passkey assertion bound to the request) is future work.
  • Revocation is per person (all their agent tokens), not per token.
  • The inbox.expire schedule reads tenants when the scheduler starts; a tenant that enables the inbox later is swept after a restart (its expired items read as cancelled).
  • The token-issue cap is kept per process.

Orbit by SkySync Tech. Licensed under AGPL-3.0.