Conversation
…bject Node's querystring.parse uses Object.create(null) so __proto__ / constructor land as own data properties and Object.getPrototypeOf(result) is null. Perry returned a regular object, so the prototype-pollution guard Node added in v6+ was missing. Add OBJ_FLAG_NULL_PROTO on GcHeader._reserved (bit 6 — bits 3..5 are the copied-nursery survival counter and bits 14..15 the layout state, so 0x08 would be clobbered on every minor GC) and a js_object_alloc_null_proto helper that stamps it. Object.getPrototypeOf consults the flag and returns null for those objects. Wire querystring.parse and the Object.create(null) path through the new allocator.
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.
Summary
querystring.parsenow returns a null-prototype object soObject.getPrototypeOf(result) === null, matching Node'sObject.create(null)-backed result and dodging__proto__pollution.OBJ_FLAG_NULL_PROTOonGcHeader._reserved(bit 6 — bits 3..5 are the copied-nursery survival counter and bits 14..15 the layout state, so 0x08 would be clobbered on every minor GC) and ajs_object_alloc_null_protohelper.Object.getPrototypeOfreturns null when the flag is set;Object.create(null)now stamps it too (previously returned the object itself).Test plan
test-parity/node-suite/querystring/parse/null-prototype.tsmatches Node byte-for-byte, including spread /Object.assignnot propagating the flag,JSON.stringify, andObject.keys.querystring/parse/*.tsparity cases still match (theempty-keys.tsdiff is pre-existing and unrelated).Object.create(null)sanity (getPrototypeOf→ null, own keys preserved) matches Node.Closes #1175.