fix(ext/node): fix Buffer.concat, expose internal/buffer, implement markAsUntransferable#32760
Merged
bartlomieju merged 5 commits intomainfrom Mar 17, 2026
Merged
fix(ext/node): fix Buffer.concat, expose internal/buffer, implement markAsUntransferable#32760bartlomieju merged 5 commits intomainfrom
bartlomieju merged 5 commits intomainfrom
Conversation
…length Use TypedArrayPrototypeGetByteLength instead of .length in Buffer.concat() to prevent spoofed length getters from causing uninitialized memory exposure. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Register internal/buffer as a requireable internal module and export utf8Write from it, enabling test-buffer-write-fast.js. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
…ansferable Add op_mark_as_untransferable using V8's set_detach_key to make ArrayBuffers truly non-transferable (both via postMessage and ArrayBuffer.prototype.transfer()). Apply it to the Buffer pool and implement worker_threads.markAsUntransferable(). Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
kajukitli
approved these changes
Mar 16, 2026
Contributor
kajukitli
left a comment
There was a problem hiding this comment.
Reviewed with full repo context. Initial findings didn't hold up on closer inspection. Looks good.
nathanwhit
reviewed
Mar 17, 2026
ext/node/ops/buffer.rs
Outdated
| scope: &mut v8::PinScope<'_, '_>, | ||
| ab: v8::Local<v8::ArrayBuffer>, | ||
| ) { | ||
| let key = v8::String::new(scope, "untransferable").unwrap(); |
Member
There was a problem hiding this comment.
could use v8_static_strings here
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
Fixes 3 Buffer compat tests from #32706 and fixes #31824.
TypedArrayPrototypeGetByteLengthinstead of.lengthto prevent spoofed length getters from causing uninitialized memory exposureutf8Writeset_detach_keyAPI. Applied to the Buffer pool soArrayBuffer.prototype.transfer()throwsTypeErrorinstead of detaching the shared pool. This prevents the bug where transferring a Buffer's backing store would break all subsequentBuffer.from()calls (Bufferis totally broken in the presence of transferable buffers #31824)Enabled tests
test-buffer-concat.jstest-buffer-write-fast.jstest-buffer-pool-untransferable.jsCloses #31824
Test plan
./x test-compatBufferis totally broken in the presence of transferable buffers #31824 repro no longer reproduces🤖 Generated with Claude Code