Skip to content

Backport security fix from v5.2.1 to version-4 (non-Chromium browser dev-server vulnerability) #5534

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
wants to merge 2 commits into
base: version-4
Choose a base branch
from

Conversation

Wajih-Ul-Hasan
Copy link

@Wajih-Ul-Hasan Wajih-Ul-Hasan commented Jul 11, 2025

Summary

Backported the security patch from v5.2.1 to the version-4 branch to prevent dev client injection into unauthorized or potentially malicious browsers via the /webpack-dev-server route.

What This Fixes

  • Prevents exposure of dev asset listings and client scripts to untrusted sources
  • Implements a header-based access control mechanism instead of relying on insecure User-Agent detection

Context

Relevant to: #5313
Inspired by: #5315 (official v5.2.1 patch)

Since [email protected] depends on [email protected], and upgrading to v5 is not always viable for projects in production, this patch brings essential security hardening to the v4 codebase.

Implementation Details

  • Introduced isTrustedClient() helper to verify presence of webpack-dev-server-client header
  • /webpack-dev-server route now denies access (403) if the required header is missing
  • Patch mirrors the core logic used in v5.2.1, but adapted to v4’s Express-based routing
  • Clean, isolated backport to avoid impact on unrelated parts of the server

Thanks for considering this backport 🙏
Happy to adjust based on any review feedback.

Copy link

linux-foundation-easycla bot commented Jul 11, 2025

CLA Signed

The committers listed above are authorized under a signed CLA.

@Wajih-Ul-Hasan
Copy link
Author

Hi @alexander-akait — tagging you as discussed in Issue #5313. This PR backports the dev-server security fix for non-Chromium browsers to the version-4 branch. Let me know if any changes are needed.

@alexander-akait
Copy link
Member

Sorry, it is not a good fix, we can't apply security fix using userAgentHeader, it is unsafe and insecurity, we need to backport header logic

@Wajih-Ul-Hasan
Copy link
Author

Wajih-Ul-Hasan commented Jul 11, 2025

@alexander-akait If you have any better logic in your mind ,kindly share it with me. I will implement it.

@alexander-akait
Copy link
Member

There is a start of work - #5514, just need to backport this logic from v5 to v4

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants