URL: /docs/security

---
title: Secrets and security
description: "The security model: trust classes, secrets, egress, signing, approvals, audit and incident response."
---

The goal is one instance that safely runs PR CI, website publishing and signed releases, with no second instance needed. [How the pieces fit](/docs/overview) shows the order the controls apply in; this page is the reference for each. Each section says what is built. Where a section says "not built", that part is still to do.

## Secrets vault

Scoped, versioned secrets with policy evaluated by the core: bound to an org (and optionally a project, environment and ref pattern), usable only by the trust classes named (never `untrusted_pr`) and only toward named destination hosts. Values are sealed under a per-org, per-domain key derived from the master key, are never returned by any operation, and every use and denial is audited with the run, job, attempt and destination. Child processes the server starts get an allowlisted environment only. Design and threat model: [Secrets vault](/docs/secrets-vault).

### The master key and the data volume

A key file on the same volume as the sealed store puts the key into every volume backup. On a hosted instance set the key as `TURNTABLE_MASTER_KEY` instead: it is read once at boot, deleted from the process environment before anything else starts, and never passed to a child (children get an allowlist). Both the variable and a key file is an error. `doctor` warns when a key file sits inside the data directory, or is left there after the key moved to the variable.

To rotate with no shell, set the new key and the old one as `TURNTABLE_MASTER_KEY_PREVIOUS` and deploy: every sealed row (secrets, vault versions, webhook secrets, audit anchor state) is re-encrypted in one transaction, verified by opening it under the new key, and audited with counts per table in the system chain, or nothing changes and the boot fails. It is idempotent. The runbook, including why the App private key, the webhook secret and the vault secrets must then be rotated (old backups still hold values the old key opens), is in [Hosted deployment](/docs/hosted#the-master-key-from-a-variable-and-rotating-it). `turntable keys reseal` takes the key the same way the server does: `TURNTABLE_MASTER_KEY` or `TURNTABLE_MASTER_KEY_FILE` (or `--file`), read once and deleted from the environment, with the audit anchor state under `<data dir>/audit-state` when the key is a variable. Setting both forms is an error, and no error or message carries a key value. `keys reseal` refuses while `TURNTABLE_MASTER_KEY_PREVIOUS` (or `_FILE`) is set: it scrubs the variable, never echoes it, and says to finish the rotation first. The order is: boot the server with the previous key to re-wrap, confirm `instance_doctor` (or `turntable doctor`) is green, remove `TURNTABLE_MASTER_KEY_PREVIOUS`, then run `keys reseal`. **Keep `TURNTABLE_MASTER_KEY_PREVIOUS` set until a clean boot is confirmed (doctor green, no `AnchorCorrupt`), and only then remove it.** The release lane has the same pair, `TURNTABLE_RELEASE_MASTER_KEY` and `TURNTABLE_RELEASE_MASTER_KEY_PREVIOUS`, for its publish credentials and signing key files.

## Secrets proxy

Sandboxes never hold raw secrets. A proxy sits on the sandbox's only network path and injects credentials into outbound requests, per allowed host and rule. Job code and third-party actions see placeholders at most, and a proxied job is verified from inside its sandbox before it runs. Docker and Daytona sandboxes are both supported. See [Secrets proxy](/docs/secrets-proxy).

## Egress

Egress is deny by default for every trust class, and `untrusted_pr` runs are held at `none` whatever the project allows. A job that holds secrets or a token never runs on `open` egress: its sandbox is `deny-all-except-proxy`, and an egress canary checks that from inside before the job starts. See [Configuration](/docs/configuration#egress) and [Secrets proxy](/docs/secrets-proxy#wiring-into-job-execution).

## Trust classes and fork PR gating

Every run the server ingests gets a trust class, decided once at ingest from forge facts that are re-fetched then (never taken from pull request text), and stored on the run with those facts and the reasons, so an audit or the UI can show why. `get_run` returns it as `trust`.

| Class | Meaning | Secrets and write token |
| --- | --- | --- |
| `protected` | a push to a protected ref, a schedule, or a maintainer's manual run on one | allowed |
| `release` | a release tag, or a maintainer's manual run on one | allowed |
| `trusted_pr` | a same-repo pull request whose opener can write, a push to another branch, a writer's manual run | never |
| `untrusted_pr` | everything else: a fork, an author who cannot write, an author whose permission could not be read | never |

**Facts.** A pull request is trusted only if its head repo is the base repo (a fork is untrusted whatever its author's standing) and its opener has write, maintain or admin permission, read from `GET /repos/{owner}/{repo}/collaborators/{user}/permission` with the poller's token. The forge is not asked about a fork's author. If the token cannot ask (401, 403), the author is untrusted and the decision records `permission: unknown`; a rate limit or server error fails the poll, which retries, rather than deciding on a guess. `authors` in the poll config is an explicit trusted list that works without asking the forge, for same-repo pull requests only. Protected refs are the default branch, the project's `protectedRefs`, and any branch the forge reports as protected.

**Waiting for a human.** A run classified `untrusted_pr` is created but every job waits in `awaiting_approval`, in the same transaction that creates it, so nothing can start. With `prMode: allowlist` nothing is held: only same-repo pull requests by listed authors run, and every other pull request is refused without a run. With `prMode: approval` every open pull request is ingested and untrusted ones are held. At most `maxWaitingRuns` (default 20) runs of a repo wait at once (a new push to a waiting pull request replaces it, so it is not blocked by the cap), and held runs do not count toward `maxRunsPerHour`, and neither do pull request markers that are untrusted or not yet classified, so strangers cannot use up the default branch's runs. Work on strangers' pull requests is bounded before any forge call is spent on it: the waiting cap is checked first, at most `maxNewPrsPerPoll` (default 5) pull requests from authors outside `authors` are examined per poll (the rest wait for the next poll), and a pull request skipped because the queue is full is remembered by head sha until room opens up.

**Approval.** `approve_run` releases a held run. It needs the `release_operator` role by default; an org can lower that to `operator` with `turntable policy set approve-run-min-role operator --org <slug>` (`turntable policy show` reads it, and the change is audited). **The risk of lowering it:** an operator token may belong to an agent that has just read the untrusted pull request's title, body and diff, so a prompt injection in that text could get the agent to approve its own attacker's code. The sandbox still has no secrets, but it does run the code. Keep `release_operator`, and have a person approve, unless you accept that. The caller passes the run's `head_sha` and the `workflow_hash` shown by `get_run`; both must equal what the run was decided on, or the call is refused with 409. Approving means "I read this commit and this workflow." A new push to the pull request is a new run with its own hold and its own approval, and the older waiting run of that pull request is cancelled. Approval never raises the class: an approved fork run still gets no secrets and no write token, and the class on the run is not changed. The worker checks the same binding again before starting an untrusted run: no approval, a different sha, or a workflow file whose hash differs from the approved one ends the job as `infra_error`. **Labels and comments are never read**, so no label can approve a run.

**Who may approve (`untrusted_run_approval`).** A pull request from a stranger can try to talk an agent into approving its own run: the title, body and diff are text the agent reads. So each project has a policy for who may call `approve_run`, and the default, `no_agents`, takes agents out of that step.

| Value | Who can approve |
| --- | --- |
| `human` | Only a signed `turntable.approve_run.v1` statement from an enrolled approver (WebAuthn or ed25519), relayed through `approve_run`. A token alone is refused, over MCP or REST, whatever its kind. An agent may carry a statement a person signed; it cannot make one. |
| `no_agents` (default) | Not over MCP, whoever holds the token. Not with a token whose kind is `agent`, over REST either, so an agent cannot step around the MCP block. A person approves in the web UI, or over REST or the CLI with their own `person` token. |
| `any` | Any caller with the role `approve_run` needs. This is how it worked before the setting existed. |

`approve_run_min_role` still applies on top, and a release tag run always needs `release_operator`, whatever this says. A refusal is a 403 whose message starts with `agents_may_not_approve` or `approval_requires_human`, and the audit row records the reason, the policy, the caller kind (`agent` or `person`), the transport (`mcp`, `rest` or `local` for the host CLI) and the run. The MCP tool description tells an agent the policy and to ask a person.

Set it per project with `turntable policy set --org <slug> --project <slug> --untrusted-run-approval <human|no_agents|any>` on the host, or `set_project_settings` over REST with an instance token (`get_project_settings` reads it). It is the instance operator's setting to loosen: the order is `any` < `no_agents` < `human`, an org owner (a person; no token holds that role) may only tighten it through `set_setting` or the web UI, a reset to a looser default counts as loosening, and only the instance administrator can loosen it. It is not an MCP tool, and every change (raising it to `any` included) is audited with the old and new value in the system chain and the org's. A project's setting affects only that project.

**Signed approval under `human`.** An enrolled approver signs a statement that binds the org, project, run id, head sha, workflow hash, the trust class being approved, their approver id, a single-use nonce and an expiry of at most 10 minutes:

```json
{ "type": "turntable.approve_run.v1", "org": "acme", "project": "api",
  "run_id": "...", "head_sha": "...", "workflow_hash": "...", "trust_class": "untrusted_pr",
  "approver": "<approver key id>", "expires_at": 1767225600000, "nonce": "..." }
```

- **WebAuthn.** The UI calls `approve_run_challenge` with the run id and the approver's key id, signs the returned `challenge` with the passkey, then calls `approve_run` with the run's `head_sha` and `workflow_hash` plus the `statement` and the assertion as `signature`.
- **Offline ed25519.** `approve_run_challenge` returns `canonical`; sign it on the approver's machine with `turntable approvals sign --key <private-key-file> --statement -` and pass the printed signature object to `approve_run` with the statement.

`approve_run` verifies the signature against the org's enrolled approvers and its key policy (`any` or `hardware`), and refuses a statement for another org, project, run, sha, workflow or trust class, an expired one, a replayed nonce (the nonce is a server-issued challenge, spent atomically for both methods), a revoked or unenrolled key, and a key that does not count (no forge login). An approver of another org is unknown here. The audit row records the statement hash and the approver id; the signature is omitted. A statement given under `no_agents` or `any` is verified the same way, but those policies do not need one. `approve_run_challenge` is not an MCP tool. Before choosing `human`, enrol an approver (`turntable approvals bootstrap`): without one, nobody can release an untrusted run.

**Egress.** Untrusted code with network access is a mining and exfiltration vector even without secrets, so a run classified `untrusted_pr` gets egress `none` whatever the repo or project allows. A repo's poll config may set `untrustedEgress: "allowlist"`; `open` is not accepted. The worker applies the same cap to the run's plan, so a plan that says otherwise is still held at `none`.

**Isolation fails closed.** A run is trusted for isolation only when its stored class is `protected`, `release` or `trusted_pr`, or it is a local run (`turntable run`, from your own checkout). A missing, unknown or unparseable class is untrusted, as is a job that needed approval or that the privileged-trigger rule demotes (including a job whose own step checks out the PR head, listed at ingest).

**Concurrency.** A held run's workflow file chooses its own `concurrency` group, so its group is rewritten to one scoped to its pull request (`untrusted:pr-<n>:<group>`). Runs record their repo, and pull request numbers, concurrency groups and caps are all scoped by it, because a project can bind several repos. It can neither cancel nor block a run of the default branch.

**Manual runs.** A `workflow_dispatch` run is `protected` or `release` only when the person who started it is a maintainer (maintain or admin); a writer's is `trusted_pr`, and anyone else's, or an unknown actor's, is `untrusted_pr`, whatever the ref. Manual dispatch is not ingested yet; the rule is in the classifier.

Issue [#17](https://github.com/turntable-ci/turntable/issues/17).

## Workflow source and workspace taint

Two questions decide whether a run can be hijacked: whose workflow file does it run, and whose code does it check out? Turntable answers both from the event, never from the payload alone, and enforces the answer structurally.

### Which ref the workflow definition comes from

| Event | Workflow definition from | Class |
| --- | --- | --- |
| `push` to a protected branch | the pushed commit (the protected ref itself) | protected |
| `push` of a release tag | the tagged commit | release |
| `push` to any other branch | the pushed commit (a push needs write access) | trusted |
| `pull_request` | the PR head, like GitHub's own event | untrusted unless a same-repo, trusted author |
| `pull_request_target`, `workflow_run`, `issue_comment`, `issues`, review and discussion events | the BASE branch (the default branch), never the head that triggered it | untrusted unless proven otherwise, and demoted when handed a non-protected ref |
| `schedule` | the default branch | protected |
| `workflow_dispatch` | the dispatched ref | by who started it: maintainer protected or release, writer trusted, else untrusted |
| `merge_group` | the merge queue commit | trusted |

Protected branches are the default branch plus the project's `protectedRefs`; release tags default to `v*`. Anything not positively trusted is untrusted: an unknown event, an unknown author, an unknown fork status.

### Credentials follow the class

Only protected and release runs may be given secrets or a token that can write to the forge. Trusted and untrusted classes never get either. This holds whatever the workflow says: a workflow cannot ask for more than its class allows.

### The demotion rule

A job on a privileged trigger (`pull_request_target`, `workflow_run`, `issue_comment`, `issues`, `pull_request_review`, `pull_request_review_comment`, `discussion`, `discussion_comment`) that **receives a non-protected ref** is demoted to untrusted **before it starts**. It receives one in two ways:

- the delivered workspace is at a non-protected ref (for example `refs/pull/9/head`), or
- one of its own steps asks for the PR head: a `with.ref` or `with.repository` that names `github.event.pull_request.head.*`, `github.head_ref`, `github.event.workflow_run.head_*`, or a `refs/pull/` ref (the classic "pwn request": check out the PR head, then run its code with the base repo's secrets).

Demotion is a property of the plan, so it happens before any sandbox exists. A same-repo author with a trusted history does not escape it.

### Lint

Two findings are lint:

- **Outside text in a script.** A `${{ }}` that reads attacker-controlled data (`github.head_ref`, PR and issue titles and bodies, comment and review bodies, branch labels and refs, commit messages and author names) inside a `run:` block or a `with.script:`. The safe form passes the value through `env:` and reads it as a shell variable.
- **A privileged job taking the PR head**, as above.

For **protected and release** runs a finding fails planning with the list of findings. For trusted and untrusted runs it is a warning. Fix it by moving the expression into `env:`, or by not checking out the head.

### No job-initiated forge fetches

The workspace is a tarball the controller delivered at one sha. The checkout stand-in only copies it and never touches the network, and a sandbox has no network unless an operator opts in. A job therefore cannot fetch a different ref, a fork, or the PR head on its own. Remote actions are fetched by sha by the controller, not the job.

The controller gets a polled run's commit without running `git` or `tar`, and without parsing the repository in the server's own process. It starts a child process of its own binary (`turntable fetch-source`), which speaks git's smart-HTTP protocol (v2) to the public repository, asks for exactly that sha at depth 1, and checks every object it receives (each object's SHA-1, the pack checksum, and that the commit it holds is the one asked for) before writing anything. The child writes the tree and a `.git` with a real index to a private temporary directory and streams a gzip tarball of it (one gzip member) to a file. A hostile repository can therefore stall or exhaust only that child, never the event loop or the memory of the server.

The child is not trusted either. This is what limits it, and what does not. It runs under one wall-clock deadline (5 minutes by default), is killed when the attempt is cancelled (and a kill is only waited for a few seconds), runs at most 2 at a time, and stops by itself if the server that started it is gone. Its environment is scrubbed: no Turntable setting, token or key, only the base variables plus the TLS and proxy settings (`SSL_CERT_FILE`, `SSL_CERT_DIR`, `NODE_EXTRA_CA_CERTS`, `HTTPS_PROXY`, `HTTP_PROXY`, `NO_PROXY` and their lower-case forms), which are passed through so it reaches GitHub the way the server does. **That is environment only.** The child runs as the same operating-system user as the server, so a child that a hostile repository managed to compromise could read the server's files, including the master key and the database, and call anything that user can. The process boundary protects the server's event loop and memory from a hostile pack, not its secrets from a compromised child; that would need the child to run as another user or in a sandbox, which is not done here. For the same reason nothing the child reports is believed: the server checks that the file it wrote is a regular file (not a link) owned by the server's user, no larger than the cap, exactly as long as the child said, and for exactly the commit asked for, and it reads the run's workflow and local-action files from that tarball, not from the directory the child also wrote, so the files it plans from are the files that are delivered. That reader is strict: the server plans from the archive and the sandbox extracts it with GNU tar, and a planner and an extractor that read one archive differently are the hole, so the scanner accepts only what the writer in this program writes and refuses every other way of saying the same thing. Names must already be canonical (no absolute path, empty, `.` or `..` segment, `./` prefix, doubled slash or trailing slash on a file), no name may repeat, every entry's parent must be a directory entry before it (so nothing sits under a symlink and nothing is implied), hard links and every type but file, directory and symlink are refused, pax headers may carry only a `path` or `linkpath` record framed exactly and consistent with the entry's header, header fields and checksums must be canonical, pax bodies are capped at 1 MiB, no name or link target may pass 4096 bytes and all names together may not pass 64 MiB, a pax size is checked before its body is read, names must survive a UTF-8 decode and encode byte for byte (a leading U+FEFF is kept, not dropped), a disguised `.git` or `.gitmodules` (case, normalisation, ignorable characters, trailing dots, 8.3 names) is refused everywhere, two names that fold together (`Readme` and `README`) are refused only when the scan is asked to (`refuseFoldedNames`, for an archive extracted onto a case-folding disk) because a Linux sandbox extracts them as two files, and the archive must end with exactly two zero blocks and nothing after them (truncated input or trailing bytes are refused). A lookup of a path that is not in its canonical spelling is an error, not a miss. What this does and does not give: an approval binds the workflow bytes the server read from the tarball, and nothing more. A compromised child could still deliver other files under the same commit sha than the repository holds, because the server cannot check them against the commit without the git objects the child held. On Linux the server kills the child when its resident memory passes a ceiling (1536 MiB by default, read from `/proc`), and the child also checks its own memory at checkpoints; other systems have no `/proc` reading, the server logs once that the ceiling is not enforced there, and the caps below still hold. Leftovers of a crashed server (`tt-src-*` in the temporary directory, older than an hour) are removed at start. Settings: `TURNTABLE_CHECKOUT_TIMEOUT_SECONDS`, `TURNTABLE_CHECKOUT_MAX_MEMORY_MIB` (0 turns the ceiling off), `TURNTABLE_CHECKOUT_CONCURRENCY`, `TURNTABLE_CHECKOUT_MAX_PACK_MIB` (128), `TURNTABLE_CHECKOUT_MAX_UNPACKED_MIB` (512) and `TURNTABLE_CHECKOUT_MAX_TARBALL_MIB` (256). The repository host must be `github.com` (over https, on its default port) or one the operator allowed (`TURNTABLE_NET_ALLOW_HOSTS`); owner and repository names may not be `.` or `..`.

The repository's contents are untrusted when the child writes them: a path named `.git` in any spelling a filesystem might fold to it (any case, trailing dots or spaces, `git~1`, an NTFS stream, characters HFS+ ignores), `..`, one with a slash, a backslash or a NUL, a name that is not UTF-8, a tree that has a name twice or is not in git's order, a symlinked `.gitmodules` (in any of those spellings), a write through a symlink, an unsupported file mode, a tree object over 32 MiB, or a repository over the size and file-count caps is refused, and a submodule becomes an empty directory that is never fetched. Objects the pack carried but the commit does not reach are not written. No credential is sent. The pack is hostile input and is bounded before anything is done with it: the object count before any allocation, each object's declared size before it is inflated (the inflate itself is cut at that size, so a zlib bomb stops), delta results before they are allocated and against what is left of one budget for everything unpacked, a limit on delta chain depth, offset deltas that may only point at an earlier object, a response size cap, and a wall clock over the requests and the parsing. A redirect is followed only within the same origin, for a repository that moved; never to another host. Anything the other side wrote that appears in an error (a path name, the server's refusal text, a zlib message) is shortened and stripped of control characters. The packed tree and `.git` go to the sandbox as a tarball written by a tar writer in the same program, so the server image needs neither program (it is distroless).

Object ids are checked with plain SHA-1, not the collision-detecting SHA-1 (sha1dc) that git itself uses. The requested sha comes from the forge, so a server cannot make the child accept an arbitrary commit for it, but an attacker who can craft a SHA-1 collision between two objects they control could serve different contents under one id. GitHub applies sha1dc when it receives objects, and git's own clients rely on the same property; this check adds no protection against it.

`turntable fetch-source <owner/name> <sha>` runs the same path (a child of the same binary under the same limits) and says what it got, for a smoke test or to check that a host can reach GitHub.

## Action pins and moved tags

Before a run starts, every `uses:` reference is resolved to a commit sha, and the action is fetched by that sha. Turntable also remembers, per project, every tag-to-sha resolution it has made (`action_pins`: repository, ref, sha, first and last seen).

If a tag later resolves to a different commit, it has moved. The pin does not change on its own. A protected or release run fails with an error that names the action and both shas, until an operator accepts the move. A pull request run only gets a warning and keeps using the old pinned commit. An operator reviews the new commit (`get_action_pins` shows it as `pending_sha`), then calls `accept_action_move` with that exact sha. The call needs the operator role and is audited, and a wrong sha is refused, so accepting never blesses a commit nobody looked at. Until trust classes land, a push counts as protected and every other event as a pull request class.

### Impostor commits and nested actions

GitHub serves commits from a repository's whole fork network under the parent's name, so `uses: owner/repo@<sha>` can name a commit that exists only in an attacker's fork. Every sha, given or resolved from a tag, must therefore be reachable from a branch or tag of the named repository itself (the compare API against the default branch, then its tags and branches). An unreachable sha is refused with an error that says it may exist only in a fork. Resolving a tag to a sha and checking a sha both call the GitHub API, so the worker authenticates them with the run's own credential: the poll config's token file for a repo the poller watches, else an App installation token minted read-only for that one repo (`contents: read`), else `TURNTABLE_GITHUB_TOKEN`. The poll token serves only a run whose org and project are the ones the poll entry lands runs in. The credential is used only for the run's own repository and for actions whose owner is on the org's action-owner allowlist; it is never used for any other action (including `TURNTABLE_GITHUB_TOKEN`), and never for an untrusted run, not even for its own repo. A workflow can name any repository, so a token used for one would prove a private repo exists, reveal its shas and let a job read its code; every other action is resolved anonymously, where a private repo simply looks not found, and a private repo of an allowlisted owner is refused as a policy failure. A private repo and one that does not exist are refused with the same words (`action not available: owner/repo`), so a workflow cannot learn which private repositories exist. A local run (`turntable run`) is the operator's own checkout and token: its `TURNTABLE_GITHUB_TOKEN` is used for any action that passes the same public check, even when the run simulates a pull request. That check fails closed: only a 200 that says `private: false` passes, a 404 is not-found, and a 401, 403, 5xx or unreadable answer is an infrastructure error, never a pass. The credential and privacy decision sits outside the verdict cache, so a cache hit cannot skip it, and verdicts learned with a token are stored apart from anonymous ones and never served to an anonymous or untrusted path. Action tarballs are fetched anonymously too. Only when no credential applies are the calls unauthenticated, which share GitHub's 60-per-hour limit; the server logs once that no credential exists. Answers are kept in the database per project: a resolved tag for 5 minutes (refs move), a reachable sha for 24 hours, and an unreachable one for 10 minutes. A restart or a second job in parallel therefore asks GitHub nothing it already knows. Failures are never kept. On a rate limit (a 429, or a 403 with `retry-after` or an exhausted `x-ratelimit-remaining`) the worker waits as GitHub asks, up to 2 minutes in total per job, then retries; past that the job ends as an infrastructure error that says when the limit resets. If GitHub cannot be reached, the plan is retried; it is never treated as reachable.

Remote composite actions can contain `uses:` of their own, which act would otherwise fetch by tag over the network. So after pinning, each remote action is read at its sha. A composite's nested actions go through the same resolution: pinned by sha, checked for reachability, the owner allowlist and moved tags, and delivered locally, down to five levels. A composite whose nested actions cannot all be resolved, a docker action (top-level or nested), or a chain deeper than five levels refuses the plan. `require_sha_pins` is about what the project writes; nested tags in someone else's action do not trip it, because Turntable pins them.

### Policy rejections are failures, not infrastructure errors

A moved tag, a refused owner, an unpinned or unreachable action and the other deterministic plan rejections end the job as `failure` with the reason `policy: <message>`. They are not retried: the user can act on them. `infra_error` is kept for transient causes only (GitHub unreachable or rate limited while resolving, a provider down), which are retried.

Two optional project policies tighten this further. `require_sha_pins` refuses any `uses:` that is not already a full commit sha. The org's action owner allowlist refuses actions from any owner not on it (`turntable policy set --allow-owners actions,oven-sh`). Both are off by default and apply to nested actions inside local composite actions too.

## Job cache

Implemented. The control-plane cache assigns each job a namespace from its org, project, trust class and ref scope. A job writes only to its own namespace and never reads one written by a lower trust class, release jobs restore nothing unless a project opts in, each trust class has its own share of the org quota and evicts only within it, archives are validated before they can be restored, and the per-job credential dies with the job. See [Job cache](/docs/cache). Issue [#38](https://github.com/turntable-ci/turntable/issues/38).

## Outbound requests from the control plane

Everything the control plane fetches (the GitHub API and codeload, the Daytona API, release downloads, outbound webhooks later) goes through one client, `@turntable/net`. A source-guard test fails if any other code calls `fetch` or opens a connection itself.

- **Addresses.** The client resolves the host itself and requires every answer to be public. It refuses loopback, link-local (including the cloud metadata address 169.254.169.254), private RFC1918, carrier-grade NAT, unique local (ULA) and the other reserved ranges, and judges IPv6 forms that embed an IPv4 address (mapped, NAT64, 6to4) by the IPv4 address inside. Decimal and hex IPv4 spellings are normalised first. One private record among public ones is enough to refuse.
- **Pinned resolution.** The connection goes to the address that was validated. DNS is not consulted again, so a name that changes between the check and the connect (DNS rebinding) cannot redirect it. When a name has several addresses (all of them validated first), they are tried one at a time with the IPv4 and IPv6 families interleaved, each pinned to its own address, so a host with an IPv6 answer and no IPv6 route still connects over IPv4. Only a failure to connect moves on to the next address (a request that was sent is never repeated), and the overall deadline bounds all attempts together.
- **Redirects.** Followed by hand, at most 5, each hop validated in full (scheme, host, address). A redirect to a refused address is never followed, and credentials are dropped when the origin changes.
- **Scheme and URL.** https only. Credentials in the URL are refused.
- **Caps.** Responses are capped while streaming (32 MiB by default, larger for release and source tarballs) and the whole exchange, redirects included, has a 30 second deadline by default.
- **Allowlist.** `TURNTABLE_NET_ALLOW_HOSTS` names hosts that may be private and may use http, such as a local Daytona. Only those exact hosts.

An address the guard refuses ends the job as a `policy:` failure, not an infrastructure error.

## OIDC identity for jobs

Each org is its own OpenID Connect issuer (`<public url>/oidc/<org slug>`), so a job can prove who it is to a cloud or to Vault and receive short-lived credentials, with no long-lived cloud secret in CI. Tokens are signed ES256 by per-org keys sealed in their own key domain, last at most 5 minutes, carry a mandatory per-request audience, are never issued to `untrusted_pr` (or `trusted_pr`) by default, and every mint is audited. A job asks for one with `permissions: id-token: write`, and the credential stays outside its sandbox behind the secrets proxy. See [OIDC](/docs/oidc).

## Turntable's own token shapes

The log redactor has a built-in pattern for Turntable's own tokens, so one that lands in a job log or an error message is redacted even when nobody registered it:

| Prefix | What | Shape |
| --- | --- | --- |
| `tt_` | An org API token (`turntable token create`, the `create_api_token` operation) | the prefix and exactly 43 base64url characters |
| `tti_` | An instance administrator token (`turntable token create --instance`) | the prefix and exactly 43 base64url characters |
| `ls_` | An org token minted before the rename (formerly Longshore); still accepted | the prefix and exactly 43 base64url characters |
| `lsi_` | An instance administrator token minted before the rename; still accepted | the prefix and exactly 43 base64url characters |

The pattern needs the prefix and exactly 43 base64url characters, which is distinctive enough that `ls_colors` and ordinary words are left alone. It has no boundary on either side and fails closed: a token glued to other text (`xls_<token>`, `<token>abc`, `id=ls_<token>X`) still holds a usable credential, so it is redacted, and so are any token characters that keep going after it. Only a hash of a token is stored, and a token is shown once.

To make your own secret scanner catch a leaked one too, register these as custom patterns (GitHub secret scanning custom patterns, GitGuardian custom detectors, gitleaks or trufflehog rules): `(?:tti|tt|lsi|ls)_[A-Za-z0-9_-]{43}`. Treat a match as a live credential: revoke it with `turntable token revoke <id>` and mint a new one. This repository has no scanner configuration of its own to extend.

## Transport: https only

Plain http must redirect to https on every site we run. The primary control is the proxy or Cloudflare zone ("Always Use HTTPS", HSTS). The server enforces it too, so a proxy misconfiguration never serves plain http: with `TURNTABLE_TRUST_FORWARDED_PROTO=1`, a forwarded `http` request is redirected (301 for GET and HEAD, 400 for other methods, which a redirect would silently turn into a GET), and https responses carry `Strict-Transport-Security: max-age=31536000; includeSubDomains` (configurable or off with `TURNTABLE_HSTS_MAX_AGE`). The forwarded header is believed only when you set that variable, and only its last hop. Check both layers when you ship or audit a site.

## Release lane

Signing and publishing run in a separate process (`serve --roles release`) that alone holds the signing backend and KMS credentials, the release master key and the publish credentials. It re-checks the tag and sha with the forge and recomputes artifact digests itself, so a fully compromised main process cannot cause a signature or a publish. See [Release lane](/docs/release-lane).

## Audit log integrity and export

Every write, denied write, authentication failure, policy change, token create and revoke, approval, secret change and GitHub App change is recorded. A test walks the op registry and fails if any write op does not audit.

- **Hash chain.** Each org has its own chain. An entry carries its position (`seq`), the hash of the entry before it and its own hash: sha256 over the previous hash and the canonical JSON of the entry. Editing, deleting or inserting a row breaks every hash after it. Entries written before the chain existed stay readable and are not chained.
- **Signed checkpoints.** Every 100 entries or 10 minutes (whichever comes first, only when something changed) the server signs the chain head with an ed25519 key. The key is the secret `audit/signing-key` in the encrypted secret store, which uses a different master key from the database. Each checkpoint carries the key id.
- **Explicit setup, never implicit.** Only `turntable audit init-key --org <slug> --out <file>` creates an org's signing key; the checkpointer never does. It also writes the public key file (keep it off the server) and a small sealed state file next to the master key file (`<master key file>.audit-state/<org id>.state`). An org that was never set up is simply not signed, quietly. The state file holds two things the database cannot be trusted with: that a key existed, and the last signed (seq, hash). Back it up with the master key. For an org that signed checkpoints before the state file existed, `turntable audit adopt --org <slug>` writes it after the whole chain and every checkpoint verify, once, on your say-so.
- **Verify before sign.** Before each checkpoint the server re-derives the chain from the last signed position to the head (links and recomputed hashes), checks the stored latest checkpoint's signature and that the entry it covers is unchanged, and refuses, with an alert entry in the org's chain, if anything is off: a missing key (alert, never a new key), a missing, corrupt or mismatched state file, a key that is not the one the org was set up with, a checkpoints table that went backwards (rows deleted), or a chain that no longer extends what was signed.
- **Anchors outside the database.** Everything in the database is where an attacker with database and store access can rewrite it, so verification needs facts kept elsewhere: the public key file from `init-key` (or `turntable audit export-key`), and the export sink's files off the server, which hold every checkpoint. Then `turntable audit verify --pubkey <file> --anchors <file>` (the bodies the anchor sink received, one JSON object per line, work as the file; `--anchor` is the same flag) rejects a chain that ends behind an exported anchor (a rolled-back volume), rejects checkpoints signed by any other key, fails if the chain lacks a checkpoint the anchor has, and fails if the database has fewer checkpoints than the anchor shows. Without them verify prints `unanchored: integrity only`.
- **Anchor state off the volume.** The sealed state file is only worth something away from the database it anchors: whoever can restore or edit the volume restores matching state with it. `TURNTABLE_AUDIT_STATE_DIR` puts the directory on a separate mount or secrets volume (default: next to the master key file, else `<data dir>/audit-state`). `turntable doctor` warns (`audit_state_dir`) while it is inside the data directory.
- **Off-instance anchor export.** Set the instance setting `audit_anchor_sink_url` (`TURNTABLE_AUDIT_ANCHOR_SINK_URL`, `turntable.toml` `audit.anchor_sink_url`, or `instance_set_setting`; instance administrator only, never over MCP, no credentials in the URL) and each org's latest anchor, its newest signed checkpoint (chain head hash, sequence and time, signed with the org's audit key), is POSTed there on every checkpoint and every `audit_anchor_export_minutes` (default 60). It goes through the outbound client, signed in `x-longshore-signature` with the same HMAC secret as the audit export. The body is only `{ "version": 2, "org_id", "sequence", "head_hash", "time", "key_id", "signature" }`: no org slug, name, count or entry content, so the sink learns an opaque org id, a position, a hash and a key id. **Version 2 replaces the keyless version 1 body.** A verifier checks a v2 body under the key its `key_id` names and no other, so a valid signature under a different trusted key does not pass, and a `key_id` that is not a trusted key of the org is refused (`unknown_key`). A v1 body names no key, so it is tried under every trusted key; it is accepted only for anchors at or before the org's v2 cutover, the sequence of the first v2 body the org exported (kept as an org-scope row in `settings`, written once). Verification also takes the lowest v2 sequence in the anchors it is given as a cutover, so a keyless body after a keyed one is refused even with no row (`keyless_after_cutover`). A v2 body whose `key_id` is removed is refused too: it is never read as v1. Point it at a sink this instance cannot rewrite. Sending is off the checkpoint path: a sink that is down, slow or hanging never delays a checkpoint, and each org's send is retried with exponential backoff (5 seconds doubling to 15 minutes) until it is accepted. The HMAC secret is best given as `TURNTABLE_AUDIT_WEBHOOK_SECRET` or from a secrets mount named by `TURNTABLE_AUDIT_WEBHOOK_SECRET_FILE`, not a file on the data volume. It is read once at boot and the variable is deleted from the process environment; setting both is an error. Each new anchor sent is audited as `audit_anchor_export` in the system chain (the same anchor re-sent on the interval is not, and nor is the system org's own, so an export never causes the next checkpoint), and the first failure of a streak (not each retry) is audited as `failed`.
- **Verify with no shell.** `instance_audit_verify` (instance administrator, REST only, read-only) takes exported anchor bodies and, per org, walks the chain and checks every anchor's signature (under its named key, for v2) and hash. It answers `ok`, `rolled_back` (the chain ends behind a validly signed anchor: rows removed or an older database restored) or `mismatch` (a hash or signature disagrees, the chain is broken, or the org is unknown), with fixed sentences and no raw errors; a `reasons` list classifies a refused anchor (`unknown_key`, `keyless_after_cutover`). It shares its checks with `turntable audit verify --anchors`. It verifies under the key in the secret store, not a key pinned outside the server, so it does not replace `--pubkey` against an attacker who controls the store too. The call is audited as a read in the system chain.
- **Verify.** `turntable audit verify [--org <slug>] [--pubkey <file>] [--anchors <file>]` walks every chain and exits 1 on any problem, including entries older than twice the checkpoint interval that no checkpoint covers (checkpoints deleted or signing stopped), and any chain that has checkpoints when no public key is pinned. Without `--pubkey` nothing is vouched for: the chain's own rows (including any row that claims to record the key being created) can be written by whoever can rewrite the database, so none of them is trusted to settle it. `turntable audit checkpoint` signs the head on demand, under the same checks.
- **Authentication failures** are audited in the token's org when the token is known (revoked or expired), and in a system org called `_system` otherwise. Throttling is per org, failure kind and source (a token id, a hashed unknown token or a client address), at 5 per minute per source, so one noisy source cannot hide another's failures; a per-chain ceiling of 300 a minute bounds many sources. The first failure of each distinct token id is always recorded, and a dropped count rides on the next entry. Webhook requests the rate limiter already refuses are recorded only in aggregate: one entry per minute with a count.
- **Secrets** are audited by name only, never by value.
- **Export.** Entries and checkpoints stream to a JSONL directory (rotated at 10 MiB, files mode 0600) or a webhook, with at-least-once delivery and a cursor per sink that moves only after the sink accepted the batch. Webhook posts go through the outbound client and carry an HMAC in `x-longshore-signature`. Ship the files off the host to make deletion on the server detectable. `turntable audit export` runs one pass by hand.

## Scoped per-job GitHub token

When the GitHub App is configured, each job gets its own installation token as `GITHUB_TOKEN` (`secrets.GITHUB_TOKEN`, `github.token`). Turn it off with `TURNTABLE_JOB_TOKENS=off`.

- **One job, one token.** It is minted when the job starts, never cached and never shared with another job, and revoked at GitHub (`DELETE /installation/token`) when the job ends, however it ends: success, failure, cancel, timeout or loss of the lease. A worker that dies cannot revoke it, so it also expires after GitHub's one hour.
- **One repository.** The token names only the run's bound repository.
- **The workflow's permissions.** The job's `permissions:` block (which replaces the workflow's, as on GitHub), mapped to what an installation token can carry. With no block the token has `contents: read` and nothing else. `id-token`, `attestations` and anything else an installation token cannot carry are dropped; the job log says so. Turntable's own [OIDC issuer](/docs/oidc) is the way to ask for an identity token.
- **Capped by trust class.** `untrusted_pr`: `contents: read` only, whatever the workflow asks for. `trusted_pr`: what was asked for, never write. `protected` and `release`: what was asked for.
- **Capped by the installation.** The token is never wider than what the App's installation was granted: a permission the installation lacks is dropped, a write it only has as read is lowered, and the log says what changed. GitHub's own refusal is the backstop.
- **Only when it is needed.** A token is minted when the capped permissions need one: any write scope, a scope beyond `contents: read`, or a private repository (contents read is needed to fetch it). A job on a public repository that needs nothing beyond `contents: read` and `metadata: read` gets no token at all: `GITHUB_TOKEN` is unset, its source is delivered by the controller anyway, and its log says why. That is the case for `untrusted_pr` and `trusted_pr` on public repositories, whose egress is unchanged. Visibility is asked of GitHub as the App, with a read-only installation token for that one repository (the one action pinning already uses), so it does not spend the anonymous rate limit; the answer is remembered for ten minutes. Only a real error (GitHub unreachable, the token refused) counts as private.
- **Delivery.** With the [secrets proxy](/docs/secrets-proxy) the job holds only a placeholder in `GITHUB_TOKEN` (and in act's `secrets.GITHUB_TOKEN`). The proxy attaches the real token to requests for the repository's own API paths (`/repos/<owner>/<repo>`), GraphQL, and git over HTTPS for that repository; every other path and repository gets nothing. Without the proxy, a `protected` or `release` job gets the real token in its environment (written to a `0600` file the launcher sources and deletes, never an argument, and registered with the log redactor); every other class gets none. A job whose token could not be minted still runs, and its log says there is no token.
- **A job that gets a token is secret-bearing.** Its sandbox's egress is probed from inside before it runs, whether or not the canary is switched on for other jobs, and a probe that cannot give an answer refuses the job (the token is revoked) instead of letting it run. With the proxy it runs behind the proxy (deny-all-except-proxy, with the canaries), and it cannot use open egress: a plan that asks for `open` is refused, and the token is revoked at once. It reaches `github.com` only for its own repository; the other repositories its actions or submodules name must be pre-staged or listed as [passthrough hosts](/docs/secrets-proxy). This is the trade-off for a write token or a private repository, and why a public repository's read-only job gets no token.

## Signing service

A signing service signs release artifacts and writes the provenance that says how they were built, so signing keys never enter a sandbox. It runs in the release lane, refuses artifacts that are not release class, and needs the environment's approvals first. It is the substitute for GitHub artifact attestations. npm trusted publishing does not accept self-hosted OIDC issuers, so npm publishing uses proxy-injected tokens. See [Signing and provenance](/docs/signing) and [Release lane](/docs/release-lane).

## Human approvals

Unlike the sections around it, this one is implemented. A job in a protected environment waits for people, and only people can release it: no bearer token, session, agent or MCP call can approve. Issue [#46](https://github.com/turntable-ci/turntable/issues/46).

### What is signed

A job whose workflow names `environment: production` (or `release`, or any environment with a configured policy) is created waiting in `awaiting_approval`. Approvers sign an **approval statement**: canonical JSON (sorted keys, no whitespace) of

```json
{ "type": "longshore.approve_environment.v1", "org": "acme", "project": "api",
  "run_id": "...", "head_sha": "...", "workflow_hash": "...", "environment": "production",
  "approver": "<approver key id>", "expires_at": 1767225600000, "nonce": "..." }
```

The signature is bound to that exact commit, workflow and environment. If any of them changes (a new push is a new run), or the statement expires (at most 7 days; 24 hours by default), the signature approves nothing. A statement is accepted once. The `type` field keeps a signature for one kind of statement from being replayed as another.

### Two ways to sign

- **WebAuthn (passkey or security key).** The UI calls `approval_challenge`; the server issues the statement and a single-use challenge equal to the hash of the statement. The browser signs it with the approver's passkey. The server checks the challenge, the origin, the relying party id, that the authenticator verified the person (PIN or biometric), the signature, and that the sign counter moved forward. Registration uses attestation "none": a key is trusted because existing approvers enrolled it, not because a vendor certified it. Set `TURNTABLE_PUBLIC_URL` (or `TURNTABLE_WEBAUTHN_RP_ID` and `TURNTABLE_WEBAUTHN_ORIGINS`) so the relying party is known; a passkey is bound to the relying party id, so changing it orphans every enrolled passkey. WebAuthn needs no change to the page's content security policy.
- **Offline ed25519.** An approver key held off the machine signs the canonical statement text. `turntable approvals keygen` makes a key on the approver's own machine (the private key never leaves it) and `turntable approvals sign` signs a statement. The signature is uploaded to `POST /api/v1/approvals`, which takes no token: the signature is the credential.

An agent may relay a statement a human already signed (the `submit_approval` tool). It cannot create a statement for signing, and a token without a human's valid signature approves nothing. `approval_challenge` is not an MCP tool.

### Two-person rule

Each environment needs a number of distinct people. The default is 2 for `production` and `release`, and 1 for any other environment you configure. Distinct means different verified forge logins (compared lower-cased), not different keys and not different `person` labels: the label is free text, so two labels on one login count once. Turntable refuses to enrol a forge login that an active approver already holds under a different person; a second key for the same person and login is fine and counts once. A key with no forge login has no identity and counts for nothing: not in approvals, not in the enrolment quorum, not in `ApprovalVerifier`, even under the solo policy that lets authors approve. The Approvers page, `approvers_overview` and `approvals list` show such a key as not counting. Set it with `turntable approvals policy --org acme --environment production --required 3`. The policy is the `approval_policy` setting: one map per org, keyed by environment name, with `required` (1 to 10), `allow_author_approval` and `key_policy` (`any` or `hardware`, which adds the hardware rule to that environment on top of the org's key policy and never removes it). The CLI, the approval engine and the release lane read and write it through the same settings resolver, so what `approvals list` shows is what is enforced.

**Hosted path (no shell).** On a hosted instance nobody has the CLI, so the policy is set where the operator already sets the instance: in `turntable.toml`, `[orgs.acme.approval_policy.release]` with `required = 1` and `allow_author_approval = true` (or `TURNTABLE_APPROVAL_POLICY`, a JSON map that applies to every org), or by the instance administrator with `instance_set_setting` and `target_org`. A value in the environment or the file locks the setting: the CLI and the instance op refuse to change it and say where it is set. The setting is `instanceAdminOnly` and never editable over MCP, so an org token of any role cannot lower it and neither can an agent. Lowering it (fewer approvers, the author allowed to approve, a weaker key policy, or an environment that stops waiting) is written to the audit chain of the system org and of the org with the old and new values, emits an `approval.policy_loosened` event, and shows a warning on the setting in the web UI. A change made by editing `turntable.toml` is the operator's deploy and is not audited by the server.

**The author of a run cannot approve it.** The rule compares the approver's forge login with the run's author, and it fails closed: if either is unknown the approval is refused ("cannot establish that the approver is not the author"). That is why a forge login is required whenever an approver is enrolled. A run with no recorded author is refused, with one exception: a run the poller made from a tag (see [Releasing from a tag](/docs/release-lane#releasing-from-a-tag)), whose stored facts name the tag. For that run no approver is excluded, whoever tagged, and the environment needs one more distinct identity than its quorum, so at least the quorum's worth of approvers are not the author: a quorum of 2 needs 3 distinct approvers, a quorum of 1 needs 2. The audit log says so (`approval_author_unknown`, "author unknown; required N distinct approvers"). The tagger's name is free text the tag's creator chose, so it never excludes an approver. `--allow-author-approval` turns the rule off for an environment, and with it the check. That is for a solo setup only, and it removes the guarantee that a second person looked: with it, the person who pushed the change can release it alone. Leave it off wherever more than one person can push.

**A signed statement binds its tenant.** The org and project slugs are part of what is signed, and a statement is refused unless they are those of the org and project it is submitted to.

**`human` needs an approver.** Selecting `untrusted_run_approval = human` (`set_setting`, `set_project_settings`, `turntable policy set`) is refused with `human_requires_approver` unless the org has an active approver that counts: not revoked, with a forge login, and a key that satisfies the org key policy. A value of `human` in `turntable.toml` or the environment cannot be checked per org at boot, so keeping an approver enrolled is the operator's responsibility; the `human_approval_approvers` doctor check warns when a project is on `human` and its org has none (for example after a revocation or a tightened key policy).

**`human` assumes the `hardware` key policy.** Under the `any` policy an ed25519 key file counts, and a key file on a machine where agents run lets an agent sign an approval statement as if it were the person. Pair `human` with `hardware` so only an attested hardware key counts. The `human_approval_key_policy` doctor check warns when a project resolves to `human` while its org key policy is `any`.

### Enrolling approvers

**The two-person rule is only as strong as enrolment.** The enrolment quorum is the production policy's count, capped by how many other people could sign. With one person enrolled the cap is one, so a lone approver can enrol a second identity alone, and "two people" can then be one person holding two keys. Until at least as many people are enrolled as an environment requires, the rule is not a guarantee. Turntable says so: `approvers_overview` returns a warning, the Approvers page shows it, and `turntable approvals bootstrap` and `list` print it. Enrol the second real person promptly, and treat the first bootstrap as a setup step, not a steady state.

The first approver of an org comes from the server's CLI, the local trust root: `turntable approvals bootstrap --org acme --person alice --forge-login alice-gh --public-key alice.pub`. On a hosted instance with no shell, the instance administrator does the same over REST with `bootstrap_approver` (`POST /api/v1/instance/approvers/bootstrap`, a `tti_` token, never MCP; see [Hosted](/docs/hosted#the-first-approver-on-a-host-with-no-shell)). It takes the org, the forge login and an ed25519 public key generated offline, so no private key reaches the server, and it shares its code with the CLI. It is single use per org: it is refused once the org has any active approver and never adds to an existing set. When every approver was revoked it is refused until the `approver_rebootstrap_delay_hours` delay (24 hours by default) has passed since the last revocation, so a stolen token is not release power by itself; the last revocation and each bootstrap emit events and are audited in both chains. It is audited in the system chain and the org's own chain with the key's fingerprint, never the key. No org token of any role can call it. This is the one place where the instance operator, not an org approver, decides who the first approver is, so treat the instance token like the host's CLI. After the first approver exists, the CLI and the op both refuse, and the API refuses to enrol the first one. Every further key needs a quorum of existing approvers: someone requests an enrolment (`request_enrolment`, with a passkey registration or an ed25519 public key), and existing approvers sign it with `approve_enrolment` (the UI's Approvers page does this). The quorum is the production policy's count, capped by how many other people could sign, and a person cannot approve their own new key. Every enrolment names the person's forge login, and the signed enrolment statement carries it, so approvers sign off on the identity being granted (the Approvers page and `turntable approvals sign` show it). The enrolment quorum is counted over distinct logins, excluding only the enrolee's own login. Open challenges are capped per caller (not per org) and expired ones are purged. Revoke a key with `turntable approvals revoke`.

### Key policy: any or hardware

Each org sets which keys its approvers may use, the same way it sets the approval count.

- **`any`** (the default): any WebAuthn passkey with user verification, or an offline ed25519 key.
- **`hardware`**: only passkeys whose attestation chained to a vendor root pinned in the binary (Yubico today) when they were enrolled, and whose AAGUID is on the org's allowlist. The preset `yubikey` covers the YubiKey 5 and Bio series; add other devices by AAGUID. Registration then asks the authenticator for direct attestation and accepts the `packed` format with a certificate chain. Nothing is fetched at runtime. Offline ed25519 keys cannot satisfy `hardware`.

**Changing the policy is a trust-root change, so it takes the same quorum as enrolling a key.** There is no token operation that sets it. An operator asks for the statement (`key_policy_challenge`: the policy being replaced, the new one, a hash of the AAGUID allowlist it expands to, an expiry and a nonce), and a quorum of the currently counted approvers signs it (`approve_key_policy`, from the Approvers page or the API; not MCP). The quorum is the production policy's count, capped by how many counted people there are, computed before the change, and signers must count under the policy being replaced. A statement is bound to the policy it was issued against: once the policy moves on, it is refused. A change that would leave fewer counted people than that quorum is refused, so a change cannot quietly lower the quorum or lock the org out. The one exception is the server's CLI, the local trust root, and only while the org has no approver at all: `turntable approvals key-policy --org acme --policy hardware --preset yubikey`. Read the policy from `approvers_overview` or `turntable approvals list`.

Tightening it never deletes a key. A key that does not satisfy the policy stops counting at once, in approvals, in the enrolment quorum and in `ApprovalVerifier`, and the Approvers page and `approvals list` say why. Enrol hardware-attested keys first, while the policy is `any`, and enrol at least as many people as the quorum before tightening.

Attestation is only trusted when the device certificate carries the FIDO AAGUID extension and it matches the credential: a certificate without it proves no model, so it is never verified and never matches the allowlist.

**Touch ID and Face ID passkeys cannot satisfy `hardware`.** They are synced through iCloud Keychain and give the browser no attestation, so in practice `hardware` means security keys such as a YubiKey. If your team uses platform passkeys, leave the policy at `any`.

**Solo orgs.** One person can run the org: enrol your key with `bootstrap`, set the production and release policies to one approver with `turntable approvals policy --required 1 --allow-author-approval`, and accept that the single key is the whole guarantee. That is the case to use `hardware` for: enrol a security key as a second key (the bootstrap key signs for it while the policy is `any`), then sign the switch to `hardware` with the counted approvers (with one counted person the quorum is one) so a stolen laptop or a copied offline key cannot approve. An offline-key path for hardware keys (FIDO `sk` keys with attestation captured at enrolment) is a follow-up.

### For the signing service

`ApprovalVerifier.verify(subject, environment)` (in `approvals/verifier.ts`) is what the release lane calls before it acts. It never trusts a stored flag: it re-verifies each stored statement against the approver keys (the org's, or the caller's own key store), checks the statement binds exactly this run, sha, workflow and environment, drops expired, revoked and self-approved ones, and requires the policy's number of distinct people.

## Artifact provenance and quarantine

The core invariant: a release build consumes nothing a lower trust class could write. Every recorded artifact carries its provenance, and consumption checks the class.

- **Provenance.** When an artifact is recorded, the control plane stores the trust class of the producing attempt, capped by its run's class (an attempt can run lower than its run, for example a re-run under another decision; either class missing means `untrusted_pr`), the commit it ran at, the digest and how it was obtained (`reported` by the recorder, or `computed` when the control plane hashed the bytes itself and they matched). The caller cannot name a class. Rows are only inserted, and a name is recorded once per run. `get_artifacts` shows it.
- **Classes are ordered** `untrusted_pr`, `trusted_pr`, `protected`, `release`. A consumer may always take an artifact of its own class or a higher one. A lower-class artifact reaches a higher-class consumer only when the request names it, and then it arrives as quarantine: never executable, never an input to a build. A **release** consumer is denied anything below the release class, however it asks. `check_artifact_consumption` decides per artifact and does not move bytes.
- **See it.** `turntable artifacts list --run <id> --project <slug> --url <host> --org <slug> --token-file <file>` shows each artifact's class, digest (and whether it was computed or reported), commit and size; `turntable artifacts check --consumer <run> --source <run>:<name> [--quarantine <run>:<name>]` prints allow, quarantine or deny per source and exits 3 if any is denied. The run page has an Artifacts tab with the same facts. It does not decide anything itself: it asks `check_artifact_consumption` once as the run (an artifact it may not take as is, because a less trusted attempt wrote it, is shown as quarantined) and once as a release build (`consumer_class: release`), and shows the server's answer and reason. The check takes either a consumer run or a consumer class.
- **Signing.** The signing service refuses to sign an artifact whose recorded class is not `release` (`artifact_not_release_class`), on top of the existing run-class, ref and approval checks.
- **Upgrading.** Artifacts recorded before this change have no stored class, so they default to `untrusted_pr` and must be re-recorded to be signable. This is in the release notes.
- Everything is tenant scoped: another org's run or artifact is "no such".

Read the class and the consumption decision with `turntable artifacts list|check` or the Artifacts tab on the run page. Not built: the transport that delivers a quarantined artifact into a job (no job consumes another run's artifacts today). When it exists it must call the same decision, mount quarantined files non-executable, and never mount any into a release job.

## Per-org quotas

An instance operator can cap an org's concurrent attempts, runs per hour, sandbox time per day, stored log bytes and stored artifact and cache bytes, so one tenant cannot starve the others. Quotas are set on the host only (`turntable quotas set`), never over the API, and a stored concurrency limit can only lower the instance's per-org cap. See [Configuration](/docs/configuration#per-org-quotas).

## Incident response

Unlike the sections above, this one is implemented. When a secret may have leaked or a runner is compromised, one operation stops the bleeding and a second tells you how far it reached.

### Freeze

`incident_freeze` (REST `POST /api/v1/incident/freeze`, MCP tool, or `turntable incident freeze --org acme [--project api] --reason "..."`) needs the release_operator role. It freezes the org, or one project, and in one audited step:

1. **Pauses scheduling.** A persisted flag on the org or project. The claim path checks it on every claim, so no worker, in any process, starts a job of the scope until it is lifted. Runs that arrive while frozen (webhooks, polling) are created and wait in `queued`.
2. **Kills running jobs.** Every run with a running job is cancelled through the same path as `cancel`: workers stop and sandboxes are destroyed. A worker in another process stops at its next heartbeat. Runs that have only queued jobs stay queued and resume after unfreeze.
3. **Drops cached credentials.** The GitHub installation tokens held in the server process's cache are dropped, so the server mints fresh ones only after you unfreeze. GitHub does not let the server revoke an installation token early: a token already handed to a job lives until it expires, within an hour. A freeze run from the CLI is a different process and cannot reach the server's cache; use the API to drop it. Agent API tokens are not revoked by a freeze, so you can still operate. Revoke the ones you do not trust with `turntable token revoke`.
4. **Flags secrets.** Every secret name in scope is flagged `rotation_required`. Names only: a freeze never reads or changes a value. The built-in store (the GitHub App's key and webhook secret) is org-wide, so only an org freeze flags it. Vault secrets are flagged by name too: an org freeze flags every vault secret name in the org, a project freeze those of the project. One name can be several scoped secrets, and the flag is by name. A flag remembers which store raised it and is closed only by an update in that store: rotating (`rotate_secret`, or `set_secret` on an existing scope) closes a vault flag once every vault secret of that name has a newer version than the flag, and updating the built-in secret closes the built-in flag. A project-scoped token can close only its own project's flags, never an org-wide one.
5. **Writes an audit entry** with the reason, the principal and the outcome.

The reason is shown in the web UI to everyone on the org or project. Freezing a frozen scope keeps the first reason and time and still kills, drops and flags.

`incident_unfreeze` clears the pause only. Killed runs stay cancelled and secrets stay flagged until they are rotated. If the org is frozen, unfreezing one project does not resume it.

`incident_status` (reader) reports the freeze and how many secrets still need rotation; the names are listed only for release_operator and above, the same role that can list secrets.

### Blast radius

`secret_usage` (release_operator, like `list_secrets`: it reveals destinations and which runs held the secret) takes a secret name and a time range and lists each recorded use from the audit log: when, the run, job and attempt, the destination host, the version and the trust class it ran as. Start the range at the earliest time the secret could have leaked. It reads the per-use records the vault writes to the audit log (`secret_use`: secret name, run, job, attempt, destination). Values are never in the audit log. Denied uses are throttled samples and are not listed. Results are capped; narrow the range when `truncated` is true.

### Runbook

1. **Freeze.** `turntable incident freeze --org acme --reason "deploy key printed in a build log"`. Read the counts it returns.
2. **Scope it.** Run `secret_usage` for each affected secret from before the first suspect run. Note every destination: each is a place the secret may now be.
3. **Rotate at the source.** Replace the credential where it is issued (the registry, the cloud account, the forge). Then store the new value (`turntable secret rotate`). Anything flagged in `incident_status` is on your list until rotated.
4. **Rotate Turntable's own secrets** if they were in scope: the GitHub App private key and webhook secret (`turntable github-app rotate-webhook-secret`), the master key (see the [rotation runbook](/docs/hosted#the-master-key-from-a-variable-and-rotating-it)).
5. **Revoke agent tokens** you do not trust, and review the audit log for the window (`turntable audit verify`, `turntable audit export`).
6. **Review the runs** that used the secret: logs, artifacts, and what the destinations received.
7. **Unfreeze** with `turntable incident unfreeze --org acme`. Queued work resumes. Keep the rotation flags open until each secret is rotated.

## Reporting vulnerabilities

See `SECURITY.md` in the repository.
