-
-
Notifications
You must be signed in to change notification settings - Fork 757
fix: re-validate HttpUriPlugin redirects against allowedUris and enforce http(s) and max redirects #12463
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
Conversation
✅ Deploy Preview for rspack canceled.
|
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 addresses a critical security vulnerability in the HttpUriPlugin by implementing redirect validation and enforcement mechanisms to prevent SSRF (Server-Side Request Forgery) attacks and untrusted content inclusion. The fix follows the same approach as webpack's security patch in PR #20230.
Key Changes:
- Added redirect validation to ensure redirected URLs comply with the
allowedUrispolicy - Restricted redirects to only http(s) protocols, preventing protocol smuggling attacks
- Implemented a conservative 5-redirect limit to prevent redirect loops and SSRF amplification
Reviewed changes
Copilot reviewed 4 out of 4 changed files in this pull request and generated 7 comments.
| File | Description |
|---|---|
crates/rspack_plugin_schemes/src/http_uri/mod.rs |
Core security implementation: added validate_redirect_location() function to check redirects against policy, added MAX_REDIRECTS constant and enforcement, added sanitize_url_for_error() helper for safe error reporting, and modified resolve_content() to accept redirect count parameter |
tests/rspack-test/configCases/asset-modules/http-redirect-security/server/index.js |
Test infrastructure: HTTP server implementation with various redirect scenarios including allowed redirects, disallowed redirects, non-HTTP protocol redirects, and long redirect chains |
tests/rspack-test/configCases/asset-modules/http-redirect-security/rspack.config.js |
Test configuration with HttpUriPlugin configured to only allow http://localhost:9991/ URIs |
tests/rspack-test/configCases/asset-modules/http-redirect-security/index.js |
Comprehensive test suite validating all security scenarios: allowed redirects, disallowed URI redirects, non-HTTP protocol redirects, and excessive redirect chains |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
tests/rspack-test/configCases/asset-modules/http-redirect-security/server/index.js
Outdated
Show resolved
Hide resolved
tests/rspack-test/configCases/asset-modules/http-redirect-security/server/index.js
Outdated
Show resolved
Hide resolved
tests/rspack-test/configCases/asset-modules/http-redirect-security/server/index.js
Outdated
Show resolved
Hide resolved
Rsdoctor Bundle Diff AnalysisFound 5 project(s) in monorepo. 📁 react-10kPath:
📦 Download Diff Report: react-10k Bundle Diff 📁 react-1kPath:
📦 Download Diff Report: react-1k Bundle Diff 📁 react-5kPath:
📦 Download Diff Report: react-5k Bundle Diff 📁 romePath:
📦 Download Diff Report: rome Bundle Diff 📁 ui-componentsPath:
📦 Download Diff Report: ui-components Bundle Diff Generated by Rsdoctor GitHub Action |
📦 Binary Size-limit
❌ Size increased by 3.88KB from 48.28MB to 48.28MB (⬆️0.01%) |
CodSpeed Performance ReportMerging #12463 will not alter performanceComparing Summary
|
921a958 to
ee64bcc
Compare
…s; enforce http(s) and max redirects - Re-validate HttpUriPlugin redirects against allowedUris - Restrict redirects to http(s) protocols only - Add a conservative redirect limit (5) to prevent SSRF and untrusted content inclusion - Redirects failing policy are rejected before caching/lockfile writes This addresses the same security vulnerability that was fixed in webpack commit 2179fdbcb34fba57acc51377a5ff6ddecc97ac7f
ee64bcc to
2f8f4b2
Compare
…rce http(s) and max redirects (#12463) fix(security): re-validate HttpUriPlugin redirects against allowedUris; enforce http(s) and max redirects - Re-validate HttpUriPlugin redirects against allowedUris - Restrict redirects to http(s) protocols only - Add a conservative redirect limit (5) to prevent SSRF and untrusted content inclusion - Redirects failing policy are rejected before caching/lockfile writes This addresses the same security vulnerability that was fixed in webpack commit 2179fdbcb34fba57acc51377a5ff6ddecc97ac7f
This addresses the same security vulnerability that was fixed in webpack commit webpack/webpack#20230
Summary
Related links
Checklist