Skip to content

Conversation

@Mcsky23
Copy link

@Mcsky23 Mcsky23 commented Dec 27, 2025

Fixes #471

js_allocate_fast_array() used to set p->u.array.count = len immediately after allocation, regardless of the elements being uninitialised. If a GC pass runs during construction in methods that use this function (i.e. js_array_toReversed(), js_array_toSpliced(), js_array_toSorted(), js_array_with()), it could traverse uninitialised bytes and treat them as JSValues, potentially handling attacker-controlled leftover pointers.

The patch changes js_allocate_fast_array() to set p->u.array.count = 0 initially, leaving callers that update p->u.array.u.values[] to also increment this value progressively.

@Mcsky23 Mcsky23 changed the title fix fast-array GC traversal of uninitialized slots fix fast-array GC traversal of uninitialised slots Dec 27, 2025
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.

GC traversal of uninitialised fast-array backing store

1 participant