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: validate coerced header values for CRLF by mcollina · Pull Request #5579 · nodejs/undici

Conversation

@mcollina

@mcollina mcollina commented Jul 21, 2026

Copy link
Copy Markdown
Member

Why

processHeader() rejected objects but not functions (typeof fn === 'function'). Non-string values were coerced with `${val}` and written to the HTTP/1.1 wire without isValidHeaderValue(), so a function with a crafted toString() / Symbol.toPrimitive could inject CRLF sequences into request headers.

This is defense-in-depth / hardening, not a security advisory under our threat model: exploitation requires the application to pass a function as a header value (trusted application input). String CRLF was already rejected.

Changes

  • After coercing non-string scalar header values, run isValidHeaderValue()
  • Same validation for non-string array elements after coercion
  • Regression tests for toString and Symbol.toPrimitive on scalar and array paths
  • Confirm numbers/booleans still work

Test plan

  • node --test test/header-function-crlf.js test/request-crlf.js test/headers-crlf.js test/invalid-headers.js
  • npm run lint

Sorry, something went wrong.

Uh oh!

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

peterhirn reacted with heart emoji
All reactions
  • ❤️ 1 reaction
@mcollina
fix: validate coerced header values for CRLF
0a2ae08
Functions bypassed the object guard in processHeader() and were
coerced via template literals without isValidHeaderValue(), allowing
CRLF injection when toString/Symbol.toPrimitive returned embedded
newlines. Validate after coercion on both scalar and array paths.

Signed-off-by: Matteo Collina <[email protected]>
@codecov-commenter

codecov-commenter commented Jul 21, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 93.47%. Comparing base (f36ea9c) to head (0a2ae08).
⚠️ Report is 1 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #5579      +/-   ##
==========================================
- Coverage   93.47%   93.47%   -0.01%     
==========================================
  Files         110      110              
  Lines       37564    37575      +11     
==========================================
+ Hits        35114    35122       +8     
- Misses       2450     2453       +3     

☔ 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.

metcoder95
metcoder95 approved these changes Jul 21, 2026
View reviewed changes
jasnell
jasnell approved these changes Jul 22, 2026
View reviewed changes
@mcollina
mcollina merged commit 354a151 into main Jul 22, 2026
37 of 38 checks passed

Uh oh!

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

@mcollina
mcollina deleted the fix/header-function-crlf-validation branch July 22, 2026 06:26
mcollina added a commit that referenced this pull request Jul 24, 2026
@mcollina
fix: validate coerced header values for CRLF (#5579)
d887e34
Functions bypassed the object guard in processHeader() and were
coerced via template literals without isValidHeaderValue(), allowing
CRLF injection when toString/Symbol.toPrimitive returned embedded
newlines. Validate after coercion on both scalar and array paths.

Signed-off-by: Matteo Collina <[email protected]>
(cherry picked from commit 354a151)
mcollina added a commit that referenced this pull request Jul 24, 2026
@mcollina
fix: validate coerced header values for CRLF (#5579)
2698e49
Functions bypassed the object guard in processHeader() and were
coerced via template literals without isValidHeaderValue(), allowing
CRLF injection when toString/Symbol.toPrimitive returned embedded
newlines. Validate after coercion on both scalar and array paths.

Signed-off-by: Matteo Collina <[email protected]>
(cherry picked from commit 354a151)
@github-actions github-actions Bot mentioned this pull request Jul 24, 2026
[Release] v8.9.0 #5589
Merged
@morganlinton morganlinton mentioned this pull request Aug 16, 2026
VulcanCyber v1: defensive cybersecurity eval suite (16 tasks) morganlinton/VulcanBench#44
Merged
@mtrezza mtrezza mentioned this pull request Sep 23, 2026
refactor: Bump undici from 6.27.0 to 6.28.1 parse-community/Parse-SDK-JS#3105
Merged
This was referenced Oct 24, 2026
refactor: Bump undici from 6.27.0 to 6.29.1 and 7.28.0 to 7.30.1 parse-community/Parse-SDK-dotNET#436
Merged
refactor: Bump undici from 6.27.0 to 6.29.1 and 7.28.0 to 7.30.1 parse-community/node-apn#226
Merged
refactor: Bump undici from 6.27.0 to 6.29.1 and 7.28.0 to 7.30.1 parse-community/parse-server-example#947
Merged
refactor: Bump undici from 7.24.6 to 7.30.1 parse-community/Parse-SDK-Flutter#1179
Merged
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Reviewers

@jasnell jasnell jasnell approved these changes
@metcoder95 metcoder95 metcoder95 approved these changes

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.

4 participants

@mcollina @codecov-commenter @jasnell @metcoder95
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.