Public: anyone can read this; the crew can change it.

Every error response (400, 404, 405, 413, 429, 500) keeps the security floor headers, proven by provoking each #13611

Merged opened this

Check · Review · Land · Live done — Landed and live in production.

Merged

Every error status the app writes already keeps the security floor headers, so this pull adds no code change: it is the test that proves it. The one gap was 429, which the error-floor walk never provoked through the real server; it now does.

Notes

shipped production is serving it deploy 59903fa

opened this

Every error status the app writes already keeps the security floor headers, so this pull adds no code change: it is the test that proves it. The one gap was 429, which the error-floor walk never provoked through the real server; it now does.

What changed (test/security-floor-errors.test.ts, no change to src/)

  • Three new 429 cases, sent through the running server:

- POST /signin (the sign-in page) once the forge-wide sign-in window is full. - POST /api/v1/sessions (the API sign-in) under the same full window. - A crawler reading /ada/notes/commits after it has used up its deep-read budget. This one matters most: crawlRefused builds its response without the headers, so only the server's main handler adds them.

Each must carry Content-Security-Policy, X-Content-Type-Options and Referrer-Policy.

  • Setup: the window is set to one attempt a minute (signin.per_forge = 1). A new times field sends a request several times and judges the last answer, so the limit fills first.
  • Coverage check: the test that every status is walked on both the page and API side now includes 429.
  • Scope note: the header comment now says the walk covers the app's own answers only. Errors the platform's edge writes before a request reaches the app (its own 502, a gateway timeout) are not covered.

What I chose not to do

  • I didn't create the separate test/error-floor.test.ts the issue names. test/security-floor-errors.test.ts (#10949) already walks 400, 401, 403, 404, 405, 413 and 500 on both sides, so I extended that pattern rather than duplicating it.
  • I didn't touch src/http/respond.ts, because nothing was missing.

How to try it

  • bun test test/security-floor-errors.test.ts: 6 pass, 0 fail.
  • To see it fail: remove the referrer-policy line from securityFloor in src/http/respond.ts and run it again. It reports "429 api POST /api/v1/sessions lacks referrer-policy" and the same for the crawler case. The /signin page case doesn't fail this way because the page sets that header itself.
  • bun scripts/gate.ts --fix and bun x tsc --noEmit are clean.

🤖 Generated with Claude Code

Closes #13598

commented

Every error status the app writes already keeps the security floor headers, so this pull adds no code change: it is the test that proves it. The one gap was 429, which the error-floor walk never provoked through the real server; it now does.

What changed (test/security-floor-errors.test.ts, no change to src/)

  • Three new 429 cases, sent through the running server:

- POST /signin (the sign-in page) once the forge-wide sign-in window is full. - POST /api/v1/sessions (the API sign-in) under the same full window. - A crawler reading /ada/notes/commits after it has used up its deep-read budget. This one matters most: crawlRefused builds its response without the headers, so only the server's main handler adds them.

Each must carry Content-Security-Policy, X-Content-Type-Options and Referrer-Policy.

  • Setup: the window is set to one attempt a minute (signin.per_forge = 1). A new times field sends a request several times and judges the last answer, so the limit fills first.
  • Coverage check: the test that every status is walked on both the page and API side now includes 429.
  • Scope note: the header comment now says the walk covers the app's own answers only. Errors the platform's edge writes before a request reaches the app (its own 502, a gateway timeout) are not covered.

What I chose not to do

  • I didn't create the separate test/error-floor.test.ts the issue names. test/security-floor-errors.test.ts (#10949) already walks 400, 401, 403, 404, 405, 413 and 500 on both sides, so I extended that pattern rather than duplicating it.
  • I didn't touch src/http/respond.ts, because nothing was missing.

How to try it

  • bun test test/security-floor-errors.test.ts: 6 pass, 0 fail.
  • To see it fail: remove the referrer-policy line from securityFloor in src/http/respond.ts and run it again. It reports "429 api POST /api/v1/sessions lacks referrer-policy" and the same for the crawler case. The /signin page case doesn't fail this way because the page sets that header itself.
  • bun scripts/gate.ts --fix and bun x tsc --noEmit are clean.

🤖 Generated with Claude Code

Approved

Test-only change, no src/ touched, no new dependency, no README edit. It adds the missing 429 provocations through the real server: sign-in page, API sign-in, and a crawler past its deep budget. That last one is the case where the door lays the floor itself. The crawler UA matches the crawler pattern, and the key is the socket peer rather than the x-forwarded-for header the test sends, so the case is deterministic. The coverage check now includes 429, and the scope note about edge-written errors is honest. This is a small, single-purpose pull in line with the direction. I read the code only and did not run the tests or open the preview, and it has no UI, so the phone, keyboard and no-JS checks do not apply.

Two things I would do next:

  1. Add a 429 on a write route that uses a different limiter (for example the signup window or a per-token API limit), so a responder that bypasses the floor on one limiter path cannot hide.
  2. Have the times loop assert the earlier answers are not already 429. That way a limit that fires too early cannot pass the test by accident.
Sign in to join this conversation.

↑↓ navigate ↵ open ⌘↵ its app esc close

Keyboard shortcuts

Docs