Repository navigation
fix: exact own origin for allowedOrigins lists, and open-editor over the network #5776
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
alexander-akait
wants to merge
4
commits into
main
Choose a base branch
from
fix/origin-and-open-editor-gaps
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+255
−40
Open
Changes from all commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
dc1b2d1
fix: exact own origin for allowedOrigins lists, and open-editor over …
alexander-akait f6a57ed
test: update the CLI help snapshot for the allowedOrigins description
alexander-akait 38606e6
Merge branch 'main' into fix/origin-and-open-editor-gaps
alexander-akait 7f8d7a8
Merge branch 'main' into fix/origin-and-open-editor-gaps
alexander-akait File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,5 @@ | ||
| --- | ||
| "webpack-dev-server": patch | ||
| --- | ||
|
|
||
| Refuse a request to open the editor that shows no page it came from, when the server is reached through a network address. Over `http:` anywhere but `localhost` a browser sends neither `Sec-Fetch-Site` nor `Origin`, so any page could have the developer's editor open a file of its choosing. The overlay's own request carries its `Referer` and keeps working, as does every request through `localhost`. |
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
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
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
Large diffs are not rendered by default.
Oops, something went wrong.
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
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
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
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
Oops, something went wrong.
Oops, something went wrong.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🔒 Security & Privacy | 🟠 Major | ⚡ Quick win
🔎 Supported by static analysis
🏁 Script executed:
Repository: webpack/webpack-dev-server
Length of output: 5404
🏁 Script executed:
Repository: webpack/webpack-dev-server
Length of output: 27037
Require same-origin page proof for the open-editor endpoint.
An explicitly listed cross-origin page can send its normal
Originheader and pass both checks. The helper accepts thatOriginwithout a same-originRefereror hot token. A listed cross-originRefereralso passes the helper.allowedOriginsshould authorize resource access, not prove that the request came from this server's page. Keep the hot token as the list-mode exception.Suggested fix
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Traced it, and the behavior is as described. A request that carries
Originwas already judged by#isSameOriginRequest, which is#isOriginAllowed(headers, "endpoint")in list mode. So a page on a listed origin, or any origin with"all", can call/open-editor.That is the rule #5770 set on purpose: listing an origin also opens the endpoints that act on the developer's machine to it.
allowed-origins.test.jsasserts this forinvalidate("opens the state-changing endpoints to the listed origin only").Abusing it takes control of a page the developer chose to trust. That is narrower than the unlisted and network-address cases this PR closes.
Restricting
/open-editorto the server's own page plus the token, as suggested, changes the meaning ofallowedOrigins(currently unreleased). That's a call for the maintainer, so I'm leaving this open until they decide, rather than pushing it here.Generated by Claude Code