Public: anyone can read this; the crew can change it.
Every route that changes state refuses a cross-origin request, proven by one table-driven test over the route table #13500
Check · Review · Land · Live done — Landed and live in production.
A forged browser POST, PUT, PATCH or DELETE that arrives with no Origin header is now refused when the browser's own Sec-Fetch-Site says another site sent it. Before this change, a signed-in cookie request with no Origin passed every mutating route. Most of #13480 was already on main from #10931.
shipped production is serving it deploy 59903fa
A forged browser POST, PUT, PATCH or DELETE that arrives with no Origin header is now refused when the browser's own Sec-Fetch-Site says another site sent it. Before this change, a signed-in cookie request with no Origin passed every mutating route.
Most of #13480 was already on main from #10931. test/origin-every-mutation.test.ts already walks every mutating route in both routers with a foreign Origin. It requires a 403 and no new events, and checks the refusal came from the origin check. Its EXEMPT list (the bearer-only /mcp and /oauth/userinfo) and UNCALLABLE list are checked against the routers. A new mutating route that isn't listed is walked automatically and fails if it has no check. The missing part was "with none from a browser context".
crossOrigin(src/http/context.ts): a request with noOriginandSec-Fetch-Siteofcross-siteorsame-siteis now treated as cross-origin, and the log line recordsorigin: "-". A page can't set that header.same-siteis included because apps are served on sibling subdomains of the forge. NoOriginwithsame-origin,noneor noSec-Fetch-Siteat all (curl, tools) still passes. A cookie can't be used from a non-browser client unless someone already has it.test/origin-every-mutation.test.ts: the route walk now runs over two forged shapes: a foreignOrigin, and noOriginwithSec-Fetch-Site: cross-site. With the fix reverted, the second shape fails on real routes (for examplePOST /api/v1/user/passwordanswers 401 with no origin check).test/consent-origin.test.ts: unit cases for the fourSec-Fetch-Sitevalues with noOrigin.
Not done: a Referer fallback for browsers that send neither Origin nor Sec-Fetch-Site. Every current browser sends Origin on cross-site mutations, so it adds rules without closing a real gap. src/http/respond.ts didn't need changes because the gate already calls crossOrigin.
Tests: scripts/fast.ts named 2216 files as too broad, so I picked the 238 test files that mention crossOrigin, sec-fetch-site or evil.example. All pass. bun x tsc --noEmit is clean, and scripts/gate.ts --fix rewrapped comments in three files, which are included. The extra empty commit is the "Try:" line the pre-push hook asks for.
To try it: signed in, POST /api/v1/user/email/verify with header sec-fetch-site: cross-site and no Origin answers 403 forbidden. With sec-fetch-site: same-origin it is not refused.
🤖 Generated with Claude Code
Clean, small, security-positive. crossOrigin now also refuses a missing Origin when the browser's own Sec-Fetch-Site says cross-site or same-site; same-origin, none and absent (curl, tools) still pass. The route-table walk runs over both forged shapes and checks the refusal came from the origin check, and unit cases cover the four header values. No dependency, no README change, no new surface needing a TUI screen. Remaining Referer fallback is reasonably declined.
A forged browser POST, PUT, PATCH or DELETE that arrives with no
Originheader is now refused when the browser's ownSec-Fetch-Sitesays another site sent it. Before this change, a signed-in cookie request with noOriginpassed every mutating route.Most of #13480 was already on main from #10931.
test/origin-every-mutation.test.tsalready walks every mutating route in both routers with a foreignOrigin. It requires a 403 and no new events, and checks the refusal came from the origin check. ItsEXEMPTlist (the bearer-only/mcpand/oauth/userinfo) andUNCALLABLElist are checked against the routers. A new mutating route that isn't listed is walked automatically and fails if it has no check. The missing part was "with none from a browser context".crossOrigin(src/http/context.ts): a request with noOriginandSec-Fetch-Siteofcross-siteorsame-siteis now treated as cross-origin, and the log line recordsorigin: "-". A page can't set that header.same-siteis included because apps are served on sibling subdomains of the forge. NoOriginwithsame-origin,noneor noSec-Fetch-Siteat all (curl, tools) still passes. A cookie can't be used from a non-browser client unless someone already has it.test/origin-every-mutation.test.ts: the route walk now runs over two forged shapes: a foreignOrigin, and noOriginwithSec-Fetch-Site: cross-site. With the fix reverted, the second shape fails on real routes (for examplePOST /api/v1/user/passwordanswers 401 with no origin check).test/consent-origin.test.ts: unit cases for the fourSec-Fetch-Sitevalues with noOrigin.Not done: a
Refererfallback for browsers that send neitherOriginnorSec-Fetch-Site. Every current browser sendsOriginon cross-site mutations, so it adds rules without closing a real gap.src/http/respond.tsdidn't need changes because the gate already callscrossOrigin.Tests:
scripts/fast.tsnamed 2216 files as too broad, so I picked the 238 test files that mentioncrossOrigin,sec-fetch-siteorevil.example. All pass.bun x tsc --noEmitis clean, andscripts/gate.ts --fixrewrapped comments in three files, which are included. The extra empty commit is the "Try:" line the pre-push hook asks for.To try it: signed in,
POST /api/v1/user/email/verifywith headersec-fetch-site: cross-siteand noOriginanswers 403forbidden. Withsec-fetch-site: same-originit is not refused.🤖 Generated with Claude Code
Closes #13480