You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
[Bug]: extraHTTPHeaders silently drops a valid proto header #44342
Inspect the incoming request on the server using request.rawHeaders.
The request should contain the proto header with value "test-value",
but the header is missing.
Expected behavior
The proto header should be preserved and sent like other valid HTTP headers.
The issue occurs because headersArrayToObject() uses ordinary property assignment, which invokes the inherited proto setter instead of creating an own property.
Actual behavior
The proto header is silently dropped and does not appear in the incoming HTTP request's rawHeaders.
Additional context
No response
Environment
- OS: Ubuntu Linux
- Node.js: v22.23.5
- Browsers tested: Chromium, Firefox, WebKit
- Playwright: Local development build from main branch
The header is dropped in Chromium and WebKit; Firefox sends it correctly. Tested on Linux at d70f422f491cfb875dd5dc05f01c61207e7382b4 (1.66.0-next). Assignment in headersArrayToObject() invokes the inherited __proto__ setter instead of creating a header property. The proposed fix uses Object.fromEntries() and extends the existing context-header test.
Reproduction and checks
The existing test now creates these context headers, overrides Foo on the page, and checks the incoming request:
Removing only the production fix reproduced the same failures again. With the fix restored, all 21 tests in browsercontext-set-extra-http-headers.spec.ts and page-set-extra-http-headers.spec.ts passed across the three browsers. npm run build and npm run flint passed.
Thanks for investigating and reproducing this issue.
I independently investigated this bug and implemented a fix in my local Playwright source.
My Investigation
The issue occurs in headersArrayToObject() in packages/isomorphic/headers.ts.
When a header named __proto__ is assigned using ordinary property assignment (result[key] = value), JavaScript invokes the inherited __proto__ setter instead of creating an own property. As a result, the header is silently dropped.
My Implementation
I implemented a fix using Object.defineProperty() for the __proto__ key, ensuring that it is preserved as an enumerable own property without changing the object's prototype.
Activity
microsoft-playwright-automation commentedon Nov 24, 2026
microsoft-playwright-automation commentedon Nov 24, 2026
Hi, I'm the Playwright bot and I reproduced this.
The header is dropped in Chromium and WebKit; Firefox sends it correctly. Tested on Linux at
d70f422f491cfb875dd5dc05f01c61207e7382b4(1.66.0-next). Assignment inheadersArrayToObject()invokes the inherited__proto__setter instead of creating a header property. The proposed fix usesObject.fromEntries()and extends the existing context-header test.Reproduction and checks
The existing test now creates these context headers, overrides
Fooon the page, and checks the incoming request:Removing only the production fix reproduced the same failures again. With the fix restored, all 21 tests in
browsercontext-set-extra-http-headers.spec.tsandpage-set-extra-http-headers.spec.tspassed across the three browsers.npm run buildandnpm run flintpassed.Draft PR: #44351
himanshug189-sketch commentedon Nov 24, 2026
Hi Playwright Team,
Thanks for investigating and reproducing this issue.
I independently investigated this bug and implemented a fix in my local Playwright source.
My Investigation
The issue occurs in
headersArrayToObject()inpackages/isomorphic/headers.ts.When a header named
__proto__is assigned using ordinary property assignment (result[key] = value), JavaScript invokes the inherited__proto__setter instead of creating an own property. As a result, the header is silently dropped.My Implementation
I implemented a fix using
Object.defineProperty()for the__proto__key, ensuring that it is preserved as an enumerable own property without changing the object's prototype.I also added a regression test in:
tests/library/browsercontext-set-extra-http-headers.spec.tsThe test verifies that the
__proto__header reaches the server with the expected value by inspectingrequest.rawHeaders.Validation Performed
I successfully completed the following checks:
npm run buildbrowsercontext-set-extra-http-headers.spec.tstest file in Chromium, Firefox, and WebKit.git diff --checkAll the above checks passed.
My Implementation
fix-proto-header-preservation329d4d3e4I noticed that the Playwright automation bot has also created Draft PR #44351 with an alternative implementation using
Object.fromEntries().I understand that both approaches aim to solve the same issue. I am sharing my implementation and validation results for the maintainers' reference.
I would be happy to receive feedback on my implementation or make any additional changes if needed.
Thanks!
dgozman commentedon Nov 24, 2026
This seems like not a real scenario, because it's unlikely that anyone will send a
__proto__header. Closing as not worth fixing.