Repository navigation
fix(http): keep a __proto__ connection header on the byte transport - #2303
Merged
Merged
Conversation
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 Report✅ All modified and coverable lines are covered by tests. 📢 Thoughts on this report? Let us know! |
|
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.



The byte transport now treats a connection header named
__proto__like any other header name.checkedConnectionHeadersinsrc/lib/db/http/node-transport.tsbuilt 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:requestHeaderNamesentry__proto__, as it refuses any name the connection sets;headerNamesentry__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 onmain(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, whoselowerCasedalready 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 ontomain; CI runs the full required gate.