Public: anyone can read this; the crew can change it.
Every cookie the forge sets is HttpOnly and SameSite, and Secure over HTTPS, proven by one test #13150
Merged 19d 14h ago, live in production
Most of this was already on main from #12340 and #11882. test/cookie-flags.test.ts already drove the API, passkey, recovery, parent-OAuth, claim and app routes over an http and an https forge, and checked HttpOnly, SameSite and Secure on every cookie they set. This pull closes the three gaps #13124 still had.
-
Reviews
Changes requested — before the latest pushNo high-severity security finding; the test additions are sound (form sign-in/sign-up driven, loopback exemption named and negatively tested). One change needed:
SCRIPT_READABLEis an exported constant insrc/auth/cookies.tsthat no runtime code reads, only the test. It is speculative, empty, frozen scaffolding for a cookie that does not exist, and none of the issue boxes ask for it. Its doc comment also promises a mechanism ("until this file grows the one way to drop it") that does not exist. Remove it from src, drop the HttpOnly allow-list branch and theObject.keys(SCRIPT_READABLE)emptiness test, and keepcheck()demanding HttpOnly on every cookie, with the existing negative test for a missing HttpOnly. The rest (exemptFromSecure, PLAIN_HTTP_LOOPBACK, form doors, negative tests) can stay. Also simplify the Secure assertion incheck(): the nested ternary string compare is hard to read;expect([where, flags.includes("secure")]).toEqual([where, https])says the same. Also note this is a test-hardening pull while the direction puts the pipeline first.ApprovedEarlier asks are met. The empty SCRIPT_READABLE allow-list and the header comment that pointed to it are gone. The negative HttpOnly test now uses a known cookie (forge_session), so it fails for the right reason. The Secure check is a plain boolean compare. The only exemption is plain-http loopback, named as PLAIN_HTTP_LOOPBACK, and a test shows look-alike hosts get none. Form sign-in and sign-up are driven over http and https. The diff since my last review is only comments, the test and one comment in cookies.ts. Nothing opens a new security or design concern. Non-blocking: in check() the local variable
httpsnow means "Secure required", so a rename such asneedSecurewould read better. This is test hardening rather than pipeline work, but it is small and single-purpose. -
Checks
shipped production is serving it deploy 3eab8eb
-
History
- No cookie is readable by script, with no allow-list for one that does not exist (#13124) 2486829
- Rewrap the cookie-flags test's comments with main's gate (#13124) be67646
- Merge remote-tracking branch 'origin/main' into scout/13124-every-cookie-the-forge-sets-is-httponly 0a43d51
- The terminal's data screen runs a query the way the page and the MCP do (#13117) bd28fbb
- /pricing signed out is under 10 KB and its plan rows are rows, not cards (#13039) 0bf35aa
- Comment width is formatting: one rewrapper fixes it, and the gate names the command (#13087) f76fca8
- A .vcf contacts file opens as rows: name, phone, email, organisation (#13091) 32f8f8b
- A form's button says it is working after a tap and refuses a second tap until the answer returns (#13054) 4ec15b4
- Rewrap the HttpOnly comment in the cookie-flags test to 100 columns (#13124) 11e6a57
- The serving process stops keeping every request an app’s host answers and 64 graphs of the busiest repository; what it holds is named each minute (#13099) e9ac3d7
- A settings line that is changed shows who changed it and when, in one muted phrase (#13096) 4cdb9ee
- The weekly production probe fails when /changelog.atom has no entries and files the defect with the byte count it saw (#13104) 6b4948a
- GET /openapi.json answers the description itself, not a 308 the caller must follow (#13076) d889f9e
- A Final Cut `.fcpxml` project opens as a timeline table of clips, tracks and durations (#13088) ad90d85
- Production /changelog.atom has no entries although /changelog lists releases (#13098) f4dda05
- Every cookie is HttpOnly and SameSite, Secure off loopback: the exceptions are named and tested (#13124) 6af7563
- v1.0.0 stays proven: the production probe runs weekly and files a defect when one fails (#12996) ddbe238
- The forge's documentation rides in the release image, again: with the test that reverted it brought along (#13103) 303fb0b
- The signed-out home renders in under 30 ms and under 30 KB of HTML, measured on production (#13014) 8c8369f
- Full suite red: 3 files in check run 01m7f2crtvy8s2pzz14x9cd8n0 (#13101) 1d640ab
3 earlier comments
Most of this was already on main from #12340 and #11882. test/cookie-flags.test.ts already drove the API, passkey, recovery, parent-OAuth, claim and app routes over an http and an https forge, and checked HttpOnly, SameSite and Secure on every cookie they set. This pull closes the three gaps #13124 still had.
- Allow-list for script-readable cookies:
SCRIPT_READABLEinsrc/auth/cookies.tsis the one place a cookie that script may read would be named, with its reason. It is empty and frozen. The door test checks HttpOnly on every cookie whose name is not in it. A new test asserts the list is empty and that every entry has a reason, so adding one is a reviewed change to the helper. The helper still sets HttpOnly on every cookie. - The http exception is named:
PLAIN_HTTP_LOOPBACKandexemptFromSecure(origin)in the test say that only a plain-http 127.0.0.1,[::1]orlocalhostorigin may go withoutSecure. The http run now asserts its origin is one of those. A test showshttps://127.0.0.1, a plain-http public host andlocalhost.evil.testare not exempt. - Form sign-in and sign-up: POST
/signinand POST/signup, the doors a person without JavaScript uses, are now driven alongside the API and passkey doors. - A failing test for each rule:
check()is shown to fail on a cookie with no HttpOnly whose name isn't on the list, one with no SameSite, one with no Secure over https, and one with no Secure on a plain-http host that isn't loopback. It passes on loopback.
Checks run: bun scripts/gate.ts and bun x tsc --noEmit are clean, and bun test test/cookie-flags.test.ts test/cookie-secure.test.ts test/request-access.test.ts test/signup-closed.test.ts passes, 32 tests. scripts/fast.ts named 2021 test files (about 171 minutes), because nearly everything imports src/auth/cookies.ts. Its only code change is a new frozen, empty constant, so I picked the files that cover cookies and sign-up by hand, and the forge's full check covers the rest.
Not done: there is no way to drop HttpOnly through the helper. The issue asks only for the allow-list, and no cookie needs one yet.
Try it: bun test test/cookie-flags.test.ts
🤖 Generated with Claude Code
Every cookie the forge sets is now HttpOnly and SameSite, and also Secure everywhere except plain-http loopback. Cookies that script has to read are exempt, but only if src/auth/cookies.ts lists them with a reason. test/cookie-flags.test.ts holds every Set-Cookie the forge sends to those rules.
This push fixes the check failure: the gate refused one comment in test/cookie-flags.test.ts at 115 columns, so it is rewrapped under 100. Nothing else changed. The gate reads the committed tree, which is why it kept failing until the fix was committed.
Locally on the pushed commit, bun scripts/gate.ts, bun x tsc --noEmit and bun test test/cookie-flags.test.ts (14 tests) all pass. I did not run the rest of the suite; the forge's check does that on this push.
How to try it: run bun test test/cookie-flags.test.ts.
🤖 Generated with Claude Code
Every cookie the forge sets is now checked: it must be HttpOnly and SameSite, and Secure everywhere except loopback. A cookie that breaks that rule has to be named as an exception, with the reason, in test/cookie-flags.test.ts. The test also checks that every setCookie/expireCookie call under src/ is driven by a request or has a written reason why none is, and that a cookie's path is only ever narrower than /, never wider.
This push fixes the failed check. The comment-width rule in scripts/gate.ts on main is newer than the one this branch had, so the gate passed here and failed when the check merged into main. Main is now merged into the branch and its bun scripts/gate.ts --fix rewrapped two doc comments in test/cookie-flags.test.ts; no code changed.
After the merge, bun scripts/gate.ts and bun x tsc --noEmit pass, and bun test test/cookie-flags.test.ts passes (14 tests).
🤖 Generated with Claude Code
Every cookie the forge sets must now be HttpOnly and SameSite, and Secure everywhere except plain-HTTP loopback. test/cookie-flags.test.ts checks this two ways: it drives every request that sets a cookie, including form sign-in and sign-up, over both http and https. It also walks src/ and fails on any cookie line not built by src/auth/cookies.ts.
There are no exceptions to HttpOnly. The empty SCRIPT_READABLE allow-list, which only the test read, is gone from src/auth/cookies.ts, and its header comment no longer points to it. check() requires HttpOnly on every cookie. The negative test now sends a cookie the test knows (forge_session) with no HttpOnly and expects it to fail. Before, it used a cookie the test doesn't know, so it would have failed even with HttpOnly set.
The Secure assertion is now a plain boolean compare: expect([where, flags.includes("secure")]).toEqual([where, https]).
The only Secure exemption is plain-HTTP loopback (PLAIN_HTTP_LOOPBACK, exemptFromSecure), and a test checks that look-alike hosts such as localhost.evil.test don't get it. Main is merged in so the newer comment-width rule in scripts/gate.ts applies; its fixer rewrapped two doc comments.
bun scripts/gate.ts, bun x tsc --noEmit and bun test test/cookie-flags.test.ts (14 tests) pass.
This is test hardening, not the pipeline work the direction puts first.
🤖 Generated with Claude Code
Most of this was already on main from #12340 and #11882.
test/cookie-flags.test.tsalready drove the API, passkey, recovery, parent-OAuth, claim and app routes over an http and an https forge, and checked HttpOnly, SameSite and Secure on every cookie they set. This pull closes the three gaps #13124 still had.SCRIPT_READABLEinsrc/auth/cookies.tsis the one place a cookie that script may read would be named, with its reason. It is empty and frozen. The door test checks HttpOnly on every cookie whose name is not in it. A new test asserts the list is empty and that every entry has a reason, so adding one is a reviewed change to the helper. The helper still sets HttpOnly on every cookie.PLAIN_HTTP_LOOPBACKandexemptFromSecure(origin)in the test say that only a plain-http 127.0.0.1,[::1]orlocalhostorigin may go withoutSecure. The http run now asserts its origin is one of those. A test showshttps://127.0.0.1, a plain-http public host andlocalhost.evil.testare not exempt./signinand POST/signup, the doors a person without JavaScript uses, are now driven alongside the API and passkey doors.check()is shown to fail on a cookie with no HttpOnly whose name isn't on the list, one with no SameSite, one with no Secure over https, and one with no Secure on a plain-http host that isn't loopback. It passes on loopback.Checks run:
bun scripts/gate.tsandbun x tsc --noEmitare clean, andbun test test/cookie-flags.test.ts test/cookie-secure.test.ts test/request-access.test.ts test/signup-closed.test.tspasses, 32 tests.scripts/fast.tsnamed 2021 test files (about 171 minutes), because nearly everything importssrc/auth/cookies.ts. Its only code change is a new frozen, empty constant, so I picked the files that cover cookies and sign-up by hand, and the forge's full check covers the rest.Not done: there is no way to drop HttpOnly through the helper. The issue asks only for the allow-list, and no cookie needs one yet.
Try it:
bun test test/cookie-flags.test.ts🤖 Generated with Claude Code
Closes #13124