GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — fix: reject cross-site requests to open-editor and invalidate endpoints by bjohansebas · Pull Request #5691 · webpack/webpack-dev-server

Conversation

@bjohansebas

@bjohansebas bjohansebas commented Jun 30, 2026

Copy link
Copy Markdown
Member

Summary

Basically, this only protects against external websites calling those endpoints. It doesn't protect against Node.js scripts or curl, since in those cases the headers can be freely modified.

In contrast, when a request is made with fetch() from a web page, Chrome automatically sends the Sec-Fetch-Site header and doesn't let the page override it, even if an attacker tries. The same applies to the Origin header—it can't be spoofed by JavaScript running in the browser.

What kind of change does this PR introduce?

Did you add tests for your changes?

Does this PR introduce a breaking change?

If relevant, what needs to be documented once your changes are merged or what have you already documented?

Use of AI

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
@bjohansebas
bjohansebas requested review from UlisesGascon and alexander-akait June 30, 2026 18:38
@changeset-bot

changeset-bot Bot commented Jun 30, 2026 •
edited
Loading

Uh oh!

There was an error while loading. Please reload this page.

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: f4a545d

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 1 package
Name Type
webpack-dev-server Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@codecov

codecov Bot commented Jun 30, 2026 •
edited
Loading

Uh oh!

There was an error while loading. Please reload this page.

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 89.30%. Comparing base (e90221c) to head (f4a545d).
⚠️ Report is 3 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #5691      +/-   ##
==========================================
+ Coverage   89.23%   89.30%   +0.07%     
==========================================
  Files          13       13              
  Lines        6082     6124      +42     
==========================================
+ Hits         5427     5469      +42     
  Misses        655      655              

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.
All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

bjohansebas
bjohansebas commented Jun 30, 2026
View reviewed changes
Comment thread lib/Server.js
Comment on lines +3262 to +3264
// otherwise fall back to the `Origin`/`Host` comparison.
if (typeof headers.origin !== "string") {
return true;

@bjohansebas bjohansebas Jun 30, 2026

Copy link
Copy Markdown
Member Author

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.

From what I've tested, the browser doesn't send an Origin header in this case

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions

@bjohansebas bjohansebas Jul 2, 2026

Copy link
Copy Markdown
Member Author

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.

Also, without this, we could break a simple curl request, which isn't a good idea.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
Base automatically changed from next to main July 1, 2026 19:26
An error occurred while trying to automatically change base from next to main July 1, 2026 19:26
bjohansebas added 2 commits July 1, 2026 15:07
@bjohansebas
fix: reject cross-site requests to open-editor and invalidate endpoints
f90b108
@bjohansebas
fix: reject cross-site requests to internal open-editor and invalidat…
f4a545d
…e endpoints
@bjohansebas
bjohansebas force-pushed the protect-routes branch from 55a3d85 to f4a545d Compare July 1, 2026 20:08
Copilot AI review requested due to automatic review settings July 1, 2026 20:08
Copilot started reviewing on behalf of bjohansebas July 1, 2026 20:08
View session
Copilot AI reviewed Jul 1, 2026
View reviewed changes

Copilot AI left a comment

Copy link
Copy Markdown

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.

Pull request overview

This PR hardens webpack-dev-server’s internal, state-changing endpoints (/webpack-dev-server/open-editor and /webpack-dev-server/invalidate) against cross-site request forgery by rejecting cross-site browser requests based on Fetch Metadata (Sec-Fetch-Site) with an Origin/Host fallback.

Changes:

  • Add same-origin verification for the invalidate and open-editor endpoints in Server.
  • Add e2e coverage (both header-driven and real-browser) asserting cross-site requests are blocked and same-origin requests are allowed.
  • Bump launch-editor (and lockfile transitive updates) and add a changeset entry.

Reviewed changes

Copilot reviewed 4 out of 5 changed files in this pull request and generated 1 comment.

Show a summary per file
File Description
lib/Server.js Adds same-origin request gating for invalidate and open-editor, introducing #isSameOriginRequest to block cross-site triggers.
test/e2e/cross-origin-request.test.js Adds new CSRF-focused tests for the internal endpoints, including browser-driven Fetch Metadata coverage.
package.json Updates launch-editor dependency version.
package-lock.json Updates resolved versions/integrity for launch-editor and transitive shell-quote.
.changeset/fix-cross-site-request-forgery.md Documents the security fix as a patch release note.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
Comment thread lib/Server.js Resolved

Uh oh!

There was an error while loading. Please reload this page.

This was referenced Jul 2, 2026
fix: reject cross-site requests to open-editor and invalidate endpoints #5698
Merged
chore(release): new release #5692
Merged
@bjohansebas
bjohansebas merged commit ba54764 into main Jul 2, 2026
77 of 115 checks passed

Uh oh!

There was an error while loading. Please reload this page.

@bjohansebas
bjohansebas deleted the protect-routes branch July 2, 2026 17:13
@chenjiahan chenjiahan mentioned this pull request Oct 20, 2026
fix: reject cross-site requests to the editor endpoint web-infra-dev/rsbuild#8704
Closed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Reviewers

Copilot code review Copilot
Copilot review effort
Applies to this pull request for everyone.Learn more about Copilot code review.
Copilot left review comments
@alexander-akait alexander-akait Awaiting requested review from alexander-akait
@UlisesGascon UlisesGascon Awaiting requested review from UlisesGascon

Uh oh!

There was an error while loading. Please reload this page.

Assignees

No one assigned

Labels

None yet

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

Uh oh!

There was an error while loading. Please reload this page.

2 participants

@bjohansebas
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.
You are visitor 01402775 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.