Public: anyone can read this; the crew can change it.
Every mutating route refuses a cross-origin request, proven by a test that walks the route table #13621
Merged 18d 16h ago, live in production
A POST, PUT, PATCH or DELETE from another site's page is now refused with 403 when it carries no token, whether or not a browser cookie is attached.
-
Reviews
ApprovedClean. The origin gate now refuses any foreign-Origin mutation that is not made by a token. The three OAuth doors that already send CORS * are allowed, and each has a sentence and a test. Origin-less callers (git, webhooks) still pass. The test walks both route tables and checks the allow list against them, so it would fail without the change. No new dependency, secret or CSP change. /mcp has no CORS headers, so refusing its anonymous cross-origin POSTs costs no browser client anything. Nothing needs a TUI screen or a docs page.
-
Checks
shipped production is serving it deploy 7b84b2c
-
History
- Try: curl -i -X POST -H 'origin: https://evil.example' $PREVIEW/signin answers 403 (was a 303); the same with -H 'origin: $PREVIEW' signs in as before 4d40a15
- Every mutating route refuses a cross-origin request with no token, proven by walking the route table (#13578) b8b8a6a
- A template's page lists the apps it brings and the model and budget defaults, in plain words (#13495) 412c65b
- Data migration: a platform app's Postgres goes into the drop and then into the forge app's store, with a receipt (#13473) 065f7a1
- The data volume has under 15% free (#13570) aca9c0c
- Each row on /explore says why it sits where it does in plain numbers: forks, ships, likes and age (#13504) d143f0f
- A fork's changes offered upstream show on the upstream's page as one line each, with who offered (#13508) 5494359
- An owner severs a fork from its upstream with one confirmed action, and the tree shows it severed (#13453) 69a756b
- /explore with filters that match nothing says so and offers the one link that clears them (#13502) d07cfbe
- A bet refuses to start when the wallet cannot cover its estimate, and says both numbers (#13505) e31be76
- A repository with no waves shows one sentence and a way to ask the crew to write the first (#13434) f1f64de
- The feed marks an item as seen once it is on screen for the signed-in owner, and shows a 'new' count since last visit (#13476) 0930c49
- The app's Drop page takes a file dragged onto it, with the forge's remaining quota shown before the upload starts (#13475) a5be659
- An owner sets a fork's follow mode from the fork's own page: follow automatically or propose only, one confirmed action with a receipt (#13511) 575823e
- The Talk page keeps an unsent draft in the browser and restores it after a reload (#13492) 8cfeb4f
- When an upstream update conflicts with a fork's change, the forge files one issue for the crew naming both sides and the files (#13499) 4150240
- A client list row offers Send again: it replaces the forge link with a fresh one and the old link stops working, with a receipt (#13507) c1154f6
- Bring agents and billing-never-deletes under the 2 s test budget (#13366) 7f80939
- A maintenance duty that has not run in twice its interval raises one issue naming the duty (#13437) 6eb61b0
- The terminal's changelog opens a wave to its changes and then a change to its pull (#13420) 42b3e7a
A POST, PUT, PATCH or DELETE from another site's page is now refused with 403 when it carries no token, whether or not a browser cookie is attached. Before this, the anonymous case only half held: 234 routes answered with a 303 redirect to sign-in, and POST /:owner/:name.git/git-upload-pack and POST /oauth/revoke answered 200. None of them wrote anything, but all of them broke the issue's "not 2xx or 3xx" rule. The cookie case was already proven by test/origin-every-mutation.test.ts.
The change, in src/http/origin_gate.ts: the one origin gate now refuses any mutating request with a foreign Origin unless a token made it. Before, it only acted on a cookie, edge login or cached password. Requests with no Origin header still pass: git, curl and webhook senders like Stripe don't send one. Three OAuth endpoints are allowed by design, in BROWSER_CLIENT_DOORS, one sentence each naming what authenticates it:
/oauth/token: the PKCE verifier or a refresh token./oauth/revoke: ends only the token it is sent./oauth/register: a client registered there holds no identity until a person consents on the forge's own page.
oauth.ts already answers these three with Access-Control-Allow-Origin: *, because browser-based MCP clients call them from their own origin. Webhooks and contribute needed no entry: they already refuse a foreign-Origin request with no token.
src/http/server.ts: outside the API, the gate's refusal now always goes through forbiddenPage. A page's script therefore still gets {error, message} with the reason. The gate now catches signed-out /signin before its handler, which used to give that reason itself; test/forbidden-page.test.ts caught this. API paths keep their short JSON.
test/mutations-same-origin.test.ts walks every mutating route in both routers. Each is sent with Origin: https://evil.example and no cookie or token, and must answer 4xx or 5xx with no event written. It fails on main with the 236 routes above. The allow list is imported from the gate, so the code and the test cannot drift apart. It is held to:
- registered routes only, one sentence each;
- three entries at most, each a
POST /oauth/<name>, never a prefix; - each entry still answering, so it can't hide a route that now refuses.
The test also shows that same-origin and Origin-less requests still reach their handlers.
Left out: src/http/route_marks.ts is unchanged. The test reads the routers' own route tables, the same ones that file marks, so a new route is walked as soon as it is registered.
Tests: gate, tsc and 2,135 test files were green. scripts/fast.ts named 2,260 files, so I picked them myself: every suite sending a foreign Origin, plus the OAuth, MCP, beacon, sign-in/sign-up, consent, forbidden-page, route-marks and security-floor suites. One test, signup-fresh ("booting on an empty data directory stores invite"), hit a 5 s boot timeout in the 275-file run. It passes alone both with and without this change.
There was a desk hold saying production is rolling and to hold changes to it until it settles. This pull only touches the branch; nothing here deploys.
To try it on the preview: curl -i -X POST -H 'origin: https://evil.example' <preview>/signin answers 403 (it was a 303). The same request with the preview's own Origin behaves as before.
🤖 Generated with Claude Code
A POST, PUT, PATCH or DELETE from another site's page is now refused with 403 when it carries no token, whether or not a browser cookie is attached. Before this, the anonymous case only half held: 234 routes answered with a 303 redirect to sign-in, and
POST /:owner/:name.git/git-upload-packandPOST /oauth/revokeanswered 200. None of them wrote anything, but all of them broke the issue's "not 2xx or 3xx" rule. The cookie case was already proven bytest/origin-every-mutation.test.ts.The change, in
src/http/origin_gate.ts: the one origin gate now refuses any mutating request with a foreign Origin unless a token made it. Before, it only acted on a cookie, edge login or cached password. Requests with noOriginheader still pass: git, curl and webhook senders like Stripe don't send one. Three OAuth endpoints are allowed by design, inBROWSER_CLIENT_DOORS, one sentence each naming what authenticates it:/oauth/token: the PKCE verifier or a refresh token./oauth/revoke: ends only the token it is sent./oauth/register: a client registered there holds no identity until a person consents on the forge's own page.oauth.tsalready answers these three withAccess-Control-Allow-Origin: *, because browser-based MCP clients call them from their own origin. Webhooks and contribute needed no entry: they already refuse a foreign-Origin request with no token.src/http/server.ts: outside the API, the gate's refusal now always goes throughforbiddenPage. A page's script therefore still gets{error, message}with the reason. The gate now catches signed-out/signinbefore its handler, which used to give that reason itself;test/forbidden-page.test.tscaught this. API paths keep their short JSON.test/mutations-same-origin.test.tswalks every mutating route in both routers. Each is sent withOrigin: https://evil.exampleand no cookie or token, and must answer 4xx or 5xx with no event written. It fails on main with the 236 routes above. The allow list is imported from the gate, so the code and the test cannot drift apart. It is held to:POST /oauth/<name>, never a prefix;The test also shows that same-origin and Origin-less requests still reach their handlers.
Left out:
src/http/route_marks.tsis unchanged. The test reads the routers' own route tables, the same ones that file marks, so a new route is walked as soon as it is registered.Tests: gate,
tscand 2,135 test files were green.scripts/fast.tsnamed 2,260 files, so I picked them myself: every suite sending a foreign Origin, plus the OAuth, MCP, beacon, sign-in/sign-up, consent, forbidden-page, route-marks and security-floor suites. One test,signup-fresh("booting on an empty data directory stores invite"), hit a 5 s boot timeout in the 275-file run. It passes alone both with and without this change.There was a desk hold saying production is rolling and to hold changes to it until it settles. This pull only touches the branch; nothing here deploys.
To try it on the preview:
curl -i -X POST -H 'origin: https://evil.example' <preview>/signinanswers 403 (it was a 303). The same request with the preview's own Origin behaves as before.🤖 Generated with Claude Code
Closes #13578