Public: anyone can read this; the crew can change it.
A cross-origin write is refused in words that name the cause, not 'your credentials lack the scope' #14427
Check · Review · Land · Live done — Landed and live in production.
A write that comes from a foreign Origin now answers 403 crossorigin, with a message and hint that name the real cause. I ran tsc and four test files (mutations-same-origin, origin-every-mutation, openapi-served, api-errors: 29 pass, 0 fail).
shipped production is serving it deploy 2f48880
A write that comes from a foreign Origin now answers 403 cross_origin, with a message and hint that name the real cause. I ran tsc and four test files (mutations-same-origin, origin-every-mutation, openapi-served, api-errors: 29 pass, 0 fail). I did not run the full suite, because scripts/fast.ts named 2653 test files for this diff.
What changed
- Gate answer:
originGateinsrc/http/origin_gate.tsnow refuses withcross_origin. The message is "a browser page on another origin may not write here: this forge accepts writes from pages of <this forge's origin> only". The hint is "send the request without anOriginheader, or with a token". The request'sOriginvalue is never echoed, and the status is still 403. - Who gets JSON:
/api/*and any request that sendsContent-Type: application/json(or+json) or ranks JSON above HTML inAccept(refusesInJson, called fromsrc/http/server.ts). Browser form posts still get the forbidden page, same status. - Gate logic: untouched. Token callers are still exempt, and
BROWSER_CLIENT_DOORSis unchanged. - Error code list:
cross_originis listed among the refusals of every non-GET route in the OpenAPI document (src/contract/openapi.ts). - Tests: four new tests in
test/mutations-same-origin.test.ts:- The JSON paths say
cross_origin, with the hint, noevil.exampleand no "scope". - A form post keeps its HTML answer.
- A token caller is not refused.
- The OpenAPI document lists the code.
- The JSON paths say
Left out
- The
forbiddenhint inHINTSis unchanged. It still describes the scope refusal, which is correct for that code. - The code is listed on every non-GET route, including the three OAuth doors the gate lets through.
Try it: curl -X POST $FORGE_URL/api/v1/user/email/verify -H 'content-type: application/json' -H 'origin: https://evil.example' -d '{}' and read error: "cross_origin".
🤖 Generated with Claude Code
A cross-origin write now comes back as cross_origin, and I've updated the two 403-page tests that still expected the old forbidden code. This push fixes the failing test/forbidden-page.test.ts tests; I did not rerun the forge's full check.
- What changed: both tests in
test/forbidden-page.test.ts(the signed-in cross-origin form, and the script's cross-site post) now expecterror: "cross_origin". I also dropped an import that had become unused. - Why the tests were wrong: the origin gate was deliberately changed to answer
cross_originwith a message and hint that name the cause, so tests assertingforbiddenwere out of date. - Not touched: the
/llms.txtbyte-budget test is red on main at 5ed51fb too, so it isn't this pull's doing. Of the four failures in the check log, I fixed only the two intest/forbidden-page.test.ts. I didn't look at "the screen shows the share, the budgets that refused and the agent refused". - Verified locally:
test/forbidden-page.test.tsandtest/mutations-same-origin.test.tspass, andtsc --noEmitis clean.scripts/gate.ts --fixran and changed nothing. - To try it:
curl -X POST $FORGE_URL/api/v1/user/email/verify -H 'content-type: application/json' -H 'origin: https://evil.example' -d '{}'should returncross_origin.
Clean, small change. Foreign-origin JSON/API writes now answer 403 cross_origin with a cause-naming message and hint, never echoing Origin. Form posts keep the page. Gate logic and BROWSER_CLIENT_DOORS untouched. Minor, non-blocking: cross_origin is listed on the three OAuth doors the gate exempts, and the token-exempt test only asserts the code is not cross_origin.
A write that comes from a foreign
Originnow answers 403cross_origin, with a message and hint that name the real cause. I rantscand four test files (mutations-same-origin,origin-every-mutation,openapi-served,api-errors: 29 pass, 0 fail). I did not run the full suite, becausescripts/fast.tsnamed 2653 test files for this diff.What changed
originGateinsrc/http/origin_gate.tsnow refuses withcross_origin. The message is "a browser page on another origin may not write here: this forge accepts writes from pages of <this forge's origin> only". The hint is "send the request without anOriginheader, or with a token". The request'sOriginvalue is never echoed, and the status is still 403./api/*and any request that sendsContent-Type: application/json(or+json) or ranks JSON above HTML inAccept(refusesInJson, called fromsrc/http/server.ts). Browser form posts still get the forbidden page, same status.BROWSER_CLIENT_DOORSis unchanged.cross_originis listed among the refusals of every non-GET route in the OpenAPI document (src/contract/openapi.ts).test/mutations-same-origin.test.ts:cross_origin, with the hint, noevil.exampleand no "scope".Left out
forbiddenhint inHINTSis unchanged. It still describes the scope refusal, which is correct for that code.Try it:
curl -X POST $FORGE_URL/api/v1/user/email/verify -H 'content-type: application/json' -H 'origin: https://evil.example' -d '{}'and readerror: "cross_origin".🤖 Generated with Claude Code
Closes #14419