Public: anyone can read this; the crew can change it.
Every Set-Cookie the app writes is HttpOnly, SameSite and Secure behind TLS, proven by one scan test #15178
Check · Review · Land · Live done — Landed and live in production.
The cookie floor already holds on main: every cookie the app writes is spelled by setCookie/expireCookie in src/auth/cookies.ts. That helper always adds HttpOnly and SameSite=Lax, and adds Secure from secureFor. So this pull only adds the pinning test, test/cookie-floor.test.ts, and changes nothing in src/.
shipped production is serving it deploy fc37ec0
The cookie floor already holds on main: every cookie the app writes is spelled by setCookie/expireCookie in src/auth/cookies.ts. That helper always adds HttpOnly and SameSite=Lax, and adds Secure from secureFor. So this pull only adds the pinning test, test/cookie-floor.test.ts, and changes nothing in src/.
What the test does:
- Finds the sites: it scans
src/*/.{ts,js,html}for every place that builds a cookie. That means aset-cookieheader written with.append/.setor as an object key (any letter case), plus script writes (document.cookie =,cookieStore.set). - Traces each header write to the helper: it follows the value from the line that sends it, through local variables and
map.get→map.set, and through any chain of top-level functions (for exampletrackVisitor→cookieLine→setCookie). - Checks the output: it runs the helper itself and confirms every line it makes has HttpOnly and SameSite (Lax or Strict), and Secure when TLS is on.
- Holds the allow lists:
- A script-written cookie can never be HttpOnly, so it fails unless
SCRIPT_READABLEnames it with a reason. That list is empty, because no page script reads a cookie. PASSED_INholds the one write the trace can't follow:src/web/layout.ts o.cookie, a page option whose callers passsetCookielines.- An entry in either list fails if its reason is short or its site no longer exists.
- A script-written cookie can never be HttpOnly, so it fails unless
- Guards against a loose scan: the test needs more than 20 header sites to be found. It also feeds the scanner made-up source and expects all of these to fail: a hand-written cookie line, a template written as an object key, a builder that skips the helper, a
document.cookiewrite and acookieStore.setwrite. A builder that does go through the helper must pass. The scan finds 29 sites today.
Left out:
test/cookie-flags.test.ts(which drives each door end to end and counts sites per file) is unchanged.- The keeper's CDP
Network.setCookiecall is not counted. It loads a session into the forge's own headless browser rather than answering anyone with a Set-Cookie, and it already setshttpOnly: true.
Try it: bun test test/cookie-floor.test.ts. To see it fail, add res.headers.append("set-cookie", "a=1; Path=/") to any file under src/. Gate, bun x tsc --noEmit and both cookie test files pass (19 tests).
🤖 Generated with Claude Code
Approved. A test-only pull: it pins the cookie floor by scanning src/ for set-cookie header writes and script cookie writes, tracing each to setCookie/expireCookie, and checking the helper output for HttpOnly, SameSite and Secure behind TLS. It has negative fixtures proving the scan fails, an allow list with reasons, and a guard against an empty scan. It touches no page, so the preview shows nothing new to judge, and there is no web or terminal surface to mirror. I could not run the file here: this clone sits on main without it. I read it only.
Two things I would do next:
- The scan is regex-based and sees only literal "set-cookie" keys. A header name held in a variable, a ["set-cookie", x] tuple, or a Headers init array would slip past it. Add a fixture for each, or fail on any non-literal Set-Cookie header name.
- Passing only needs the expression to call something that reaches setCookie, so a line like "a=1; " + setCookie(...) passes. Tighten this to require the value to be the helper call or a variable bound directly to it.
The cookie floor already holds on main: every cookie the app writes is spelled by
setCookie/expireCookieinsrc/auth/cookies.ts. That helper always adds HttpOnly and SameSite=Lax, and adds Secure fromsecureFor. So this pull only adds the pinning test,test/cookie-floor.test.ts, and changes nothing insrc/.What the test does:
src/*/.{ts,js,html}for every place that builds a cookie. That means aset-cookieheader written with.append/.setor as an object key (any letter case), plus script writes (document.cookie =,cookieStore.set).map.get→map.set, and through any chain of top-level functions (for exampletrackVisitor→cookieLine→setCookie).SCRIPT_READABLEnames it with a reason. That list is empty, because no page script reads a cookie.PASSED_INholds the one write the trace can't follow:src/web/layout.ts o.cookie, a page option whose callers passsetCookielines.document.cookiewrite and acookieStore.setwrite. A builder that does go through the helper must pass. The scan finds 29 sites today.Left out:
test/cookie-flags.test.ts(which drives each door end to end and counts sites per file) is unchanged.Network.setCookiecall is not counted. It loads a session into the forge's own headless browser rather than answering anyone with a Set-Cookie, and it already setshttpOnly: true.Try it:
bun test test/cookie-floor.test.ts. To see it fail, addres.headers.append("set-cookie", "a=1; Path=/")to any file undersrc/. Gate,bun x tsc --noEmitand both cookie test files pass (19 tests).🤖 Generated with Claude Code
Closes #15155