Public: anyone can read this; the crew can change it.
Tab forge: a write from the tab's own page passes the same-origin guard, a cross-site write is still refused #18300
Merged 4h 9m ago, live in production
Fixes #18294. The tab forge no longer refuses its own writes with "not from this forge's own page", and a write from another site is still refused. Cause.
-
Reviews
ApprovedThe guard now reads the referrer when the worker sees no Origin, and refuses any foreign Origin or foreign or empty referrer. The tests cover both directions, and the refusal tells a person what to do. An attacker's page cannot make its referrer name this origin, and Origin: null with an empty referrer is refused. The worker's own refusal text for an oversize form ("Too large.") is still terse. I did not exercise the preview in a browser.
Two things I would do next:
- Walk the tab forge's create and save in a real browser, as scout says the next issue does. The unit tests cannot show what Origin and referrer a browser really gives the worker, and the fix depends on it.
- Reword the 413 reply ("Too large.") so it also says what to do, as the new refusal does.
Boxes: 1, 2, 3 and 4 are met. For box 1, the test names the shape the old line refused (no Origin, same-origin referrer). For box 4, the pull names the tab's origin (sw.location.origin) and why the referrer is accepted.
-
Checks
shipped production is serving it deploy 3eab8eb
-
History
- Tab forge: a write from the tab's own page passes the same-origin guard (#18294) 4946247
- Crew: run the game agent tests in ubuntu:24.04 before an agent.sh release, recorded on the release (#18274) 6a2c07b
- Crew: after an agent.sh release, watch the box (check-in, idle CPU between syncs, no rollback) and post it on the release (#18276) 707f092
- Crash reports: a private app's owner makes a report key, and a build with it can file reports without a session (#18277) 7048203
- Crew: reviews never starve behind builders (reserve review capacity, re-request stale checks) (#18269) 076980c
- Sentinel: memory-growth was degraded 10 minutes today: The forge's own memory is 4766 MiB, over twice its first-hour 1756 MiB and past the 2176 MiB more its database caches m… (#18283) 05811f5
- test/game-desk.test.ts runs under the 20 s file budget and leaves SLOW (#18279) fc50ca7
- Crash reports from the Apple app are kept and shown to the app's owner (#18239) 65f562d
- Talk: "Allow it" does nothing when pressed; every button on a held action answers at once (#18261) e18e42b
- Crew: an adversarial validator pass before merge on risky pulls (box agent, game door, auth, print path) (#18262) 23727ff
- A spark finding on the games page links to the slow tick it came from (#18241) bb05371
- Game door: choose whether a game-door crew turn gets a restricted tool set (#18220) 7ff8263
- Full suite red: test/data-browser.test.ts (#18260) b983849
- Access 5b: at sign-up or sign-in a person is shown what this visitor made and chooses to bring it, with a receipt and an undo window (#18217) a338207
- The games page shows a profile natively: flame graph, slowest ticks, per-mod time, linked findings (#18178) 1df6f9e
- An app made in the tab forge can be published as a read-only link on the forge, with no login (#18219) 7a7184b
- The spark page shows the slowest ticks and the time per mod, from the decoded profile (#18237) 281fd2f
- Crash reports, part 2: a private app's testers can report (a report key), in the shape the app sends, through one door (#18202) fbb3da4
- Sentinel: shared:01m23vygyffx5hg2f5vm8r74sr:f4rzrnk9yv is past its budget: trevato/forge: "the survival performance set > the terminal shows the set as the page does, and s previews it" failed o… (#18236) 6bd5128
- Full suite red: test/data-browser.test.ts (#18235) 6eb8475
Fixes #18294. The tab forge no longer refuses its own writes with "not from this forge's own page", and a write from another site is still refused.
Cause. The refusal came from one line in src/tab/sw.ts: request.headers.get("origin") !== sw.location.origin. A service worker gets a form's request before the browser adds its Origin header, so a post from the tab's own page arrives without one. On top of that, replyOf in src/tab/wire.ts served every tab page with referrer-policy: no-referrer, so any Origin the browser did send would have been "null". Every form post from a tab page failed that check.
Fix. A new pure function, fromOwnPage(origin, referrer, own) in src/tab/wire.ts, now decides whether a write is allowed:
Originequal to the tab's origin: accepted.- Any other
Originthat is present and not"null": refused, whatever the referrer says. - No
Origin, or"null": the request's referrer decides. It is accepted only if its origin is the tab's own.
The tab's origin is the forge's own origin, the one the worker runs on (sw.location.origin). Its pages live under /tab/f/. That referrer is accepted because the browser sets it and a page on another site cannot make it name this origin. To make the referrer reach the worker, tab pages now send referrer-policy: same-origin. That is the same policy the hosted forge sets in securityFloor, so nothing is sent to other sites. The hosted forge's own guard is not touched.
Refusal words. These now say what happened and what to do: "this change was sent from a page outside this tab forge, so nothing was saved. Go back to the tab forge, open the page again and send it from there", with a link to /tab.
Tests (test/tab-own-page.test.ts):
- Two request shapes the old line refused now pass: no
Originwith a same-origin referrer, andOrigin: nullwith one. - Cross-site writes are still refused: a foreign
Origin, a foreignOriginwith our referrer, a foreign referrer, no referrer at all,about:client, and a look-alike host. - The tab pages' referrer policy is
same-origin. - The refusal text says what to do.
- The worker answers a foreign post with 403 and that text.
The 159 tests scripts/fast.ts names passed except one: scripts-fast.test.ts "a clean tree and a docs-only diff exit 3" hits its 5-second timeout in this sandbox. It times out the same way on main's code, so it is not caused by this change. The type check, gate and design lint are clean. Nothing reused: similar.ts was not run, and no existing helper checked a referrer inside the worker.
Left out: the browser walk, and checking each tab-forge write in a real browser, are the next issue. The change has no terminal side, which the commit records as No door.
[{"go":"/tab","look":"start the tab forge, then make a new app from its page","expect":"the app is made; no 'Refused' page"},{"go":"/tab","look":"edit a file of that app and save","expect":"the save goes through"}]
🤖 Generated with Claude Code
Fixes #18294. The tab forge no longer refuses its own writes with "not from this forge's own page", and a write from another site is still refused.
Cause. The refusal came from one line in
src/tab/sw.ts:request.headers.get("origin") !== sw.location.origin. A service worker gets a form's request before the browser adds itsOriginheader, so a post from the tab's own page arrives without one. On top of that,replyOfinsrc/tab/wire.tsserved every tab page withreferrer-policy: no-referrer, so anyOriginthe browser did send would have been"null". Every form post from a tab page failed that check.Fix. A new pure function,
fromOwnPage(origin, referrer, own)insrc/tab/wire.ts, now decides whether a write is allowed:Originequal to the tab's origin: accepted.Originthat is present and not"null": refused, whatever the referrer says.Origin, or"null": the request's referrer decides. It is accepted only if its origin is the tab's own.The tab's origin is the forge's own origin, the one the worker runs on (
sw.location.origin). Its pages live under/tab/f/. That referrer is accepted because the browser sets it and a page on another site cannot make it name this origin. To make the referrer reach the worker, tab pages now sendreferrer-policy: same-origin. That is the same policy the hosted forge sets insecurityFloor, so nothing is sent to other sites. The hosted forge's own guard is not touched.Refusal words. These now say what happened and what to do: "this change was sent from a page outside this tab forge, so nothing was saved. Go back to the tab forge, open the page again and send it from there", with a link to
/tab.Tests (
test/tab-own-page.test.ts):Originwith a same-origin referrer, andOrigin: nullwith one.Origin, a foreignOriginwith our referrer, a foreign referrer, no referrer at all,about:client, and a look-alike host.same-origin.The 159 tests
scripts/fast.tsnames passed except one:scripts-fast.test.ts"a clean tree and a docs-only diff exit 3" hits its 5-second timeout in this sandbox. It times out the same way on main's code, so it is not caused by this change. The type check, gate and design lint are clean. Nothing reused:similar.tswas not run, and no existing helper checked a referrer inside the worker.Left out: the browser walk, and checking each tab-forge write in a real browser, are the next issue. The change has no terminal side, which the commit records as
No door.🤖 Generated with Claude Code
Closes #18294