Skip to content

fix(http): keep a __proto__ connection header on the byte transport - #2303

Merged
cevheri merged 2 commits into
mainfrom
fix/byte-transport-proto-header
Nov 15, 2026
Merged

cevheri merged 2 commits into
mainfrom
fix/byte-transport-proto-header

Conversation

@cevheri

@cevheri cevheri commented Nov 15, 2026

Copy link
Copy Markdown
Member

The byte transport now treats a connection header named __proto__ like any other header name.

checkedConnectionHeaders in src/lib/db/http/node-transport.ts built its checked record on a plain {}, so assigning __proto__ hit the prototype setter instead of creating an entry.
The observable: a connection header named __proto__ was missing from the request on the wire, with no error, and {"__proto__": "x", "__PROTO__": "y"} was accepted instead of refused with "Invalid headers: proto is named twice".
The fix builds the record with Object.create(null), so __proto__ is an own entry like any other name.

This is an internal transport-contract change that no current caller can reach: S3 passes no connection headers and Snowflake passes three fixed names.
With a connection header named __proto__, the transport now:

  • sends it on every request;
  • refuses a second spelling of it when the transport is built;
  • refuses a requestHeaderNames entry __proto__, as it refuses any name the connection sets;
  • refuses a signer headerNames entry __proto__, as it refuses any name the connection sets.

Every other header name keeps its behaviour.

Test plan

  • bun tests/run-tests.ts tests/unit/db/http/node-byte-transport.test.ts: the three new cases fail on main (header missing from the raw request head; no duplicate refusal; per-request __proto__ accepted) and pass with the fix, 167 pass.
  • bun tests/run-tests.ts tests/unit/db/http/node-transport.test.ts: the text transport, whose lowerCased already builds its record with no prototype, 57 pass.
  • bun run format && bun run lint && bun run typecheck && bun run knip: green on the branch rebased onto main; CI runs the full required gate.

The byte transport built its checked connection headers on a plain
object, so a header named __proto__ hit the prototype setter: it was
dropped from the request without a word, and a second spelling of it
was not refused as a duplicate. Build the record with no prototype, as
the text transport does, and pin both on the wire.
Pin that a per-request __proto__ next to a connection __proto__ is
refused when the transport is built, as any connection name is. The
first commit's comparison with the text transport holds only once
lowerCased also builds its record with no prototype; the fix does not
depend on it.
@codecov

codecov Bot commented Nov 15, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.

📢 Thoughts on this report? Let us know!

@sonarqubecloud

Copy link
Copy Markdown

@cevheri
cevheri merged commit 4c675d8 into main Nov 15, 2026
39 checks passed
@cevheri
cevheri deleted the fix/byte-transport-proto-header branch November 15, 2026 05:59
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant