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

Type confusion in V8 (CVE-2026-85046)

A type confusion in V8's Maglev compiler allows an array's elements kind to change during a sort callback, leaving a Smi-elements array containing HeapObjects. This can lead to a use-after-free and arbitrary read/write within the V8 heap.

Salvatore Gulizia Follow

Originally disclosed on Chrome VRP

Bounty$1,000 High View original
  • Fix shipped in 31 days

REPRODUCTION CASE

Tested with a Linux x64 ASAN d8 built from V8 commit 95c55cd89dafc0b7b2f9631c009bffc71183a2d8.

Run:

Shell
/path/to/v8/out/x64.asan.report/d8 \
  --disable-in-process-stack-traces \
  --allow-natives-syntax ./poc.js

Binary SHA-256:

Text
2fd100a8386d4a1be152e1150550e7e3ecf3e28fb1e6ee78dd5d9e01ddef9103  d8

VULNERABILITY DETAILS

Maglev can inline Array.prototype.sort with polymorphic feedback containing both PACKED_SMI_ELEMENTS and PACKED_ELEMENTS. It unions those maps to PACKED_ELEMENTS and snapshots the receiver's HeapObjects before calling the comparison function.

The callback can run receiver.fill(0), changing the live receiver to PACKED_SMI_ELEMENTS. The post-callback guard accepts that map because it belongs to the original polymorphic set. Copy-back then restores the saved HeapObjects without changing the receiver back to an object-elements map.

The result is a Smi-elements array containing HeapObjects. Smi-only consumers expose compressed object addresses and can move those objects without write barriers. The resulting generational use-after-free was independently developed into reliable arbitrary read/write within the V8 heap.

Affected code path

Text
Array.prototype.sort
 -> MaglevGraphBuilder::TryReduceArrayPrototypeSort
 -> collect PACKED_SMI_ELEMENTS and PACKED_ELEMENTS maps
 -> union representation to PACKED_ELEMENTS
 -> snapshot receiver into a temporary FixedArray
 -> invoke attacker-controlled comparison callback
 -> callback migrates receiver to PACKED_SMI_ELEMENTS
 -> CheckMaps accepts any map from the original polymorphic set
 -> copy saved HeapObjects into the Smi-elements receiver

Verified at current V8 commit 95c55cd89dafc0b7b2f9631c009bffc71183a2d8:

The unsafe guard/copy-back sequence is:

C++
RETURN_IF_ABORT(AddNewNode<CheckMaps>(
    {receiver}, receiver_maps_before_loop,
    CheckType::kOmitHeapObjectCheck));

// The receiver may now have PACKED_SMI_ELEMENTS.
GET_VALUE_OR_ABORT(writable_elements,
                   BuildLoadElements(receiver, elements_kind));
RETURN_IF_ABORT(BuildCopyLoop(temp_array, writable_elements,
                              /*check_undefined=*/false));

Downstream operations trust the corrupted map:

Security impact

The bug leaks exact compressed object addresses and enables missing-barrier object moves. Controlled reclaim of the resulting stale in-cage pointer provides reliable arbitrary read/write within the V8 heap.

VERSION

The impossible representation was reproduced at both affected revisions. It was also reproduced from an ordinary page in stock Chrome 150 without V8 flags, native syntax, exposed GC, Sandbox APIs, or debugging APIs.

Maglev defaults to enabled at src/flags/flag-definitions.h:646 in current V8 and :625 in the Chrome 150 revision. Array.prototype.sort is installed unconditionally at src/init/bootstrapper.cc:2462-2463.

BISECTION

A source-semantic git bisect was run from known-good parent 5a0da6da91cabd4ebf725337b98e157f8d235f82 to affected descendant a48b78348d46ca248ad7080eb29bf4545378198b:

Shell
git bisect start a48b78348d46ca248ad7080eb29bf4545378198b \
  5a0da6da91cabd4ebf725337b98e157f8d235f82
git bisect run sh -c 'if git grep -q "TryReduceArrayPrototypeSort" -- src/maglev; then exit 1; fi; exit 0'

First bad commit:

Text
66a3f1e94d4b681bff6476a876067a3c79a853f0
Reland: [compiler] Inline Array.prototype.sort in Maglev and Turbofan
Cr-Commit-Position: refs/heads/main@{#106837}

The reland introduces the vulnerable Maglev reducer. Its direct parent does not contain TryReduceArrayPrototypeSort. This is a source-level boundary; archived browser binaries were not runtime-bisected.

EXPECTED RESULT

V8 preserves a valid elements representation or deoptimizes after the callback changes the receiver's elements kind.

ACTUAL RESULT / CRASH STATE

The Smi map passes the post-callback guard. Copy-back creates a Smi-array/HeapObject representation mismatch, and the deterministic downstream Smi consumer reaches:

Text
AddressSanitizer:DEADLYSIGNAL
ERROR: AddressSanitizer: SEGV on unknown address 0x0000010581a4
The signal is caused by a READ memory access.
#0 ... v8::internal::JSArray::AnythingToArrayLength(...)
#1 ... v8::internal::Accessors::ArrayLengthSetter(...)
#2 ... v8::internal::PropertyCallbackArguments::CallAccessorSetter(...)
#3 ... v8::internal::Runtime_StoreCallbackProperty(...)

ATTACHMENTS

  • poc.js: minimal deterministic ASAN crash reproducer.
  • asan.log: complete symbolized crash output.

CREDIT INFORMATION

Reporter credit:

Text
Salvatore Gulizia (nickname: Serotav)

The original report as published on the Chromium issue tracker, by Salvatore Gulizia (nickname: Serotav). 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. 7 min read.

Context

V8 is the JavaScript engine used by Chrome, and Maglev is one of its optimising compilers. Maglev can inline built-in array methods when the feedback it has collected about a call site is simple enough. Array.prototype.sort is one of those built-ins: when the receiver's elements maps are known, Maglev can snapshot the receiver's elements, call the user-supplied comparison function, and then copy the saved elements back into the receiver.

This report describes a type confusion in that inlining path. When the comparison callback changes the receiver's elements kind during the sort, the post-callback guard still accepts the new map, and the copy-back writes HeapObjects into an array that is now typed as Smi elements. The result is an array whose map and contents disagree, which downstream Smi-only code trusts.

The issue is tracked as CVE-2026-85046, rated high severity, in the Google Chrome program (Chrome VRP). The reporter is Salvatore Gulizia (nickname Serotav), and the bounty was 1000.00 USD. It was disclosed on 2026-09-03.

Setup

The reproduction was tested with a Linux x64 ASAN build of d8, the V8 shell, built from V8 commit [redacted]. The binary used had this SHA-256:

Text
[redacted]  d8

The crash was reproduced with a minimal script, poc.js, run with two flags: one to disable in-process stack traces and one to allow native syntax. The full crash output was kept as asan.log.

The impossible representation was reproduced at both affected revisions listed below. It was also reproduced from an ordinary page in stock Chrome 150, without V8 flags, native syntax, exposed GC, Sandbox APIs or debugging APIs. That last point matters: the bug is reachable from normal web content, not only from a debug shell.

Finding it

The starting observation is about how Maglev handles polymorphic feedback for Array.prototype.sort. If the feedback contains both PACKED_SMI_ELEMENTS and PACKED_ELEMENTS, Maglev unions those maps to PACKED_ELEMENTS and snapshots the receiver's HeapObjects before calling the comparison function.

The comparison function is attacker-controlled JavaScript, and it runs while the sort is in progress. It can call receiver.fill(0), which migrates the live receiver to PACKED_SMI_ELEMENTS. When control returns, the post-callback guard checks the receiver's map against the original polymorphic set. The Smi map is in that set, so the guard passes. Copy-back then restores the saved HeapObjects into the receiver without changing it back to an object-elements map.

The outcome is a Smi-elements array that contains HeapObjects. Smi-only consumers then expose compressed object addresses, and can move those objects without write barriers. The reporter developed the resulting generational use-after-free into reliable arbitrary read/write within the V8 heap.

The affected code path, as given in the report:

Text
Array.prototype.sort
 -> MaglevGraphBuilder::TryReduceArrayPrototypeSort
 -> collect PACKED_SMI_ELEMENTS and PACKED_ELEMENTS maps
 -> union representation to PACKED_ELEMENTS
 -> snapshot receiver into a temporary FixedArray
 -> invoke attacker-controlled comparison callback
 -> callback migrates receiver to PACKED_SMI_ELEMENTS
 -> CheckMaps accepts any map from the original polymorphic set
 -> copy saved HeapObjects into the Smi-elements receiver

The reporter verified this at commit [redacted] and pointed at the following locations:

  • src/maglev/maglev-graph-builder.cc:9845-9854: TryReduceArrayPrototypeSort collects the receiver maps.
  • src/maglev/maglev-reducer-inl.h:884-895: CanInlineArrayIteratingBuiltin unions packed Smi and packed object representations.
  • src/maglev/maglev-graph-builder.cc:9967-10001 and :10077-10096: the reducer snapshots the elements, then enters the re-entrant callback.
  • src/maglev/maglev-graph-builder.cc:10165-10212: the guard accepts the original map set, then copy-back uses the union representation.

Exploitation

Step 1: build and run the reproducer

The crash was produced with the ASAN d8 binary and the minimal script:

Shell
/path/to/v8/out/x64.asan.report/d8 \
  --disable-in-process-stack-traces \
  --allow-natives-syntax ./poc.js

The report gives the two flags but does not explain what each one does. The script itself is not reproduced in the report; it is listed as an attachment, poc.js, described as a minimal deterministic ASAN crash reproducer.

Step 2: trigger the inlining and the callback

The report does not show the script, so how it produces the feedback is not described. Maglev then inlines the sort, unions the maps to PACKED_ELEMENTS, and snapshots the receiver's HeapObjects into a temporary FixedArray. The comparison callback runs receiver.fill(0), which changes the live receiver to PACKED_SMI_ELEMENTS.

Step 3: pass the guard and copy back

The unsafe guard and copy-back sequence in the reducer is:

C++
RETURN_IF_ABORT(AddNewNode<CheckMaps>(
    {receiver}, receiver_maps_before_loop,
    CheckType::kOmitHeapObjectCheck));

// The receiver may now have PACKED_SMI_ELEMENTS.
GET_VALUE_OR_ABORT(writable_elements,
                   BuildLoadElements(receiver, elements_kind));
RETURN_IF_ABORT(BuildCopyLoop(temp_array, writable_elements,
                              /*check_undefined=*/false));

The CheckMaps node is given receiver_maps_before_loop, the original polymorphic set. Because the Smi map is a member of that set, the check passes even though the receiver has changed kind. The copy loop then writes the saved HeapObjects into the receiver's now-Smi elements.

Step 4: reach a Smi-only consumer

Downstream operations trust the corrupted map. The report names two consequences:

  • src/objects/elements.cc:4440-4450: the packed-Smi typed-array path applies Smi::ToInt to the hidden HeapObject.
  • src/maglev/maglev-reducer-inl.h:561-576 and src/objects/elements.cc:2841-2848: Smi-specialised stores and moves can omit write barriers.

The deterministic downstream Smi consumer reaches this crash state:

Text
AddressSanitizer:DEADLYSIGNAL
ERROR: AddressSanitizer: SEGV on unknown address 0x0000010581a4
The signal is caused by a READ memory access.
#0 ... v8::internal::JSArray::AnythingToArrayLength(...)
#1 ... v8::internal::Accessors::ArrayLengthSetter(...)
#2 ... v8::internal::PropertyCallbackArguments::CallAccessorSetter(...)
#3 ... v8::internal::Runtime_StoreCallbackProperty(...)

The stack shows the path through the array length setter and the property store runtime, which is where the corrupted representation is consumed.

Step 5: turn the corruption into read/write

The report states that the generational use-after-free was independently developed into reliable arbitrary read/write within the V8 heap. The mechanism is the combination of leaked compressed object addresses and object moves performed without write barriers, followed by controlled reclaim of the resulting stale in-cage pointer. The report does not include the exploit code for this stage.

Root cause

The mistake is in the Maglev reducer for Array.prototype.sort. The reducer unions the receiver's polymorphic maps to a single representation (PACKED_ELEMENTS) and snapshots the elements before the callback. After the callback, it checks the receiver's map against the original polymorphic set rather than against the representation it actually used for the snapshot and copy-back. Because the callback can migrate the receiver to any map in that set, including PACKED_SMI_ELEMENTS, the guard accepts a receiver whose elements kind no longer matches the union representation. The copy-back then writes HeapObjects into Smi elements.

The existing defence, the CheckMaps guard, is the wrong check for this situation: it validates membership in the original set, not consistency with the representation used by the copy-back. The reducer's own comment, // The receiver may now have PACKED_SMI_ELEMENTS., notes that the receiver may have changed kind.

Impact

The bug leaks exact compressed object addresses and enables object moves without write barriers. Controlled reclaim of the resulting stale in-cage pointer provides reliable arbitrary read/write within the V8 heap. That is the reporter's stated impact; the report does not describe a full sandbox escape or a renderer-to-browser exploit chain.

The conditions are narrow but reachable from normal content: the sort call site must have polymorphic feedback containing both PACKED_SMI_ELEMENTS and PACKED_ELEMENTS, and the comparison callback must change the receiver's elements kind. The reporter reproduced the impossible representation from an ordinary page in stock Chrome 150 without V8 flags, native syntax, exposed GC, Sandbox APIs or debugging APIs, so the precondition is met by ordinary JavaScript.

Fix

The expected result it states is that V8 preserves a valid elements representation or deoptimises after the callback changes the receiver's elements kind. A fix would need to make the post-callback guard check the representation used for the snapshot and copy-back, or deoptimise when the receiver's map no longer matches that representation.

Variants to test

  1. Other inlined array built-ins with re-entrant callbacks. Maglev inlines several array-iterating built-ins through CanInlineArrayIteratingBuiltin. Try callbacks that change the receiver's elements kind during forEach, map, filter or similar, and look for a map/contents mismatch after the built-in returns. A positive result is a Smi-elements array holding HeapObjects, visible as a crash in a Smi-only consumer or as a wrong value read back.
  2. Other polymorphic map unions. The bug depends on the union of PACKED_SMI_ELEMENTS and PACKED_ELEMENTS. Try feedback sets that mix other elements kinds, such as PACKED_DOUBLE_ELEMENTS with PACKED_ELEMENTS, and check whether the guard accepts a map outside the representation used for the copy-back. A positive result is a value of one representation being read as another.
  3. Callbacks that change the receiver's length or backing store. The report only shows fill(0). Try callbacks that shrink or grow the array, or replace its elements, during the sort. A positive result is an out-of-bounds read or write, or a crash in the copy loop.
  4. Turbofan. The first bad commit is titled Reland: [compiler] Inline Array.prototype.sort in Maglev and Turbofan. Try the same reproducer with Maglev disabled and Turbofan enabled. A positive result is the same representation mismatch or crash.
  5. Stock Chrome without flags. The reporter reproduced the representation mismatch from an ordinary page in stock Chrome 150. Try the same script in a normal renderer, without native syntax, and check for the same crash or for observable corruption. A positive result is a crash or a wrong value in a page that uses only standard JavaScript.

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

Chrome runs web pages using a program inside it called V8. V8 reads JavaScript, the language most web pages are written in, and turns it into instructions the computer can carry out. To make pages fast, V8 contains several compilers, which are programs that rewrite JavaScript into faster machine-level instructions. One of these compilers is called Maglev.

Maglev has a shortcut. When the feedback it has collected about a sort call site is simple enough, it can replace the call to the built-in sorting function with its own faster version of the sorting steps. This shortcut is called inlining: the compiler copies the body of the built-in function directly into the optimised code instead of calling it.

The shortcut has a flaw. Before it calls the page's own comparison function (the small function the page supplies to decide the order of items), Maglev saves a copy of the array's contents. After the comparison function returns, Maglev checks that the array still looks the way it expected, then writes the saved contents back. But the comparison function is ordinary JavaScript supplied by the page, and it can change the array while the sort is running. If it does, the check still passes, and the saved contents are written back into an array that is now described differently. The array ends up claiming to hold plain numbers while actually holding references to objects. Later code trusts that claim, reads the references as if they were numbers, and the program crashes or can be made to misbehave in a controlled way.

This is called a type confusion: a value of one kind is treated as a value of another kind. The issue is tracked as CVE-2026-85046, rated high severity, in the Google Chrome program (Chrome VRP). The reporter is Salvatore Gulizia (nickname Serotav), and the bounty was 1000.00 USD. It was disclosed on 2026-09-03.

Background: the pieces involved

Before the details make sense, here are the moving parts, explained from scratch.

  • JavaScript engine: the part of a browser that reads JavaScript and executes it. Chrome's engine is V8. Other browsers use other engines.
  • Compiler: a program that translates code from one form into another, usually into faster instructions. V8 has several, including a simple one that runs code immediately and optimising ones that rewrite hot code for speed.
  • Maglev: one of V8's optimising compilers. It sits between the fastest-to-start compiler and the most aggressive one.
  • Inlining: replacing a call to a function with a copy of that function's body, so the computer does not have to pay the cost of a call. It is like a recipe that says "add salt" being rewritten to say "take the salt shaker, open it, sprinkle" so the cook does not have to look up another recipe.
  • Array: an ordered list of values in JavaScript, written with square brackets, for example [1, 2, 3].
  • Array.prototype.sort: the built-in function that sorts an array. It accepts an optional comparison function that decides the order of two items.
  • Comparison callback: the function the page passes to sort. The sort calls it repeatedly, once per pair of items it needs to compare. Because it is page-supplied code, it can do anything, including modifying the array being sorted.
  • Elements kind: V8's internal label for what an array currently holds. Examples include PACKED_SMI_ELEMENTS (a dense array of small integers, called Smis) and PACKED_ELEMENTS (a dense array of arbitrary objects). The label is stored in a small metadata object called a map.
  • Map: V8's internal description of an object's shape and type. It is not a geographical map; think of it as a label on a box saying what is inside.
  • Smi: a small integer that V8 stores directly inside a slot, without a separate object. Smis are cheap.
  • HeapObject: any object stored in V8's heap, the region of memory where JavaScript objects live. A HeapObject is referenced by a pointer.
  • Compressed pointer: V8 stores object references in a compact form, using fewer bits than a full memory address. The compact form is called a compressed pointer.
  • Write barrier: a small piece of bookkeeping the engine performs when it stores a pointer to an object, so that its garbage collector knows the object is still in use. Skipping it can let the collector free an object that is still referenced.
  • Garbage collector: the part of the engine that reclaims memory no longer in use.
  • Use-after-free: a bug where memory is freed and then still used. The program reads or writes memory that no longer belongs to it.
  • Type confusion: a bug where a value of one type is treated as a value of another type. The program's assumptions about the value are wrong.
  • Polymorphic feedback: V8 records what kinds of values it has seen at a particular place in the code. If it has seen more than one kind, the feedback is called polymorphic. Think of a shopkeeper who has seen customers pay with cash and with cards, and now keeps both a cash drawer and a card terminal ready.
  • Guard: a check inserted by the compiler to confirm an assumption before using optimised code. If the check fails, the program falls back to slower, safer code, a process called deoptimisation.
  • Deoptimise: abandon optimised code and return to the general, slower version.
  • ASAN: AddressSanitizer, a tool that detects memory errors in programs. It is used during development, not in normal browsers.
  • d8: the standalone command-line shell that ships with V8. Developers use it to run JavaScript outside a browser.
  • Commit: a saved snapshot of a source code repository at a particular point in time, identified by a long hexadecimal string.
  • SHA-256: a fingerprint of a file's contents. Two files with the same SHA-256 are almost certainly identical.
  • Bisect: a search technique that repeatedly halves a range to find the first bad change. git bisect automates this for a source repository.
  • Reland: a change that was previously reverted and is being applied again.
  • Turbofan: another of V8's optimising compilers, more aggressive than Maglev.
  • CVE: a public identifier for a known security vulnerability.
  • Chrome VRP: Chrome's Vulnerability Reward Program, which pays researchers for reporting bugs.

Context

V8 is the JavaScript engine used by Chrome, and Maglev is one of its optimising compilers. Maglev can inline built-in array methods when the feedback it has collected about a call site is simple enough. Array.prototype.sort is one of those built-ins: when the receiver's elements maps are known, Maglev can snapshot the receiver's elements, call the user-supplied comparison function, and then copy the saved elements back into the receiver.

This report describes a type confusion in that inlining path. When the comparison callback changes the receiver's elements kind during the sort, the post-callback guard still accepts the new map, and the copy-back writes HeapObjects into an array that is now typed as Smi elements. The result is an array whose map and contents disagree, which downstream Smi-only code trusts.

It was disclosed on 2026-09-03.

Setup

The reproduction was tested with a Linux x64 ASAN build of d8, the V8 shell, built from V8 commit [redacted]. The binary used had this SHA-256:

Text
[redacted]  d8

This block is a fingerprint of the exact d8 program the reporter used. The long hexadecimal string is the SHA-256 hash, and d8 is the file name. Anyone who builds the same commit and gets the same hash is running the same program, which makes the result reproducible.

The crash was reproduced with a minimal script, poc.js, run with two flags: one to disable in-process stack traces and one to allow native syntax. The full crash output was kept as asan.log.

The impossible representation was reproduced at both affected revisions listed below. It was also reproduced from an ordinary page in stock Chrome 150, without V8 flags, native syntax, exposed GC, Sandbox APIs or debugging APIs. That last point matters: the bug is reachable from normal web content, not only from a debug shell.

Finding it

The starting observation is about how Maglev handles polymorphic feedback for Array.prototype.sort. If the feedback contains both PACKED_SMI_ELEMENTS and PACKED_ELEMENTS, Maglev unions those maps to PACKED_ELEMENTS and snapshots the receiver's HeapObjects before calling the comparison function.

In plain terms: the compiler has seen the same sort call work on arrays of small integers and on arrays of objects. It decides to handle both cases with one plan, treating the array as if it held objects. Before calling the page's comparison function, it copies the array's contents into a temporary holding area.

The comparison function is attacker-controlled JavaScript, and it runs while the sort is in progress. It can call receiver.fill(0), which migrates the live receiver to PACKED_SMI_ELEMENTS. When control returns, the post-callback guard checks the receiver's map against the original polymorphic set. The Smi map is in that set, so the guard passes. Copy-back then restores the saved HeapObjects into the receiver without changing it back to an object-elements map.

receiver.fill(0) is a standard JavaScript call that replaces every element of the array with the number zero. Because the array now contains only small integers, V8 relabels it as PACKED_SMI_ELEMENTS. The guard was supposed to catch this change, but it only checks whether the new label is one of the labels it saw before, and the Smi label is. So the guard waves it through, and the saved object references are written back into an array that now claims to hold only numbers.

The outcome is a Smi-elements array that contains HeapObjects. Smi-only consumers then expose compressed object addresses, and can move those objects without write barriers. The reporter developed the resulting generational use-after-free into reliable arbitrary read/write within the V8 heap.

A Smi-only consumer is code that assumes every element is a small integer and reads it as such. When it reads a HeapObject reference instead, it treats the reference's bits as a number, which leaks the address. A generational use-after-free is a use-after-free involving objects in different age groups of the garbage collector. Arbitrary read/write means the attacker can read and write any memory within the V8 heap, which is a serious escalation.

The affected code path, as given in the report:

Text
Array.prototype.sort
 -> MaglevGraphBuilder::TryReduceArrayPrototypeSort
 -> collect PACKED_SMI_ELEMENTS and PACKED_ELEMENTS maps
 -> union representation to PACKED_ELEMENTS
 -> snapshot receiver into a temporary FixedArray
 -> invoke attacker-controlled comparison callback
 -> callback migrates receiver to PACKED_SMI_ELEMENTS
 -> CheckMaps accepts any map from the original polymorphic set
 -> copy saved HeapObjects into the Smi-elements receiver

This block is a step-by-step trace of what happens inside V8. Line by line:

  1. Array.prototype.sort: the page calls the built-in sort.
  2. MaglevGraphBuilder::TryReduceArrayPrototypeSort: Maglev's code builder decides to inline the sort.
  3. collect PACKED_SMI_ELEMENTS and PACKED_ELEMENTS maps: it gathers the labels it has seen for this call site.
  4. union representation to PACKED_ELEMENTS: it picks one plan, treating the array as holding objects.
  5. snapshot receiver into a temporary FixedArray: it copies the array's contents into a temporary array.
  6. invoke attacker-controlled comparison callback: it calls the page's comparison function.
  7. callback migrates receiver to PACKED_SMI_ELEMENTS: the callback changes the array so it now holds only small integers.
  8. CheckMaps accepts any map from the original polymorphic set: the guard passes because the new label was in the original set.
  9. copy saved HeapObjects into the Smi-elements receiver: the saved object references are written back into an array that now claims to hold numbers.

The reporter verified this at commit [redacted] and pointed at the following locations:

  • src/maglev/maglev-graph-builder.cc:9845-9854: TryReduceArrayPrototypeSort collects the receiver maps.
  • src/maglev/maglev-reducer-inl.h:884-895: CanInlineArrayIteratingBuiltin unions packed Smi and packed object representations.
  • src/maglev/maglev-graph-builder.cc:9967-10001 and :10077-10096: the reducer snapshots the elements, then enters the re-entrant callback.
  • src/maglev/maglev-graph-builder.cc:10165-10212: the guard accepts the original map set, then copy-back uses the union representation.

These are file names and line numbers in V8's source code. maglev-graph-builder.cc is the file where Maglev builds its optimised code. maglev-reducer-inl.h is a header file with helper code. The line ranges point at the exact code that does each step. A re-entrant callback is a callback that runs while the built-in function is still in progress, which is what allows it to interfere.

Exploitation

Step 1: build and run the reproducer

The crash was produced with the ASAN d8 binary and the minimal script:

Shell
/path/to/v8/out/x64.asan.report/d8 \
  --disable-in-process-stack-traces \
  --allow-natives-syntax ./poc.js

This is a shell command. Line by line:

  1. /path/to/v8/out/x64.asan.report/d8: the path to the d8 program. The x64.asan.report part of the path is the build directory, indicating a 64-bit build with ASAN enabled.
  2. --disable-in-process-stack-traces: a flag that turns off V8's own stack trace printing, so the crash output is clean for ASAN to symbolise.
  3. --allow-natives-syntax: a flag that lets the script use V8's special internal syntax, which the reproducer relies on.
  4. ./poc.js: the script to run.

--disable-in-process-stack-traces keeps the crash output clean for ASAN symbolisation, and --allow-natives-syntax lets the script use V8's native syntax, which the reproducer relies on. The script itself is not reproduced in the report; it is listed as an attachment, poc.js, described as a minimal deterministic ASAN crash reproducer.

Step 2: trigger the inlining and the callback

The script arranges for the sort call site to see polymorphic feedback containing both PACKED_SMI_ELEMENTS and PACKED_ELEMENTS. Maglev then inlines the sort, unions the maps to PACKED_ELEMENTS, and snapshots the receiver's HeapObjects into a temporary FixedArray. The comparison callback runs receiver.fill(0), which changes the live receiver to PACKED_SMI_ELEMENTS.

Maglev has already inlined the sort based on the earlier feedback, so the callback runs inside the inlined code and changes the array's label mid-sort.

Step 3: pass the guard and copy back

The unsafe guard and copy-back sequence in the reducer is:

C++
RETURN_IF_ABORT(AddNewNode<CheckMaps>(
    {receiver}, receiver_maps_before_loop,
    CheckType::kOmitHeapObjectCheck));

// The receiver may now have PACKED_SMI_ELEMENTS.
GET_VALUE_OR_ABORT(writable_elements,
                   BuildLoadElements(receiver, elements_kind));
RETURN_IF_ABORT(BuildCopyLoop(temp_array, writable_elements,
                              /*check_undefined=*/false));

This is C++ code from V8's source. Line by line:

  1. RETURN_IF_ABORT(AddNewNode<CheckMaps>(: add a guard node to the optimised code. If the guard fails, the code aborts and deoptimises.
  2. {receiver}, receiver_maps_before_loop,: the guard checks the receiver against the set of maps collected before the loop, that is, the original polymorphic set.
  3. CheckType::kOmitHeapObjectCheck));: a detail of the check that skips a redundant object check.
  4. // The receiver may now have PACKED_SMI_ELEMENTS.: a comment acknowledging that the callback may have changed the array's label.
  5. GET_VALUE_OR_ABORT(writable_elements,: fetch the array's current elements storage.
  6. BuildLoadElements(receiver, elements_kind));: load the elements using the elements kind.
  7. RETURN_IF_ABORT(BuildCopyLoop(temp_array, writable_elements,: build a loop that copies the saved contents back.
  8. /*check_undefined=*/false));: a flag telling the copy loop not to check for undefined values.

The CheckMaps node is given receiver_maps_before_loop, the original polymorphic set. Because the Smi map is a member of that set, the check passes even though the receiver has changed kind. The copy loop then writes the saved HeapObjects into the receiver's now-Smi elements.

Step 4: reach a Smi-only consumer

Downstream operations trust the corrupted map. The report names two consequences:

  • src/objects/elements.cc:4440-4450: the packed-Smi typed-array path applies Smi::ToInt to the hidden HeapObject.
  • src/maglev/maglev-reducer-inl.h:561-576 and src/objects/elements.cc:2841-2848: Smi-specialised stores and moves can omit write barriers.

The first consequence is that code which expects a small integer calls Smi::ToInt on what is actually an object reference. Smi::ToInt extracts the integer bits from the value, so it returns the object's address as if it were a number. The second consequence is that stores and moves of Smi values skip the write barrier, because Smis do not need one. When the value is actually an object reference, the barrier is skipped when it should not be, and the garbage collector can later free an object that is still referenced.

The deterministic downstream Smi consumer reaches this crash state:

Text
AddressSanitizer:DEADLYSIGNAL
ERROR: AddressSanitizer: SEGV on unknown address 0x0000010581a4
The signal is caused by a READ memory access.
#0 ... v8::internal::JSArray::AnythingToArrayLength(...)
#1 ... v8::internal::Accessors::ArrayLengthSetter(...)
#2 ... v8::internal::PropertyCallbackArguments::CallAccessorSetter(...)
#3 ... v8::internal::Runtime_StoreCallbackProperty(...)

This is ASAN's crash report. Line by line:

  1. AddressSanitizer:DEADLYSIGNAL: ASAN reports a fatal signal.
  2. ERROR: AddressSanitizer: SEGV on unknown address 0x0000010581a4: a segmentation fault occurred at that address. A segmentation fault is the operating system stopping a program that tried to access memory it is not allowed to.
  3. The signal is caused by a READ memory access.: the program was trying to read memory when it crashed.
  4. #0 ... v8::internal::JSArray::AnythingToArrayLength(...): the innermost function on the stack, which converts a value to an array length.
  5. #1 ... v8::internal::Accessors::ArrayLengthSetter(...): the function that sets an array's length.
  6. #2 ... v8::internal::PropertyCallbackArguments::CallAccessorSetter(...): the code that calls the setter.
  7. #3 ... v8::internal::Runtime_StoreCallbackProperty(...): the runtime function that stores a property.

The stack shows the path through the array length setter and the property store runtime, which is where the corrupted representation is consumed.

Step 5: turn the corruption into read/write

The report states that the generational use-after-free was independently developed into reliable arbitrary read/write within the V8 heap. The mechanism is the combination of leaked compressed object addresses and object moves performed without write barriers, followed by controlled reclaim of the resulting stale in-cage pointer. The report does not include the exploit code for this stage.

In plain terms, the leaked addresses tell the attacker where objects live. The missing write barriers let objects be moved without the garbage collector noticing. The attacker then arranges for the freed memory to be reused with controlled contents, so the stale pointer now points at data the attacker controls. That gives read and write access within the heap.

Root cause

The mistake is in the Maglev reducer for Array.prototype.sort. The reducer unions the receiver's polymorphic maps to a single representation (PACKED_ELEMENTS) and snapshots the elements before the callback. After the callback, it checks the receiver's map against the original polymorphic set rather than against the representation it actually used for the snapshot and copy-back. Because the callback can migrate the receiver to any map in that set, including PACKED_SMI_ELEMENTS, the guard accepts a receiver whose elements kind no longer matches the union representation. The copy-back then writes HeapObjects into Smi elements.

The existing defence, the CheckMaps guard, is the wrong check for this situation: it validates membership in the original set, not consistency with the representation used by the copy-back. The reducer's own comment, // The receiver may now have PACKED_SMI_ELEMENTS., notes that the receiver may have changed kind.

Impact

The bug leaks exact compressed object addresses and enables object moves without write barriers. Controlled reclaim of the resulting stale in-cage pointer provides reliable arbitrary read/write within the V8 heap. That is the reporter's stated impact; the report does not describe a full sandbox escape or a renderer-to-browser exploit chain.

The conditions are narrow but reachable from normal content: the sort call site must have polymorphic feedback containing both PACKED_SMI_ELEMENTS and PACKED_ELEMENTS, and the comparison callback must change the receiver's elements kind. The reporter reproduced the impossible representation from an ordinary page in stock Chrome 150 without V8 flags, native syntax, exposed GC, Sandbox APIs or debugging APIs, so the precondition is met by ordinary JavaScript.

Fix

The report does not describe a fix. The expected result it states is that V8 preserves a valid elements representation or deoptimises after the callback changes the receiver's elements kind. A fix would need to make the post-callback guard check the representation used for the snapshot and copy-back, or deoptimise when the receiver's map no longer matches that representation.

Variants to test

  1. Other inlined array built-ins with re-entrant callbacks. Maglev inlines several array-iterating built-ins through CanInlineArrayIteratingBuiltin. Try callbacks that change the receiver's elements kind during forEach, map, filter or similar, and look for a map/contents mismatch after the built-in returns. A positive result is a Smi-elements array holding HeapObjects, visible as a crash in a Smi-only consumer or as a wrong value read back.
  2. Other polymorphic map unions. The bug depends on the union of PACKED_SMI_ELEMENTS and PACKED_ELEMENTS. Try feedback sets that mix other elements kinds, such as PACKED_DOUBLE_ELEMENTS with PACKED_ELEMENTS, and check whether the guard accepts a map outside the representation used for the copy-back. A positive result is a value of one representation being read as another.
  3. Callbacks that change the receiver's length or backing store. The report only shows fill(0). Try callbacks that shrink or grow the array, or replace its elements, during the sort. A positive result is an out-of-bounds read or write, or a crash in the copy loop.
  4. Turbofan. The first bad commit is titled Reland: [compiler] Inline Array.prototype.sort in Maglev and Turbofan. Try the same reproducer with Maglev disabled and Turbofan enabled. A positive result is the same representation mismatch or crash.
  5. Stock Chrome without flags. The reporter reproduced the representation mismatch from an ordinary page in stock Chrome 150. Try the same script in a normal renderer, without native syntax, and check for the same crash or for observable corruption. A positive result is a crash or a wrong value in a page that uses only standard JavaScript.

Glossary

  • AddressSanitizer (ASAN): a tool that detects memory errors in programs during development.
  • Array: an ordered list of values in JavaScript.
  • Array.prototype.sort: the built-in function that sorts an array, optionally using a comparison function.
  • Arbitrary read/write: the ability to read and write any memory within a given region, here the V8 heap.
  • Callback: a function passed to another function, to be called by it later.
  • Commit: a saved snapshot of a source code repository at a particular point in time.
  • Comparison callback: the function a page passes to sort to decide the order of two items.
  • Compiler: a program that translates code from one form into another, usually faster, form.
  • Compressed pointer: a compact form of an object reference that uses fewer bits than a full memory address.
  • Elements kind: V8's internal label for what an array currently holds, such as PACKED_SMI_ELEMENTS or PACKED_ELEMENTS.
  • Generational use-after-free: a use-after-free involving objects in different age groups of the garbage collector.
  • HeapObject: any object stored in V8's heap, referenced by a pointer.
  • Inlining: replacing a call to a function with a copy of that function's body.
  • JavaScript engine: the part of a browser that reads and executes JavaScript.
  • Maglev: one of V8's optimising compilers.
  • Polymorphic feedback: V8's record that a particular place in the code has seen more than one kind of value.
  • Re-entrant callback: a callback that runs while the built-in function that called it is still in progress.
  • Segmentation fault: the operating system stopping a program that tried to access memory it is not allowed to.
  • V8: the JavaScript engine used by Chrome.
  • Write barrier: bookkeeping the engine performs when it stores a pointer to an object, so the garbage collector knows the object is still in use.

More by Salvatore Gulizia

View all

5 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.