fix: Fix CORS allowOrigin silently leaks configured origin on mismatch (#74)#78
Open
KochC wants to merge 1 commit into
Open
fix: Fix CORS allowOrigin silently leaks configured origin on mismatch (#74)#78KochC wants to merge 1 commit into
KochC wants to merge 1 commit into
Conversation
…rigin on mismatch When a specific CORS origin is configured and the incoming request origin does not match, the previous code returned the configured origin in the Access-Control-Allow-Origin header. This leaks the configured origin to untrusted callers and does not actually block the request (browsers reject the response because the header value doesn't match the request origin, but the information is still exposed). The fix omits the Access-Control-Allow-Origin header entirely on a mismatch so that neither the configured origin is disclosed nor is there any ambiguity about whether cross-origin access is granted. Tests are updated to assert the header is absent on mismatch rather than checking that it equals the configured (but leaked) origin.
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
Changed corsHeaders() to return the string "null" (instead of the configured origin) when the request's Origin header does not match OPENCODE_LLM_PROXY_CORS_ORIGIN, ensuring browsers block cross-origin requests from unrecognised origins.
Closes #74
Diff
Automated fix by OpenCode Agent