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(h2): keep a request header named __proto__ by luantaraschi · Pull Request #5669 · nodejs/undici

Conversation

@luantaraschi

@luantaraschi luantaraschi commented Aug 8, 2026

Copy link
Copy Markdown
Contributor

This relates to...

The h2 half of what I flagged in a comment on #5667. test/prototype-headers.js already covers this concern for client.request over HTTP/1.

Rationale

buildRequestHeaders in lib/dispatcher/client-h2.js probes the accumulator by index:

const current = headers[key]
...
headers[key] = current ? `${current}, ${val}` : val

For __proto__ that probe returns Object.prototype, which is truthy, so the header takes the "already present" branch and the value becomes "[object Object], pwned". That string is then assigned through the Object.prototype setter, which refuses a string, so nothing is stored and the header never reaches the wire.

Reproduced over a real HTTP/2 connection, before the change:

x-control arrived: sent
__proto__ arrived: no

__proto__ is a valid field name, and the flat array form is exactly what this function receives from the dispatcher.

There is no Object.prototype pollution: the setter refuses the string, so the global prototype is untouched.

Changes

The probe uses Object.hasOwn so an inherited name is not mistaken for an existing header, and all four writes go through a setHeader helper using Object.defineProperty, the guard parseHeaders already uses in lib/core/util.js.

Test added to test/prototype-headers.js, alongside the HTTP/1 cases: an h2 request carrying __proto__ reaches the server with that header, with a control header that already worked.

test/+(http2|h2)*.js 104 passing with 1 skipped as before, lint clean.

Features

N/A

Bug Fixes

An HTTP/2 request no longer drops a header named __proto__, and no longer corrupts its value with [object Object], first.

Breaking Changes and Deprecations

None.

Status

  • I have read and agreed to the Developer's Certificate of Origin
  • Tested
  • Benchmarked (optional)
  • Documented
  • Review ready
  • In review
  • Merge ready

Sorry, something went wrong.

Uh oh!

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

All reactions
@luantaraschi
fix(h2): keep a request header named __proto__
fdd13bd
buildRequestHeaders probed the accumulator with headers[key], which returns
Object.prototype for __proto__ instead of undefined. The header took the
already-present branch, its value became '[object Object], pwned', and the
assignment then hit the Object.prototype setter, which refuses a string, so
nothing reached the wire.

The probe uses Object.hasOwn and the writes go through a setHeader helper
using Object.defineProperty, the guard parseHeaders already uses.
Copilot AI lite review requested due to automatic review settings August 8, 2026 02:41
Copilot AI reviewed Aug 8, 2026

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

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.

Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.

Sorry, something went wrong.

Uh oh!

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

All reactions
@luantaraschi luantaraschi mentioned this pull request Aug 8, 2026
fix(cache): keep a header named __proto__ out of the prototype chain #5667
Closed
3 of 7 tasks
@codecov-commenter

codecov-commenter commented Aug 8, 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 93.45%. Comparing base (dd85997) to head (fdd13bd).
⚠️ Report is 1 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #5669      +/-   ##
==========================================
+ Coverage   93.43%   93.45%   +0.02%     
==========================================
  Files         110      110              
  Lines       38733    38795      +62     
==========================================
+ Hits        36190    36256      +66     
+ Misses       2543     2539       -4     

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

@luantaraschi

luantaraschi commented Aug 10, 2026 •
edited
Loading

Uh oh!

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

Copy link
Copy Markdown
Contributor Author

The two failing Node 24 jobs stop at test/http2-request-never-settles.js. The same test also failed in #5663, an unrelated cookies change, while the rest of this matrix passed here.

I do not have permission to rerun workflows in this repository. Could a maintainer please rerun the failed jobs to confirm whether this is the same intermittent failure?

All reactions

Sorry, something went wrong.

Uh oh!

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

@luantaraschi luantaraschi mentioned this pull request Aug 14, 2026
fix: keep a header named __proto__ across features #5688
Merged
3 of 7 tasks
@luantaraschi

luantaraschi commented Aug 14, 2026 •
edited
Loading

Uh oh!

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

Copy link
Copy Markdown
Contributor Author

This one is in #5688 too. buildRequestHeaders now calls the shared setHeader from lib/core/util.js rather than carrying its own copy of the guard, and the test moved across as it was.

Closing here to keep the four of them from sitting in your queue. Say the word if you would rather review the h2 site separately and I will reopen it.

All reactions

Sorry, something went wrong.

Uh oh!

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

@luantaraschi luantaraschi closed this Aug 14, 2026
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

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.

3 participants

@luantaraschi @codecov-commenter
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.