Repository navigation
Buffer#copy (and Buffer.concat) can read/write process memory on certain input #59985
Description
Activity
- changed the title
[-]Buffer.concat can return uninitialized memory on certain input[/-][+]Buffer#copy (and Buffer.concat) can read/write process memory on certain input[/+]on Sep 23, 2025 Note: this is not a security issue only because malicious js is not in the threat model
It's potentially still a way to circumvent things like
--permissions, which so far seem to have resulted in CVEs? Might be hard to achieve that reliably, but it's still a heap overflow at the end of the day.Reacted by Ruben Bridgewater@addaleax
--permissionsis documented to be circumventable: https://nodejs.org/api/permissions.htmlThis feature does not protect against malicious code. According to the Node.js Security Policy, Node.js trusts any code it is asked to run.
The permission model implements a "seat belt" approach, which prevents trusted code from unintentionally changing files or using resources that access has not explicitly been granted to. It does not provide security guarantees in the presence of malicious code. Malicious code can bypass the permission model and execute arbitrary code without the restrictions imposed by the permission model.
Might be hard to achieve that reliably,
Targeted read-writes should be pretty reliable for anything inside the area though
@ChALkeR Yeah, I wouldn't want to imply that
--permissionsis a security mechanism that I would personally rely on either 🙂Just pointing out that over the last few years, this type of thing seems to have been considered CVE-worthy. But I wasn't part of the conversations around that, so 🤷♀️
Reacted by Nikita Skovoroda- addedbufferIssues and PRs related to the buffer subsystem.Issues and PRs related to the buffer subsystem.
on Sep 27, 2025 - added a commit that references this issue
on Oct 15, 2025 cc @nodejs/security / @nodejs/security-wg just in case
github-actions commented
on May 14, 2026 on May 14, 2026 – with GitHub ActionsContributorMore actionsThis issue has been marked as stale due to 210 days of inactivity.
It will be automatically closed in 30 days if no further activity occurs. If this is still relevant, please leave a comment or update it to keep it open.- addedstaleIssues and PRs marked stale due to inactivity and scheduled for automatic closure.Issues and PRs marked stale due to inactivity and scheduled for automatic closure.
on May 14, 2026 Still relevant
- removedstaleIssues and PRs marked stale due to inactivity and scheduled for automatic closure.Issues and PRs marked stale due to inactivity and scheduled for automatic closure.
on May 15, 2026 github-actions commented
on Aug 14, 2026 on Aug 14, 2026 – with GitHub ActionsContributorMore actionsThis issue has been marked as stale due to 90 days of inactivity.
It will be automatically closed in 30 days if no further activity occurs. If this is still relevant, please leave a comment or update it to keep it open.- addedstaleIssues and PRs marked stale due to inactivity and scheduled for automatic closure.Issues and PRs marked stale due to inactivity and scheduled for automatic closure.
on Aug 14, 2026 github-actions commented
on Sep 14, 2026 on Sep 14, 2026 – with GitHub ActionsContributorMore actionsThis issue has been automatically closed after 30 days of inactivity following its stale status (no activity for a total of 120 days).
If this is still relevant, feel free to reopen it or leave a comment with additional details so we can continue the discussion.
Note: this is not a security issue only because malicious js is not in the threat model
While the input is deliberately invalid, returning uninitialized memory is highly unexpected
Note that this doesn't use any
Bufferapis except forBuffer.concat, i.e. doesn't call toallocUnsafeAlso the
Uint8Arrayinstance is non-pooledThis also happens even with
--zero-fill-buffersflagThe issue is on the native
_copysideAlso reproducible with
Buffer#copy:This also looks like a regression, it didn't happen in 20 or 22.6 but happens in >=22.7 and 24
A sufficiently larger length causes a bus error 😉
Reading env vars
With
Buffer.concat:With
Buffer#copy:The same code could write to process memory, not just read from it
E.g. this will cause a guard failure (which can be obviously bypassed by reading it first)
Reading then writing could also control which exact portions of process memory to overwrite