Repository navigation
fix(cors): default to same-origin and require explicit allowlist - #296
Merged
Merged
Conversation
- Only allowlisted origins receive CORS headers; an empty FUSION_CORS_ALLOWED_ORIGINS now means same-origin only. - Reject cross-origin state-changing requests with http.CrossOriginProtection. - "*" is no longer a wildcard; invalid entries are ignored with a warning. BREAKING CHANGE: deployments serving the frontend from a different origin must list it in FUSION_CORS_ALLOWED_ORIGINS. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
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.
Summary
Tighten the CORS defaults: credentialed CORS is only granted to explicitly allowlisted origins, and cross-origin state-changing requests are rejected.
"*"is no longer a wildcard; invalid entries are logged withslog.Warnand ignored.isOriginAllowedremoved.config.go,.env.example, README (the variable now sits under "frontend on a different origin" instead of "reverse proxy"),docs/backend-design.md,docs/api-conventions.md.Evidence
/api/*responses and create data via atext/plainPOST (checked in headless Chromium).After: the same page's read is blocked by the browser and the write returns 403; data is unchanged.
POST /api/sessions→ 200, "Refresh All"POST /api/feeds/refresh→ 202.cors_test.gocovers: unlisted origin gets no CORS headers; unlisted/same-site/cross-sitePOST → 403; same-origin,Sec-Fetch-Site: none, and header-less (Fever/curl) POST → 200;/feverthroughSetupRouter→ 200; allowlisted origin GET/POST/preflight;"*"no longer allowed../scripts.sh test-backendpasses.Merge Danger
Door: two-way
Revert restores the old behavior; no data or schema changes.
Blast Radius: split-origin deployments
Deployments serving the frontend from a different origin than the API (
VITE_API_BASE_URL) must setFUSION_CORS_ALLOWED_ORIGINS, and any"*"entry must be replaced with explicit origins — please call this out in the release notes. Unlisted origins now get 200/204 without CORS headers instead of 403. Not tested: a reverse proxy that rewritesHostcombined with an old browser that omitsSec-Fetch-Sitewould have same-origin writes rejected.🤖 Generated with Claude Code