Secrets vault
How Turntable stores, scopes and audits secrets, and what it defends against.
This page is the design and threat model for the built-in vault. It covers storage, scoping, policy, rotation and audit. Secrets reach jobs only through the secrets proxy, which attaches them to requests outside the sandbox; nothing hands a value to a sandbox.
Goals
- A secret is only ever usable by the runs, in the places, that its owner said.
- A fork pull request, or anything that is not positively trusted, never gets one.
- A value never leaves the vault through an API response, a log line, an error, the audit log or an export.
- A stolen database alone reveals nothing. A stolen master key alone reveals nothing.
Threat model
| Threat | Defence |
|---|---|
| Database read (backup, SQL injection, leaked file) | Values are sealed with AES-256-GCM under per-record data keys that are themselves sealed under a key derived from the master key. The master key is never in the database. |
| Record moved or swapped inside the database | The AAD binds domain, org, secret id, version and name. A moved or edited record fails to open. |
| A job, a fork PR or an agent asks for a secret | Policy is evaluated by the core, never by the caller. The class comes from the run’s stored post-demotion decision. untrusted_pr can never be allowed. |
| A secret used somewhere it should not be | A secret names its allowed destination hosts. An empty list means nowhere. |
| A prompt-injected agent reads or leaks values | No operation returns a value. set_secret and rotate_secret are not exposed over MCP, so a value never sits in an agent’s context. |
| Value ends up in logs or the audit chain | Operations that carry a value declare it; dispatch redacts it from every audit path. Tests plant a sentinel and search the log, the chain, error bodies and console output. |
| Server child processes inherit the master key path or tokens | Children get an allowlisted environment. A source-guard test fails if code spawns a process without it. |
| Key mixing: the audit signing key or the GitHub App key read or replaced through the vault | System secrets live under a separate key domain and are unreachable from the vault operations. |
| Compromised vault operator token | Writes need release_operator or admin; every write, denial and use is audited in the hash-chained log. |
Out of scope here: a compromised server process (it holds the master key in memory), a malicious operator with the master key, side channels, and secrets in a job’s own memory once delivered.
Key hierarchy
master key (file, 32 bytes, outside the database)
|-- HKDF "system" domain key, per org -> GitHub App key, webhook secrets, audit signing key
|-- HKDF "oidc" domain key, per org -> OIDC signing keys
|-- HKDF "job" domain key, per org -> vault secrets
|-- per-version data key (random, one per sealed value)
Each domain key is derived with HKDF-SHA256 from the master key and the domain name, so a record sealed for one domain cannot be opened as another even with the same org and name. The AAD also carries the domain, the org, the secret id, the version and the name. Records written before domains existed (v1) still open and are re-sealed in the new format the next time they are written. Re-sealing is forward-only: an older Turntable cannot read a v2 record, which matters for rollback.
Per-org keys
The key that wraps a value is derived from the master key, the domain and the org id (format v3). A value sealed for org A therefore opens with A’s key only, whatever AAD is presented: moving a record to another org fails on the key as well as on the AAD, and a mistake in one org’s AAD cannot expose another’s values. This limits what a bug does; it does not protect against the master key itself, which still derives every org’s key. Per-org keys held in a KMS are the way to take the master key out of the picture.
Records written before this (v2, per domain only) still open. Convert them in place, once per org, after upgrading:
turntable keys reseal --org <slug>It re-seals the secret store, the OIDC keys, the vault versions and the audit anchor state for that org; values and versions do not change. Once every org is done, set TURNTABLE_REQUIRE_ORG_KEYS=1 and a record that is not per-org is refused wherever an org is known, so a stale copy of an old record cannot be put back. keys reseal itself refuses to run while it is set, for the same reason: re-sealing reads an old record, and in strict mode that would turn a stale copy into a fresh one. To reseal again, unset it, run the reseal, and set it again. As with the earlier format change, this is forward-only: an older Turntable cannot read a v3 record. The release lane’s own signing keys and attempt credentials have no org and stay per domain.
Scopes
A secret is bound to:
- an org (always) and optionally a project,
- an optional environment name,
- an optional ref pattern (
main,release/*), - the trust classes allowed to use it (default
protectedandrelease;untrusted_pris refused at write time and again at use), - the destination host patterns it may be sent to (default none).
The same name can exist under different scopes (a DEPLOY_TOKEN per environment). When several secrets with one name match a use, the most specific wins: project beats org, environment beats none, a ref pattern beats none. Two matches at the same specificity are an error, never a guess.
Policy
One function decides every use. It is given ids (run, job, attempt) and loads the run’s stored class itself. The caller cannot pass a class. A use is allowed only if all of these hold:
- the secret’s scope matches the run (org, project, environment, ref),
- the run’s class is in the secret’s allowed classes,
- the class may be given secrets at all (
credentialsFor(class).secrets), - for a delivery, the destination matches one of the secret’s host patterns.
Any other answer is a denial, and denials are audited.
Versions and rotation
Every write creates a new version. rotate_secret makes the new version current and keeps the previous one usable for an overlap window (default 0, at most 7 days), so a run that already started with the old value can finish and a downstream system can be updated. After the window, the old version is refused. Deleting a secret deletes every version.
Audit
Every write is audited by name and scope, never by value. Every use is audited with the secret, the version, the run, job and attempt, and the destination. Denials are audited with the reason. All of it goes into the per-org hash chain (see Security).
Environment of child processes
The server starts processes (git, act, docker, sandbox helpers). Each one gets only an allowlisted environment (PATH, HOME, locale and a few named extras per call site). The master key path, bootstrap token hash, API tokens and the rest of the server’s environment are never passed on.
Not built yet
External stores (Vault, AWS Secrets Manager, GCP Secret Manager) as plugins, a KMS-held master key, the write-only UI and proxy token exchange are tracked separately.