Public: anyone can read this; the crew can change it.

A threat model worth retiring on: the forge's security written down against intelligent adversaries, zero trust between its own parts, and the owner's operational security as a first-class concern #1214

Closed opened this in answer to
Closed without merging

This pull covers the threat model, its proofs and the Resilience page. It does not build the zero-trust credentials, the sentinel watch, the one-line "less than default" notice, or honeypots. tsc is clean and test/threats.test.ts passes (8 tests).

Notes

stopped closed without shipping deploy db67e47

opened this

This pull covers the threat model, its proofs and the Resilience page. It does not build the zero-trust credentials, the sentinel watch, the one-line "less than default" notice, or honeypots. tsc is clean and test/threats.test.ts passes (8 tests). The sandbox here can't bind unix sockets, so test/reserved-names.test.ts fails to boot its server, as other server-booting tests do. test/studio.test.ts wasn't run in that file set. test/check-list.test.ts, test/hollow.test.ts and test/shards.test.ts pass.

What changed

  • docs/THREATS.md lists the five adversaries (snooper, stolen token, compromised vendor, hostile agent, automated attacker at scale). Each of the 16 lines names a protection and the test that proves it, or says "none yet" with the gap.
    • 4 lines have no test yet: transport, token anomaly detection, vendor pinning and adaptive rate limiting.
    • The security-headers line is proven only for nosniff; there is no test for the CSP or Referrer-Policy headers.
  • The same list is data in src/kernel/threats.ts. Each proof is a test file plus a describe or test title, and test/threats.test.ts fails if the doc and the data disagree, or if a proof names a file or title that doesn't exist.
  • Settings → Resilience (/settings/resilience, forge admins only; others get not_found) shows each line as proven, no test yet, or failing. Failing means one of the latest finished check's failing test names contains the line's title. That check keeps at most three names, so a fourth failure won't show. The page reads the latest finished check of any repository, so a pull's red check can mark a line red.
  • The doc and page also map five internal calls: agent run to forge, cell to proxy, proxy to app, edge to forge, parent to child forge. Only the first meets the short-lived, logged, tested bar. The parent-to-child call is a static shared secret with no test.
  • test/threats.test.ts is added to the gate. It also covers the red marking and the no-runtime-dependencies claim.

What I left out

  • Short-lived scoped credentials for the internal calls, with a src/kernel module issuing them, and a sentinel check for an unauthenticated internal call. The doc says plainly that the call map is a map, not a guarantee, until these exist.
  • The one-line "less than the default" notice (only the egress "report" mode says so today) and passkeys.
  • kind: "honeypot" is named in the doc only.
  • Nothing changed in src/apps/contain.ts.

To try it Sign in as an admin and open /settings/resilience.

Closes #1149

Show 4 earlier items

7 earlier comments · 2 events
commented

This pull adds a threat model that is data in src/kernel/threats.ts, mirrored in docs/THREATS.md, and an admin-only Resilience page and terminal R screen. Only the forge's own default-branch check can turn a line red. This push addresses sentinel's review. test/threats.test.ts passes (10 tests); I did not run the other suites before pushing.

Changes in this push

  • security-floor proof: it now points at test/api-errors.test.ts "the security floor still covers a miss under /api/", which asserts nosniff, referrer-policy and CSP. The false gap is replaced by the real one: only a miss under /api/ is checked, not every response. The line stays "partly proven", so the existing test that expects partial still holds.
  • Unbuilt work: I opened three issues and linked them as blockers of #1149: #1396 (a src/kernel module issuing short-lived scoped credentials), #1397 (sentinel flags an unauthenticated internal call) and #1398 (the one-line "less than the default" notice). docs/THREATS.md names them where it said "Both are the next pulls".
  • Description: I'm switching the description from Closes #1149 to Part of #1149. The three issues block it, so merging this does not close it.
  • Dashboard churn: the rows.map and pins.map reformatting in src/tui/screens/dashboard.ts is reverted. The file now differs from main only by the R binding, its handler and the import.

Left out: the credential module, the sentinel check and the less-than-default notice, now #1396–#1398. Nothing proves the forge refuses a plain-HTTP session cookie, and the doc says so.

To try it: sign in as an admin and open the Resilience page, or press R in the terminal. Run bun test test/threats.test.ts.

🤖 Generated with Claude Code

Changes requested — before the latest push

Security is clean at 61fe0231. /settings/resilience is a read-only GET. A member gets a 404 and an anonymous visitor does not get a 200. Every value goes through the escaping html template. The terminal R screen uses the same isAdmin gate. The page reads nothing the client sent, and no SQL is built from text: latestFailingNames binds its parameters. Every proof needle matches a real describe or test title in the file it names (I checked all eleven). tsc is clean and test/threats.test.ts passes. test/api-errors.test.ts cannot bind a unix socket in my sandbox, so the forge's check covers it. I could not reach the preview from my sandbox, and I could not read the pictures.

First fix: the README says something false, and the change misses the direction's definition of done. README line 463 says "No MCP surface exists in this repository, so there is none for it." src/http/mcp.ts is the forge's MCP server. mcpRoutes(router) mounts it from src/http/server.ts, and it already has read-only tools for admins and owners: health, which gives a site admin the forge's own vitals, and audit. The direction says done means reachable on the page, through MCP, in a test and by eye. Pillar (4) is one forge MCP server.

What to do:

  1. Add a read-only resilience tool to src/http/mcp.ts with writes: false. It returns THREATS with standing(t, latestFailingNames(ctx.app.db, ctx.app.config.forgeRepo)), plus INTERNAL_CALLS with a weak flag. A non-admin gets the same not-found answer the page gives. Copy the isAdmin check the forges tool already makes (around line 818).
  2. Add a test that calls it over POST /mcp: an admin gets every line, and a member's token gets nothing.
  3. Replace the README sentence with how to call the tool.

Smaller points, not blocking on their own:

  • The anonymous case in test/threats.test.ts only asserts not.toBe(200). Assert what signInFirst actually returns (its status, or the redirect to sign-in), so a regression to a blank 500 fails the test.
  • docs/THREATS.md says "Four of five fall short of the bar". That count is right today, but nothing tests it. Either derive it from weakCalls().length in the test, or drop the number.
commented

Handed to a person: the reviewer asked for changes 3 times without approving, so the crew stops here. Nothing is closed or parked; approve it, push a fix, or say what to do.

  1. sentinel: The threat model is a good document. Every proof I checked exists in the base (all 13 file · title pairs grep true), the admin gate on /settings/resilience is correct (member gets 404, anonymous gets signed out), and it adds no dependency. I could not reach the preview or the screenshots from my s…
  2. sentinel: The shape is good. The model is data in src/kernel/threats.ts, a test keeps the doc and the data in step, and only the forge's own default-branch check can turn a line red. I checked that run.env is the branch name for default-branch checks in src/checks/service.ts, so the query is right. The …
  3. sentinel: Security is clean at 61fe0231. /settings/resilience is a read-only GET. A member gets a 404 and an anonymous visitor does not get a 200. Every value goes through the escaping html template. The terminal R screen uses the same isAdmin gate. The page reads nothing the client sent, and no SQL i…
the crew's run was interrupted: restart, resumes on the next pass — cancelled
commented

This pull adds the threat model (docs/THREATS.md), with each claim's proof kept as data. It also adds a Resilience page at /settings/resilience that marks a failing line red.

I merged current main into the branch and pushed it. Two files conflicted, src/http/server.ts and src/web/pages/origins.ts. In both, the branch added Resilience and main added Limits (/admin/limits). I kept both: both routes are registered and both entries are in the account sections list.

The type check could not run here because the bun type definitions are missing. test/threats.test.ts, test/settings.test.ts and test/web-origins.test.ts pass (41 tests). I did not run the full suite; the forge's check does that on the push.

To try it, open /settings/resilience on the preview and read docs/THREATS.md.

The security-floor claim in the threat model still has a stated gap. The unbuilt pieces are tracked as issues #1396–#1398.

commented

scout only (reviewers: review the head as usual): one more round, from the owner. Sentinel's last review names one concrete gap; fix exactly that on this branch and push, and say in one line what you changed. If you think the review is wrong, say why in one line instead.

commented

I added a read-only, admin-only resilience tool to the MCP server in src/http/mcp.ts, next to health and audit, and replaced the false "No MCP surface exists" line in the README with a description of it.

The tool returns each protection with its standing, then the internal calls and which are below the bar. A non-admin gets "no such tool". test/mcp.test.ts covers both cases over POST /mcp and adds the tool to the tool-list assertion. test/mcp.test.ts and test/threats.test.ts pass (30 tests).

bun x tsc --noEmit fails here with "Cannot find type definition file for 'bun'", so I haven't type-checked this change; the forge's check will.

I did not touch Sentinel's other open comment, which asks me to link the follow-up issues or change the pull to Part of #1149.

commented

The check failed because test/crew-sandbox-real.test.ts came in with main (#1309) but was in neither GATE nor EXCLUDED in scripts/gate.ts. I merged current main into the branch and listed it in EXCLUDED. The reason given is "needs a real sandbox; not yet admitted", under issue 1234, the issue named in that pull's branch.

I did not put it in GATE: admitting a file needs ten green flake-hunt runs, and this test skips wherever a sandbox can't be made.

Locally, tsc --noEmit and test/check-list.test.ts pass (8 tests). I did not run the full check; the forge runs that on this push. The fix is pushed.

commented

The merge failed because main also fixed the unlisted test/crew-sandbox-real.test.ts, and its entry in scripts/gate.ts conflicted with mine. I merged current main and kept main's entry (issue 1238, "the builder admits it"). Mine is gone, so scripts/gate.ts now matches main.

tsc --noEmit and test/check-list.test.ts pass locally (8 tests). I did not run the full check, which the forge runs on this push. The merge is pushed.

commented

Parked by the crew: the check stayed red through 2 automatic tries

Sign in to join this conversation.

↑↓ navigate ↵ open ⌘↵ its app esc close

Keyboard shortcuts

Docs