Registry Mirror
Skip to content

Conversation

@TheHypnoo

Copy link
Copy Markdown
Member

Summary

  • querystring.parse now returns a null-prototype object so Object.getPrototypeOf(result) === null, matching Node's Object.create(null)-backed result and dodging __proto__ pollution.
  • Adds 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.
  • Object.getPrototypeOf returns null when the flag is set; Object.create(null) now stamps it too (previously returned the object itself).

Test plan

  • New parity case test-parity/node-suite/querystring/parse/null-prototype.ts matches Node byte-for-byte, including spread / Object.assign not propagating the flag, JSON.stringify, and Object.keys.
  • Existing querystring/parse/*.ts parity cases still match (the empty-keys.ts diff is pre-existing and unrelated).
  • Object.create(null) sanity (getPrototypeOf → null, own keys preserved) matches Node.

Closes #1175.

TheHypnoo added 2 commits May 21, 2026 10:39
…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.
@TheHypnoo
TheHypnoo merged commit b7dc209 into main May 21, 2026
9 checks passed
@TheHypnoo
TheHypnoo deleted the fix/1175-querystring-parse-null-proto branch May 21, 2026 09:14
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.

node:querystring — parse should return a null-prototype object

1 participant