Repository navigation
Fix: Tor cross-onion CORS when Origin is null - #48
Merged
Merged
Conversation
Only emit Access-Control-Allow-Origin * when the literal null entry is allowlisted; do not rewrite Origin from Referer, which broke redirect flows. Document * response semantics for opted-in opaque origins. Co-authored-by: Cursor <cursoragent@cursor.com>
The cors package skips Vary when ACAO is *, but download responses use private caching. Vary Origin keeps per-origin CORS headers distinct. Co-authored-by: Cursor <cursoragent@cursor.com>
dev-adamant-im
approved these changes
Sep 28, 2026
This was referenced Sep 30, 2026
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.
Description
Tor Browser sends
Origin: nullon cross-.onionfetches while the document origin stays the PWA hidden service. ReflectingAccess-Control-Allow-Origin: nullmakes Firefox report “CORS Allow Origin Not Matching Origin” even on HTTP 200.nullentry is present incors.allowedOrigins, respond withAccess-Control-Allow-Origin: *forOrigin: null(credentials: falseon public routes). Without that opt-in, opaque origins stay rejected like any other disallowed origin.OriginfromReferer: the browser CORS check compares ACAO to the request origin, not the referer; rewriting broke redirect flows that legitimately sendOrigin: nullwith an allowlisted referer.Vary: Originbefore thecorsmiddleware so private-cached downloads (Cache-Control: private) do not reuse a*CORS response for a different origin when the package omitsVaryfor*.nullsemantics indocs/guide/security.md.Related to #46
Related issue
How to test
npm run lintnpm run formatnpm run typechecknpm testnullincors.allowedOrigins:curl -sD - -o /dev/null -H 'Origin: null' http://127.0.0.1:<port>/api/node/info→Access-Control-Allow-Origin: *andVary: Originnullin the list: same curl → noAccess-Control-Allow-Originheadernullandhttp://*.onionconfiguredChecklist
nullopt-inVary: Originon cacheable downloadsnpm run lint,npm run format,npm run typecheck, andnpm testrun locally