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

Access 3, MCP: the scope floor is read from the disagreement count, then deleted #18418

opened this

Merged 1h 44m ago, live in production

The MCP door now asks may() and nothing else. mayToolWrite(ctx) is holds(principalOf(ctx.auth), "forge.write"), and adminAccount was already holds(principalOfUser(user), "forge.administer"). The old scopeAllows(ctx.auth.scope ??

Notes

opened this

The MCP door now asks may() and nothing else. mayToolWrite(ctx) is holds(principalOf(ctx.auth), "forge.write"), and adminAccount was already holds(principalOfUser(user), "forge.administer"). The old scopeAllows(ctx.auth.scope ?? "ro", "rw") read in src/http/mcp/tool_may.ts is deleted, along with the side-by-side comparison, the door argument (5 call sites in src/http/mcp.ts) and the allowlist entry for that line in src/design/door_checks.ts's DOOR_LINES. src/http/mcp.ts had no isAdmin read left. Its one remaining scopeAllows(…, "admin") controls how far a token reaches, which is a scope and not a role, and it stays.

Disagreement count. The suite has 1 access_disagreement row whose door starts mcp : mcp feed_dismiss, forge.write, session, may=1. It came from test/mcp-tools-may.test.ts, which builds a ctx by hand with a user and no scope. No HTTP request can produce that: resolveAuth gives every signed-in caller a scope (admin for a session, the platform edge or a password; a token's own scope otherwise). When the account is asking for itself, may letting it write is the intended answer. Every caller made from a real credential gives 0 rows: sessions as guest, member and admin; ro, rw and admin tokens; via, proposal, run and contribute tokens. Production was not read: the table has no route, and this sandbox cannot reach the forge's database.

Threat note. For every caller that reaches /mcp, may's answer equals the old floor's, so an ro token can do nothing new. test/mcp-scope-floor-gone.test.ts (new) checks this over HTTP:

  • An ro token calling feed_dismiss gets READ_ONLY_REFUSAL; an rw token reaches the tool.
  • An admin's ro and admin tokens are both listed decider_shadow and can run it.
  • An agent without the admin role, and a member, are told no tool named decider_shadow, and it is not in their list.

Making mayToolWrite always say yes fails the first test, and making adminAccount always say yes fails the agent test. Dropping the admin check in the other direction fails the admin test.

Test changed: in test/mcp-tools-may.test.ts, "a write answered apart from the old scope floor is counted" tested the side-by-side counting this issue removes. It now says that a signed-in account with no scope writes as the account and nothing is counted.

Not done: the per-tool isAdmin and rw checks under src/http/mcp/tools/ (bet, notify, features, infra, …) are left alone. They are outside this issue's files and stay listed in DOOR_LINES. The API routes and pages are not touched.

Checks: the gate has 0 failing rules. The fast.ts list was too broad to run (4074 files), so I picked the tests myself. These pass: bun x tsc --noEmit, mcp-size, mcp-tools-may, mcp-scope-floor-gone, door-inline-checks, mcp-ro-refuses-writes, mcp-write-scope, mcp-refusal-hints, may, who-may, token-admin-scope, the web/repo/infra may tests, dup-imports and unused-exports.

Try: on the preview, POST tools/call feed_dismiss to /mcp with an ro token and read the read-only refusal; with an rw token the call reaches the tool.

🤖 Generated with Claude Code

Closes #18405

commented

The MCP door now asks may() and nothing else. mayToolWrite(ctx) is holds(principalOf(ctx.auth), "forge.write"), and adminAccount was already holds(principalOfUser(user), "forge.administer"). The old scopeAllows(ctx.auth.scope ?? "ro", "rw") read in src/http/mcp/tool_may.ts is deleted, along with the side-by-side comparison, the door argument (5 call sites in src/http/mcp.ts) and the allowlist entry for that line in src/design/door_checks.ts's DOOR_LINES. src/http/mcp.ts had no isAdmin read left. Its one remaining scopeAllows(…, "admin") controls how far a token reaches, which is a scope and not a role, and it stays.

Disagreement count. The suite has 1 access_disagreement row whose door starts mcp : mcp feed_dismiss, forge.write, session, may=1. It came from test/mcp-tools-may.test.ts, which builds a ctx by hand with a user and no scope. No HTTP request can produce that: resolveAuth gives every signed-in caller a scope (admin for a session, the platform edge or a password; a token's own scope otherwise). When the account is asking for itself, may letting it write is the intended answer. Every caller made from a real credential gives 0 rows: sessions as guest, member and admin; ro, rw and admin tokens; via, proposal, run and contribute tokens. Production was not read: the table has no route, and this sandbox cannot reach the forge's database.

Threat note. For every caller that reaches /mcp, may's answer equals the old floor's, so an ro token can do nothing new. test/mcp-scope-floor-gone.test.ts (new) checks this over HTTP:

  • An ro token calling feed_dismiss gets READ_ONLY_REFUSAL; an rw token reaches the tool.
  • An admin's ro and admin tokens are both listed decider_shadow and can run it.
  • An agent without the admin role, and a member, are told no tool named decider_shadow, and it is not in their list.

Making mayToolWrite always say yes fails the first test, and making adminAccount always say yes fails the agent test. Dropping the admin check in the other direction fails the admin test.

Test changed: in test/mcp-tools-may.test.ts, "a write answered apart from the old scope floor is counted" tested the side-by-side counting this issue removes. It now says that a signed-in account with no scope writes as the account and nothing is counted.

Not done: the per-tool isAdmin and rw checks under src/http/mcp/tools/ (bet, notify, features, infra, …) are left alone. They are outside this issue's files and stay listed in DOOR_LINES. The API routes and pages are not touched.

Checks: the gate has 0 failing rules. The fast.ts list was too broad to run (4074 files), so I picked the tests myself. These pass: bun x tsc --noEmit, mcp-size, mcp-tools-may, mcp-scope-floor-gone, door-inline-checks, mcp-ro-refuses-writes, mcp-write-scope, mcp-refusal-hints, may, who-may, token-admin-scope, the web/repo/infra may tests, dup-imports and unused-exports.

Try: on the preview, POST tools/call feed_dismiss to /mcp with an ro token and read the read-only refusal; with an rw token the call reaches the tool.

🤖 Generated with Claude Code

commented

Left #18405 open: 1 unticked item remain (if any disagreement stays undecided, the pull changes nothing and says which door and why).

Sign in to join this conversation.

Search
↑↓ navigate ↵ open ⌘↵ its app esc close

Keyboard shortcuts

Docs