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

Every /__forge/* answer on an app host wears the security floor, JSON included #6115

opened this

Merged 41d 2h ago, live in production

Every /forge/ answer the forge itself writes on an app host now passes through securityFloor, so the JSON answers carry the CSP, referrer-policy and x-content-type-options too. The feedback, crew-pill, door and credentials tests pass.

Notes

opened this

Every /__forge/* answer the forge itself writes on an app host now passes through securityFloor, so the JSON answers carry the CSP, referrer-policy and x-content-type-options too. The feedback, crew-pill, door and credentials tests pass. I did not get a type check: tsc failed here because the bun type definitions aren't installed.

  • Fix: in src/apps/proxy.ts, the /__forge/crew answer, the door's 405, every answer from the notes handler (/__forge/note, /__forge/notes, their errors and 404s) and /__forge/measure now go through securityFloor. This also covers the 405/403/404 JSON from src/apps/feedback.ts without touching its json helper.
  • Test: the new test in test/apps-feedback.test.ts walks /__forge/, /crew, /notes, /note, /note/moderate and /measure. It sends GET and POST, signed in and out, against a public and a private app, and checks the three headers on every answer. The CSP must be exactly default-src 'none'; frame-ancestors 'none'; base-uri 'none' on non-HTML answers. Before I wrapped /__forge/measure the same test failed on it, so removing the floor from a path does fail it.
  • Pill: its fetches are same-origin, and the crew-pill test still passes.
  • Left alone: /__forge/signin, /signout, /report and /grant answers are not wrapped. Unknown /__forge/note* paths (like /__forge/note/nope) still go through to the app, so the app's own response comes back without the floor.
  • Test placement: the new test sits last in its describe because its POSTs use up the per-sender and per-app note limits that a later test depends on.

Closes #6094

2 earlier comments
commented

Every /__forge/* answer the forge itself writes on an app host now passes through securityFloor, so the JSON answers carry the CSP, referrer-policy and x-content-type-options too. The feedback, crew-pill, door and credentials tests pass. I did not get a type check: tsc failed here because the bun type definitions aren't installed.

  • Fix: in src/apps/proxy.ts, the /__forge/crew answer, the door's 405, every answer from the notes handler (/__forge/note, /__forge/notes, their errors and 404s) and /__forge/measure now go through securityFloor. This also covers the 405/403/404 JSON from src/apps/feedback.ts without touching its json helper.
  • Test: the new test in test/apps-feedback.test.ts walks /__forge/, /crew, /notes, /note, /note/moderate and /measure. It sends GET and POST, signed in and out, against a public and a private app, and checks the three headers on every answer. The CSP must be exactly default-src 'none'; frame-ancestors 'none'; base-uri 'none' on non-HTML answers. Before I wrapped /__forge/measure the same test failed on it, so removing the floor from a path does fail it.
  • Pill: its fetches are same-origin, and the crew-pill test still passes.
  • Left alone: /__forge/signin, /signout, /report and /grant answers are not wrapped. Unknown /__forge/note* paths (like /__forge/note/nope) still go through to the app, so the app's own response comes back without the floor.
  • Test placement: the new test sits last in its describe because its POSTs use up the per-sender and per-app note limits that a later test depends on.
commented

Every /__forge/* answer the forge writes on an app host now passes through securityFloor, including the 303 redirects and the 404s. The type check is clean and the feedback, crew-pill, door and credentials tests pass. I did not look at the preview.

  • Newly wrapped: /__forge/signin, /signout, /report (the 303), /grant (the 303 and the 404), and the generic admit-failure answers under /__forge/. The last one is what a private app returns on /__forge/report.
  • Test: the path list in test/apps-feedback.test.ts now also covers /__forge/signin, /signout, /report, /grant and /grant?t=bad. That is GET and POST, signed in and out, on a public and a private app. A path that loses the floor fails the test.
  • *Unknown /__forge/note paths:** I chose to keep these going through to the app, and the comment above the feedback branch in src/apps/proxy.ts now says so. /__forge/notebook, for example, belongs to the app and keeps the app's headers.
  • Preview: the earlier report of /__forge/crew with only x-content-type-options fits a preview built from before the first push. I can't confirm the deployed head from here. After this push (d309a61d) deploys, the headers should arrive; the tests show they leave the proxy.
commented

The change is complete, but the preview can't show it. /__forge/* on an app host is answered by the proxy of the forge that hosts the app. For the preview at lab--6115--… that is the production forge, which still runs main. My branch only changes what the forge does once it is deployed.

I curled /__forge/crew, /notes, /measure and /signin on the preview at d309a61d. They show only x-content-type-options, with no CSP or referrer-policy, which is the old proxy's behaviour. Nothing in the app sits in front of proxyApp. The headers will arrive once this merges and the forge redeploys. Until then the evidence is the test, which runs the real proxy and checks the headers on every /__forge/* answer. It failed on /__forge/measure before that path was wrapped.

Changes this round (cf2a0580):

  • HTML answers: the sweep now checks that HTML answers such as the door still carry a CSP with default-src and frame-ancestors 'none', not just that a header exists.
  • *Unknown /__forge/note paths:** a new test checks that /__forge/notebook is not claimed by the notes door. It gets no JSON not_found from it and goes through to the app.

The type check is clean and test/apps-feedback.test.ts passes (25 tests).

Sign in to join this conversation.

Search
↑↓ navigate ↵ open ⌘↵ its app esc close

Keyboard shortcuts

Docs