Repository navigation
Conversation
…e Studio shell Studio routes by location.hash only, yet the preview server answered every unknown GET with the Studio shell (200, same origin, query kept). An OAuth redirect to the preview port (/oauth/callback?code=...&state=...) therefore re-mounted the project, and project script read the code from the address (SECOPS-2642, part 1). The shell is now served only at / and /index.html. Any other path gets a plain-text 404, and a request carrying `code` or `state` at any path (entry and preview routes included) gets a plain-text 400. Both carry a sandbox CSP (opaque origin), COOP same-origin, frame-ancestors 'none' / X-Frame-Options DENY, nosniff, no-referrer and no-store, and never echo the request. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Contributor
Edit accuracy: accurate 253 (base branch 253), smooth 71 of thoseThe gate fails: 14 of 15 shards reported results. Quarantined, measured but not gated (0) Unstable (1)
|
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What
SECOPS-2642 part 1.
hyperframes previewanswered every unknown GET with the Studio shell (200, same origin, query kept). An OAuth redirect to the preview port (/oauth/callback?code=…&state=…) therefore re-mounted the project, and project script read the code from the address.Studio routes by
location.hashonly, so it never needs a path:/and/index.html./assets/*,/icons/*,/favicon.svg,/api/*and/__hyperframes_configare unchanged.404 Not found..codeorstateat any path gets a plain-text400. That includes/and/api/projects/:id/preview, which loads project script. This runs as the first middleware. No Studio route uses either parameter.Content-Type: text/plain,X-Content-Type-Options: nosniff,Content-Security-Policy: sandbox; default-src 'none'; frame-ancestors 'none',X-Frame-Options: DENY,Cross-Origin-Opener-Policy: same-origin,Cross-Origin-Resource-Policy: same-origin,Referrer-Policy: no-referrer,Cache-Control: no-store. The CSPsandboxgives the page an opaque origin, so a same-origin opener or parent cannot read its address. COOP alone leaves a same-origin popup readable. This is the same header set as the part 3 refusal in fix(cli): play and present answer unknown paths with an inert refusal (SECOPS-2642 part 3) #8160, but a separate copy here.The CLI's own login (
packages/cli/src/auth/loopback.ts) runs its ownnode:httpserver on an ephemeral port and is untouched.src/authtests pass.Tests
New
packages/cli/src/server/studioServer.unknownPaths.test.ts:/oauth/callbackand/callbackwithcodeandstate, on127.0.0.1andlocalhost, plus four unknown paths. Each must be non-HTML with the headers above and must not contain the code, the state,<or the shell.codeand/orstateon/,/index.htmland/api/projects/project/preview, and on a POST./,/index.htmland/?hf_canary_…still serve the shell.Fails without the fix:
studioServer.unknownPaths.test.ts. 13 of 16 tests fail againstmain'sstudioServer.ts. For example, "refuses an OAuth return at /oauth/callback instead of serving the Studio shell" getsexpected 200 to be greater than or equal to 400, and the preview-route and POST cases getexpected null to be 'nosniff'. The 3 entry-route tests pass on both.Two existing tests assumed the shell at a made-up SPA path (
/editor,/projects/demo). They now hit/index.html.Other parts of SECOPS-2642 (not in this PR)
play/presentis a separate PR (fix(cli): play and present answer unknown paths with an inert refusal (SECOPS-2642 part 3) #8160).Verification
vitest runforsrc/server+src/auth: all pass, apart from the known-flakyfileWatcher.atomicreal-FS test, which passes on rerun.main'sstudioServer.tson this machine (openWritesNothingis flaky and passed with the fix):whisper/manager-resolution,utils/projectLock,utils/publishProject(Unicode form),commands/lambda/deploy(warming),checkSweep.chromium×2 (WebGL).tsc --noEmit, oxlint, oxfmt, fallow andcomment-ratchetare clean.hyperframes preview. The tests check the server responses and headers, not browser COOP/sandbox behaviour.🤖 Generated with Claude Code