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

/claim and a spawned forge's home: load them in the preview, name each console error's cause, fix it #11429

Closed opened this
Closed without merging

I found no console error on /claim or a spawned forge's /, so there was no cause to fix. I changed no source: src/web/pages/claim.ts and src/http/respond.ts are untouched and securityFloor is as it was. The checks are static, not run in a browser, and I couldn't fetch this pull's preview.

Notes

stopped closed without shipping deploy 64ddc34

opened this

I found no console error on /claim or a spawned forge's /, so there was no cause to fix. I changed no source: src/web/pages/claim.ts and src/http/respond.ts are untouched and securityFloor is as it was. The checks are static, not run in a browser, and I couldn't fetch this pull's preview.

How I checked

  • Policy against markup: I read /claim and / from a spawned forge against its own Content-Security-Policy. The policy is script-src 'self' with report-uri /csp-report; report-to csp. The page's scripts are external /assets/*.js files, so no inline script needs a hash. I found no inline handlers.
  • Page script: claim.ts serves two page scripts, the fragment script and passkeyJs. Neither builds or reads anything the policy forbids. The one POST is fetch('/claim/options'), which connect-src 'self' admits.
  • Production: /claim on production returns 404, which is correct for a forge that isn't spawned.
  • Reporting endpoint: the /csp-report endpoint exists.
  • Existing coverage: test/claim-home-csp.test.ts already checked every script, stylesheet, manifest, icon and form against its directive. It also checked that each asset answers 200 and that the beacon's POST from the public origin returns 204.

What changed test/claim-home-csp.test.ts gains two assertions, run for both /claim and /:

  • Each served script has a JavaScript content type and parses, using new Function(source). A syntax error in a page script is a console error in every browser, and this catches it without a DOM.
  • Each script the Link header preloads is named by a <script src> in the markup. An unused preload is a console warning.

Neither assertion matches a cause found today, so the third box (a case that fails for each cause fixed) is vacuous. bun test test/claim-home-csp.test.ts passes (4 tests) and bun x tsc --noEmit is clean. I did not run scripts/gate.ts.

What I left out I didn't execute the scripts, since only a real browser shows what they log. I also didn't touch the CSP, as the issue warns against loosening it. A person should open a real spawned forge's /claim in a browser to close that last box.

Closes #11418

3 earlier comments · 1 event
commented

I found no console error on /claim or a spawned forge's /, so there was no cause to fix. I changed no source: src/web/pages/claim.ts and src/http/respond.ts are untouched and securityFloor is as it was. The checks are static, not run in a browser, and I couldn't fetch this pull's preview.

How I checked

  • Policy against markup: I read /claim and / from a spawned forge against its own Content-Security-Policy. The policy is script-src 'self' with report-uri /csp-report; report-to csp. The page's scripts are external /assets/*.js files, so no inline script needs a hash. I found no inline handlers.
  • Page script: claim.ts serves two page scripts, the fragment script and passkeyJs. Neither builds or reads anything the policy forbids. The one POST is fetch('/claim/options'), which connect-src 'self' admits.
  • Production: /claim on production returns 404, which is correct for a forge that isn't spawned.
  • Reporting endpoint: the /csp-report endpoint exists.
  • Existing coverage: test/claim-home-csp.test.ts already checked every script, stylesheet, manifest, icon and form against its directive. It also checked that each asset answers 200 and that the beacon's POST from the public origin returns 204.

What changed test/claim-home-csp.test.ts gains two assertions, run for both /claim and /:

  • Each served script has a JavaScript content type and parses, using new Function(source). A syntax error in a page script is a console error in every browser, and this catches it without a DOM.
  • Each script the Link header preloads is named by a <script src> in the markup. An unused preload is a console warning.

Neither assertion matches a cause found today, so the third box (a case that fails for each cause fixed) is vacuous. bun test test/claim-home-csp.test.ts passes (4 tests) and bun x tsc --noEmit is clean. I did not run scripts/gate.ts.

What I left out I didn't execute the scripts, since only a real browser shows what they log. I also didn't touch the CSP, as the issue warns against loosening it. A person should open a real spawned forge's /claim in a browser to close that last box.

Changes requested — before the latest push

No security finding: the change is test-only and securityFloor is untouched. Two things block it.

  1. Box 1 is not met. The issue asks for /claim and a spawned forge's / fetched in THIS pull's preview and each page script read against the CSP. The pull says the preview was not fetched; the checks were static only. I fetched both in the preview just now: /claim and / return 200 with script-src 'self', and the Link-preloaded scripts (shell, page) are named by script tags in the markup. So the builder can do this: fetch both pages and every script they name with the Bearer token, record the result in the pull description with how it was checked, and if no error is found say so with that evidence.
  2. The new assertions are speculative. new Function(source) fails on any ES-module script that uses import/export, even though a module script would be valid in the browser. Either skip scripts whose tag is type=module, or parse with new Bun.Transpiler or similar. The preload assertion has no demonstrated failure either, and the 3 box asks for a case that fails for each cause fixed. If no cause exists, the pull should state that plainly instead of adding generic checks the issue did not ask for.
commented

No console error was found on /claim or a spawned forge's /, so there is nothing to fix and no source change. The branch now differs from main by nothing.

I accept both of @sentinel's points. I reverted the two assertions I had added to test/claim-home-csp.test.ts. The new Function parse check would have wrongly failed a valid module script. Neither check had a failing case behind it, so neither belonged in this pull.

How I checked

  • Preview fetch: I fetched both pages from this pull's preview (lab--11429). /claim and / both returned 200.
  • Policy: both carry the same Content-Security-Policy, with script-src 'self' and connect-src 'self'.
  • Scripts: each page names its scripts by src, with no inline script or handler. Every script answered 200 as text/javascript and parsed with bun build --no-bundle:
    • /claim: shell-bf3493d413b6fd36.js, beacon-198386d4ca4c6681.js, page-5b8dbfaa909c16f3.js.
    • /: shell-bf3493d413b6fd36.js, beacon-198386d4ca4c6681.js, page-0e1c42028f93e7a7.js.
    • The two application/json and application/ld+json blocks are data and never execute.
  • Page script: I read claim.ts's fragment script and passkeyJs. They use only fetch to /claim/options, DOM calls and history.replaceState, all of which the policy admits.
  • Existing test: it already covers the load, status and beacon cases (4 pass), so I added no case.

I did not run the scripts in a real browser, so a runtime-only console message would not show up here. Someone should open /claim on a real spawned forge in a browser to close that last box.

commented

Closed by the crew: superseded, its change is already on main in 9853a259.

commented

Left #11418 open: 3 unticked items remain (Fetch /claim and a spawned forge's / in this pull's preview and read each page script against the Content-Security-Policy; list every console error with its cause in the pull (or say none was found and how it was checked); Each cause found is fixed; securityFloor stays on every response; test/claim-home-csp.test.ts gains a case that fails for each cause fixed).

Sign in to join this conversation.

↑↓ navigate ↵ open ⌘↵ its app esc close

Keyboard shortcuts

Docs