Skip to content
Memory corruption Disclosed report Advanced CVE-2026-4716

Uninitialized Tail Exposure After Resizable ArrayBuffer `transfer()`

Transferring a resizable ArrayBuffer to a smaller length left the hidden grow area uninitialised, and a later resize exposed those stale bytes to JavaScript. An attacker could read leftover memory contents through a typed array or DataView.

pwn2addr Follow

Originally disclosed on Mozilla

  • Fixed in 7 days
  • Paid in 9 days
  • Disclosed after 7 days

Created attachment 9547177 index.html

User Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/145.0.0.0 Safari/537.36

Steps to reproduce:

Uninitialized Tail Exposure After Resizable ArrayBuffer transfer()

Summary

When ArrayBuffer.prototype.transfer() is used on a resizable buffer with a smaller target length, the destination backing store can keep uninitialized bytes in the hidden grow area. A later resize() growth makes those bytes visible to JS.

Repro Shape

  1. Create a resizable buffer: new ArrayBuffer(16, { maxByteLength: 80 })
  2. Transfer to a smaller/same length: transfer(8) or transfer(16)
  3. Grow back: resize(80)

Observed: non-zero bytes show up in the expanded tail
Example: 77,77,77,77,77,77,254,255,...

Control case: plain resize shrink/grow (without transfer) keeps tail bytes at zero.

Call Path

ArrayBuffer.prototype.transfer() enters:

  • js/src/vm/ArrayBufferObject.cpp:673 ArrayBufferObject::transferImpl
  • js/src/vm/ArrayBufferObject.cpp:679 ArrayBufferCopyAndDetach(..., PreserveResizability::Yes)

Resizable branch:

  • js/src/vm/ArrayBufferObject.cpp:520
  • js/src/vm/ArrayBufferObject.cpp:532 ResizableArrayBufferObject::copyAndDetach(...)
  • js/src/vm/ArrayBufferObject.cpp:2796 ResizableArrayBufferObject::copyAndDetach
  • js/src/vm/ArrayBufferObject.cpp:2809 ResizableArrayBufferObject::copy(...)

Vulnerable copy branch (newByteLength <= sourceByteLength):

  • js/src/vm/ArrayBufferObject.cpp:2656 createBufferAndData<FillContents::Uninitialized>(..., newMaxByteLength, ...)
  • js/src/vm/ArrayBufferObject.cpp:2662 only [0..newByteLength) is copied from source

Important detail: for resizable buffers, allocation is sized to maxByteLength (js/src/vm/ArrayBufferObject.cpp:2563), not just current byteLength.

Root Cause

The bug is an invariant mismatch between copy-time initialization and grow-time assumptions.

Copy-time behavior:

  • The transfer-shrink path allocates with FillContents::Uninitialized.
  • Only the prefix is copied.
  • The remainder [newByteLength .. maxByteLength) is left uninitialized.

Grow-time behavior:

  • ResizableArrayBufferObject::resize does not zero-fill on growth.
  • It assumes growth regions are already zeroed by initial allocation or by a previous shrink.
  • See js/src/vm/ArrayBufferObject.cpp:1352 to js/src/vm/ArrayBufferObject.cpp:1355.

Those assumptions are true for normal resize-only flows, but false for this transfer-shrink copy path.

Code Contrast

Uninitialized transfer-shrink copy:

C++
auto [buffer, toFill] = createBufferAndData<FillContents::Uninitialized>(
    cx, newByteLength, newMaxByteLength, metadata, nullptr);
std::uninitialized_copy_n(source->dataPointer(), newByteLength, toFill);

js/src/vm/ArrayBufferObject.cpp:2656

Grow path that skips zeroing:

C++
// Clear only on shrink.
if (newByteLength < oldByteLength) {
  memset(dataPointer() + newByteLength, 0, oldByteLength - newByteLength);
}

js/src/vm/ArrayBufferObject.cpp:1352

One side creates uninitialized tail bytes, the other side assumes tail bytes are already safe.

Why the Control Case Looks Correct

In resize-only workflows, shrink explicitly clears truncated bytes:

  • js/src/vm/ArrayBufferObject.cpp:1359

So when the buffer is grown later, the no-zero-on-grow rule is still safe. transfer(shrink) bypasses that safety guarantee.

Impact

  • Class: uninitialized memory exposure
  • Surface: JS-readable bytes via Uint8Array / DataView after growth
  • Conditions:
    • resizable ArrayBuffer
    • transfer(newLen) where newLen <= oldLen
    • later resize() growth

Fix Direction

Either of these fixes the invariant:

  1. Use FillContents::Zero in the transfer-shrink copy path.
  2. Keep uninitialized allocation, but explicitly memset(0) for [newByteLength .. maxByteLength) before exposing the new buffer.

The key requirement is that grow-time assumptions must always remain true.

Actual results:

Memory Leak

Expected results:

Not Memory Leak

The original report as published on Mozilla's Bugzilla, by Pwn2addr. Images and videos are our own copies; raw HTML is shown as text. View it on Mozilla's Bugzilla.

Not written yet. The AI write-up for this report has not been written yet. The Original tab links to the source.

How it worked

Root cause

The transfer-shrink copy path allocates the destination with uninitialised contents and copies only the prefix, while the resize growth path assumes the tail is already zeroed.

Impact

Uninitialised memory could be read by JavaScript after growth, potentially disclosing data left in the backing store; the report demonstrates the leak but does not show a full exploit.

What the attacker needed

Resizable ArrayBuffer support; attacker can run JavaScript in the engine

The fix

The transfer-shrink copy path should either zero-fill the allocation or explicitly clear the region between the new length and the maximum length before exposing the buffer.

How it was found

  1. Create a resizable ArrayBuffer with a maximum length larger than its initial length.
  2. Transfer it to a length equal to or smaller than the original.
  3. Resize the resulting buffer up to its maximum length.
  4. Read the expanded tail through a view and observe non-zero bytes.

Explained by bugbounty.wiki with AI from the original and checked against quotes from it; it can still be wrong. Read the original before relying on a detail.

Not written yet. The AI write-up for this report has not been written yet. The Original tab links to the source.

An ArrayBuffer is a block of memory that JavaScript code can read and write through views like Uint8Array. When the buffer was shrunk by copying it to a new one, the spare space beyond the copied part was never wiped, so growing it again revealed whatever was previously in memory. That leftover data could contain sensitive information from other parts of the program.

What is Memory corruption?

Native code reads or writes memory it should not: overflows, use-after-free, type confusion. The core of browser, kernel and parser bugs.

More by pwn2addr

View all

71 more disclosed reports, best first.

More from Mozilla

View all

The newest disclosed reports for this program.

Similar reports

View all

Same bug class and techniques, clearest first.

Memory corruption

The lesson behind this report.

Native code reads or writes memory it should not: overflows, use-after-free, type confusion. The core of browser, kernel and parser bugs.