http: validate ClientRequest path on set#62030
Open
mcollina wants to merge 1 commit intonodejs:mainfrom
Open
Conversation
The `path` property on `ClientRequest` was only validated at construction time. Add a getter/setter so that the same `INVALID_PATH_REGEX` check runs whenever `req.path` is reassigned, preventing invalid characters from reaching `_implicitHeader()`.
Collaborator
|
Review requested:
|
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #62030 +/- ##
==========================================
- Coverage 89.74% 89.65% -0.09%
==========================================
Files 676 676
Lines 206070 206249 +179
Branches 39517 39509 -8
==========================================
- Hits 184928 184908 -20
- Misses 13300 13466 +166
- Partials 7842 7875 +33
🚀 New features to boost your workflow:
|
anonrig
approved these changes
Feb 28, 2026
marco-ippolito
approved these changes
Feb 28, 2026
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.
Summary
ClientRequest.paththat runsINVALID_PATH_REGEXvalidation on every assignment, not just at construction timekPath) so the setter is always invokedreq.pathafter constructionTest plan
test/parallel/test-http-client-path-toctou.jsverifying:req.pathwith\r\n,\r,\n, or\0throwsERR_UNESCAPED_CHARACTERStest-http-client-*tests pass (66/66)