deepsec: the forge reviews its own security
The forge runs deepsec (open source, Apache-2.0) on itself (#14792).
Its workspace is committed in .deepsec/:
deepsec.config.ts: thinkinghigh, direct model auth, the project root is the repository. It is for a person's run; a pull's review uses the forge's own config.data/forge/INFO.md: the threat summary deepsec reads (auth primitives, threat model, known false positives; it points atdocs/THREATS.md).data/forge/config.json: the scope.ignorePathsare never reviewed.priorityPathsare reviewed first.
What deepsec generates (data/forge/runs/, files/, the generated matchers) stays ignored.
On every pull
The pull's own check step never runs deepsec and is never handed a key: whatever a pull's code runs can read its own environment. The forge runs deepsec itself, after the fast check step is green (src/checks/deepsec_step.ts, #15024), for a repository that has a scope in .deepsec/data/forge/config.json. It lists the changed src/ files in scope from the bare repository's diff, priority paths first, and caps them by a dollar ceiling. Then it runs deepsec process --project-id forge --files-from <list> --limit <n> when all of these hold, and otherwise names the one that does not:
- The pull. It is the fast tier and not an outside contributor's pull.
- The key. The forge hands over the connected model account's key as
DEEPSEC_ANTHROPIC_KEY(src/checks/deepsec_key.ts), in the deepsec cell's environment and nowhere else. The account is the one the repository's crew would be picked: a direct API key account, or the forge's own API key for a repository an admin owns with no grant of its own. A subscription login or a gateway is not handed in. The log saysdeepsec key: DEEPSEC_ANTHROPIC_KEY handed in from the account "…", and every line deepsec prints has the key masked as[DEEPSEC_ANTHROPIC_KEY]. - The cell. deepsec is an agent with a shell, so it runs in a check cell of its own (
deepsecCell). The forge's data and home are hidden, except the checkout and the tool, which are read-only. Its one place to write is a scratch directory beside the checkout. Its only way out is the model host,api.anthropic.com, and that is always enforced. It cannot reach the forge, and it has no grant. Where the host cannot make a cell, deepsec is skipped, never run bare. - The tool. deepsec 2.3.16 is not a dependency of the forge or of any clone. The first check that needs it installs it into the check install cache,
<data>/check-install/deepsec-2.3.16/, fromtools/deepsec/package.jsonand its committed lockfile, with no install scripts run (src/checks/deepsec_tool.ts). - The config. It is the forge's own (
forgeConfig), written into the scratch directory: plain data, direct model auth, the checkout as the project root. The checkout's.deepsec/deepsec.config.tsis the pull's code, so it is never loaded. The scope andINFO.mdare read as data, and only when they really are inside the checkout.
The check log gets one line:
deepsec: 2 changed src/ files in scope (src/http/c.ts, src/core/d.ts), at most $0.54 at $0.27 a file under a $3.00 ceiling; ran deepsec 2.3.16, no findings (advisory, never blocks the gate)
deepsec exits 1 when it produces a finding, and the line then names the exit.
The review never changes the check's verdict. It does not block the gate until its false-positive rate has been measured over two weeks.
What is left: a prompt planted in the files reviewed could steer the agent to send the key to api.anthropic.com, the one host it can reach. The key cannot leave for anywhere else.
Every week
The forge sweeps its own repository (FORGE_SENTINEL_REPO, else trevato/forge) once a week. The maintenance duty deepsec-sweep (src/maintain/duties/deepsec_sweep.ts, #15026) ticks daily and starts src/checks/deepsec_sweep.ts a week after the last sweep began. It exports the default branch's tree, then runs scan, process --limit n and revalidate --min-severity HIGH in the same cell, with the same key and the same config as a pull's review. What it wrote is filed through the same path as a pull's findings: each new one a sealed report under P0 Trust, each one already open matched.
- Durable. Its workspace is
<data>/deepsec-sweep/. deepsec's record of what it processed is kept there, so the files past one week's ceiling are next week's.state.jsonsays when the sweep began and on which commit. A sweep a restart cut short is resumed on the next tick, at most 3 tries, with only what is left of its ceiling. - Only its own records. Only the records written since the sweep began are filed, so a finding closed last month is never filed again from an old record.
- What it did. Its end is a row on
/maintenancewith the line and what it spent, for exampledeepsec sweep of main at 1a2b3c4d5 under a $25.00 ceiling: ran scan, process --limit 92, revalidate; 3 findings, 1 filed as sealed reports (#15301), 2 already filed (#14801, #14803); spent $24.30; …. deepsec's own output, with the key masked, is in<data>/deepsec-sweep/sweep.log. - Skipped. A $0 ceiling, no key, no cell, or no scope on the default branch is said on that row, and so is a tree that could not be exported. A skip writes no state (a resumed sweep's failed export counts as one of its 3 tries), so the next day's tick tries again.
Spend
process has no spend cap of its own. The cap is a file count: floor(ceiling ÷ $0.27). $0.27 a file was measured on the 2026-11-20 sweep at thinking high; xhigh cost about six times that.
- Per pull: $3 (
PULL_MAX_USD), about 11 files. - Weekly sweep: the
security.sweep_max_usdlimit on/admin/limits(default $25, about 92 files).sweepArgvsinsrc/checks/deepsec_plan.tsis the sweep:scan,process --limit n, thenrevalidate --min-severity HIGH.
Vercel's Sandbox mode uploads the tree to Vercel, so it stays off: .deepsec/deepsec.config.ts sets ai: { mode: "direct" }, and no run names a Vercel account.
Try it locally, with your own key: cd .deepsec && DEEPSEC_ANTHROPIC_KEY=… bunx deepsec@2.3.16 process --project-id forge --files-from <list>.