fix(server): restrict CORS to VS Code webviews - #54
Open
karakanb wants to merge 1 commit into
Open
Conversation
|
Reviews (1): Last reviewed commit: "fix(server): restrict CORS to VS Code we..." | Re-trigger Greptile |
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.
Motivation
POST /api/v1/query) to arbitrary browser origins, enabling cross-origin data exfiltration.Description
Access-Control-Allow-Origin: *middleware with origin validation that permits same-origin and non-browser clients and only allows validatedvscode-webview://origins, reflecting the exact origin and addingVary: Origin(changes inpkg/server/server.go).sameOriginandisVSCodeWebviewOriginto validate origins and return HTTP 403 for disallowed cross-origin requests, and respond to authorized preflights with HTTP 204.pkg/server/watcher.go).TestCORSMiddlewarecovering no-origin, same-origin, VS Code webview (including preflight), malicious website, and spoofed-scheme cases (change inpkg/server/server_test.go).docs/commands/serve.mdso users know the local API rejects arbitrary browser origins.Testing
make test, which executed the Go unit test suite including the updatedpkg/servertests and completed successfully.make formatwhere Go formatting andgo vetpassed, but frontend type checks could not be completed due to missing frontend dependencies in the environment.make depsfailed to fetch modules fromproxy.golang.org(HTTP 403 in this environment), so full dependency installation and a completemake buildwere not possible here.git diff --checkand repository checks were run and reported no whitespace or diff-check issues for the changes.Codex Task