But You Told Me You Were Safe: Attacking The Mozilla Firefox Renderer (Part 1)
A prototype pollution flaw in Firefox's top-level await implementation let a malicious module leak an internal Module object and call unsafe methods, leading to memory corruption and renderer code execution. An attacker could then use the corruption to build read/write primitives and run shellcode.
Published on zerodayinitiative.com
Vulnerabilities and exploits in common targets like browsers are often associated with memory safety issues. Typically this involves either a direct error in memory management or a way to corrupt internal object state in the JavaScript engine.
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 write-up covers the first vulnerability in the exploit chain that Manfred Paul used to compromise the Mozilla Firefox browser at Pwn2Own Vancouver 2022. The target is the Firefox renderer process, and the vulnerable code lives in SpiderMonkey, Firefox's JavaScript engine. The bug is tracked as CVE-2022-1802 and as ZDI-22-799 on the Zero Day Initiative advisory page. Mozilla fixed it in Firefox 100.0.2 through Mozilla Foundation Security Advisory 2022-19.
The feature involved is top level await, the part of the JavaScript module system that allows an asynchronous module to be awaited. In SpiderMonkey, large parts of this feature are implemented in built-in JavaScript code rather than in C++. The report notes that this is true for most JavaScript-based functions in Firefox. The specific function discussed is in /js/src/builtin/Module.js, and the report links to it at revision [redacted].
The author notes that the blog series relies heavily on the details Manfred Paul provided at the Pwn2Own competition. The chain used some memory corruptions, but the vulnerable code was written in a memory-safe language, JavaScript. Both vulnerabilities in the chain were related to prototypes. This first one is a prototype pollution vulnerability in the await implementation.
Setup
No accounts, roles or special tooling are described. The precondition for the bug is a website that can run JavaScript in the Firefox renderer, specifically code imported as a module from another file. The trigger snippet only works when imported as a module from another file, and the last line exists solely to mark the module as asynchronous, which is needed to trigger the bug.
Finding it
The researcher examined the built-in JavaScript implementation of top level await in /js/src/builtin/Module.js. The report lists three facts about the relevant function that make it interesting:
- The function runs in the same JavaScript context as the user's code. Global state, including prototypes of global objects, is shared between this built-in code and untrusted website code.
- The function has a default argument of
execList = []. In practice it is called without specifying this argument, except for the recursive call inside the function itself. A new empty array object is therefore constructed for the argument, and like any ordinary array it has the unique objectArray.prototypeas its prototype. - The function invokes
std_Array_pushon this array object. That leads to a call to theArray.prototype.pushJavaScript method. Usingstd_Array_pushinstead ofArray.prototype.pushhelps prevent side effects up to a certain point, but the function can still interact with the object's prototype.
The report contrasts this with other places in the same file where a different function, DefineDataProperty, is used to assign array values. DefineDataProperty is safe and will not interact in any way with the object's prototype.
The semantics of Array.prototype.push with a single argument are roughly equivalent to an assignment. The assignment is not just the definition of a data property on the object itself: it searches the object's prototype chain for existing properties as per usual JavaScript semantics. If the imported module defines a getter or setter for property 0 on Array.prototype, the assignment triggers the setter. The report notes that this call technically violates the ECMAScript specification, which defines GatherAsyncParentCompletions in terms of abstract lists and not actual JavaScript arrays.
The crucial side effect is that the setter receives the value being assigned, which leaks a module object. The report calls this value "m" and describes it as representing a module. This object is not the same as the module namespace returned by import(). It is an internal type of the JavaScript engine not meant to be accessible to untrusted script. It exposes unsafe methods via its prototype, such as GatherAsyncParentCompletions. Calling that method results in a call to UnsafeSetReservedSlot, which can be used to achieve memory corruption if a non-module object is passed in.
Exploitation
Step 1: Leak the internal module object
The report says it is easy to trigger the vulnerability and obtain a Module object. The technique is to attach a setter to the 0 property of Array.prototype and wait for it to be called. The snippet must be imported as a module from another file, and the last line exists solely to mark the module as asynchronous, which is needed to trigger the bug.
Step 2: Reach UnsafeSetReservedSlot
With the leaked module object, the attacker calls mod.gatherAsyncParentCompletions with an object of the form {asyncParentModules:[obj]}. This results in a call to UnsafeSetReservedSlot. The call attempts to write the value obj.pendingAsyncDependencies-1 to the internal object slot numbered MODULE_OBJECT_PENDING_ASYNC_DEPENDENCIES_SLOT=20.
Step 3: Understand the slot layout
In SpiderMonkey, objects have space for up to 16 so-called fixed slots, which are for internal use only. This number is defined by the MAX_FIXED_SLOTS constant. Slots with a higher index are indexed from an array pointed to by the slots_ field. The write is therefore directed to the array pointed to by slots_. No bounds checking exists to make sure the slots_ array is large enough for the specified index, because UnsafeSetReservedSlot assumes, as the name implies, that the caller passes only suitable objects.
Step 4: Shape the heap so the write lands on elements_ capacity
The general idea is:
- Create a new array object.
- Set some named properties of the object to force the allocation of a
slots_array for the object. Among these properties, create one namedpendingAsyncDependencies. - Write to a few numbered elements of the object to ensure the allocation of
elements_, the backing store for array elements.
By getting the alignment right, slots_[4] will then point to the capacity value of elements_, which can then be overwritten. The report states that this is not trivial, but that the heap allocator is very simple and deterministic. All of the allocations so far take place in the nursery heap, a special area for small short-lived objects, where memory is allocated by a simple bump allocator.
Step 5: Build read and write primitives
After increasing the capacity, the attacker can write out of bounds of the object's elements_ array and corrupt other nearby objects. From there, arbitrary read and write primitives are easily constructed by overwriting the data pointer of a typed array. The report warns that corruption in objects in the nursery heap cannot be used for very long, since the objects created there will soon be moved to the tenured heap. The best way to proceed is to use nursery corruption as a first stage only and immediately use it to produce corruption in the tenured heap, for example by corrupting ArrayBuffer objects.
Step 6: Execute shellcode despite W^X
Firefox uses W^X JIT, so all JIT-produced executable pages are non-writable. Overwriting executable JIT code with shellcode is therefore not possible. A well-known method forces the JIT to emit arbitrary ROP gadgets by embedding chosen floating-point constants into a JIT-compiled JavaScript function, producing arbitrary short byte sequences in an executable page. Manfred Paul enhanced this technique so that ROP is not needed at all. The floating-point constants are embedded into a WebAssembly method, so they are compiled into consecutive memory in order of appearance. This makes it possible to insert not just ROP gadgets but somewhat longer stretches of shellcode by encoding them in the floating-point constants.
There are restrictions: no 8-byte block may appear twice, or the constant will only be emitted once, and due to ambiguity in representation, byte sequences equal to NaN might not be encoded correctly. Manfred Paul therefore opted for a minimal first-stage shellcode with just two pieces of functionality:
- The ability to read a pointer from the Windows PEB structure.
- The ability to invoke a function given the function's address.
From ordinary JavaScript, the attacker triggers the first function to leak a value from the PEB. The JavaScript then uses this value together with the arbitrary read primitive to locate kernel32.dll and its functions in memory. Once it has the address of VirtualProtect, it invokes the second function to mark the backing store of an ArrayBuffer object as executable, making it possible to run a second-stage shellcode without constraints and compromise the renderer process.
With code execution inside the renderer, the next step is to prepare to attack the sandbox. The report says this is covered in the second blog, coming next week.
Root cause
The built-in implementation of top level await uses a real JavaScript array with a default argument, execList = [], and pushes onto it with std_Array_push, which resolves to Array.prototype.push. Because built-in code shares the JavaScript context and global prototypes with untrusted page code, a page can define a setter for property 0 on Array.prototype. The push then triggers that setter and hands the page an internal module object that was never meant to be exposed. That object exposes GatherAsyncParentCompletions, which calls UnsafeSetReservedSlot. That function trusts its caller and performs no bounds checking against the slots_ array, so a crafted object with a pendingAsyncDependencies property produces an out-of-bounds write at slot index 20.
The report notes that the ECMAScript specification defines GatherAsyncParentCompletions in terms of abstract lists, not actual JavaScript arrays, so the implementation's use of a real array is itself a deviation. The report also notes that other places in the same file use DefineDataProperty, which is safe and does not interact with the prototype. The existing defence, using std_Array_push instead of Array.prototype.push, only helps up to a point and does not stop prototype interaction.
Impact
Under the conditions described, a website running JavaScript in the Firefox renderer can leak an internal module object, corrupt memory, build arbitrary read and write primitives, and execute shellcode in the renderer process. The report frames this as compromising the renderer process, with the sandbox attack left for part two. The write-up does not state a severity score or CVSS vector, and it does not describe what an attacker could do beyond the renderer without the second vulnerability. The chain as a whole was used at Pwn2Own Vancouver 2022.
Fix
Mozilla fixed the vulnerability in Firefox 100.0.2 via Mozilla Foundation Security Advisory 2022-19. The report does not describe the code change itself. The report notes that other places in the same file use DefineDataProperty, which is safe and does not interact with the object's prototype.
Variants to test
- Look for built-in JavaScript in the engine that constructs default array arguments and pushes onto them, then check whether a page-defined setter on
Array.prototypefor the relevant index is reached. A positive result is a setter firing with an internal engine object as its argument. - Look for built-in code that calls prototype methods on objects reachable from page-controlled prototypes, rather than using internal helpers such as
DefineDataProperty. A positive result is page code observing or influencing an internal operation. - Look for internal objects exposed through leaked values that carry methods calling slot writers such as
UnsafeSetReservedSlot. A positive result is a write to a slot index aboveMAX_FIXED_SLOTSlanding in theslots_array. - Test whether shaping named properties and numbered elements lets
slots_[4]align with the capacity ofelements_in the nursery heap. A positive result is an out-of-bounds write past the elements backing store. - Test whether WebAssembly floating-point constants can carry shellcode under the stated restrictions, namely no repeated 8-byte block and no NaN-equal byte sequences. A positive result is the intended byte sequence appearing in executable memory in order.

What happened, in plain words
In 2022, at a hacking contest called Pwn2Own in Vancouver, a researcher named Manfred Paul broke into the Mozilla Firefox web browser. He did it with a chain of two bugs, and the surprising part is where the bugs lived: in JavaScript, a language that is supposed to be safe from the kind of memory mistakes that usually cause these break-ins.
This article is about the first bug in that chain. It is tracked as CVE-2022-1802 and as ZDI-22-799 on the Zero Day Initiative advisory page. Mozilla fixed it in Firefox 100.0.2 through Mozilla Foundation Security Advisory 2022-19. The bug is a prototype pollution problem in the part of Firefox that handles await in JavaScript modules. The write-up says the chain as a whole was used at Pwn2Own Vancouver 2022.
The technical write-up is written for people who already know how browsers and JavaScript engines work. This version starts from zero. If you can use a browser and a computer, you can follow it. Every term is explained the first time it appears, and there is a glossary at the end.
A quick note on what this article can and cannot show. So this article cannot show it either, and it says so where that matters.
The pieces you need to know first
Before the bug makes sense, here are a few ideas, explained from scratch.
A browser has more than one part. When you open a web page, the part that draws the page and runs the page's JavaScript is called the renderer process. It is deliberately kept separate from the rest of the browser, so that a bug in a web page does not immediately give an attacker the whole computer. The renderer is the target of this first bug.
JavaScript engines. Firefox does not interpret JavaScript with a simple script. It has a dedicated program inside it, called SpiderMonkey, that reads JavaScript and turns it into something the computer can run. SpiderMonkey is Firefox's JavaScript engine.
Built-in JavaScript. Some of SpiderMonkey is written in C++ (a language that talks directly to memory), but a large part of it is written in JavaScript itself. The report notes that this is true for most JavaScript-based functions in Firefox. This matters a lot: built-in JavaScript runs in the same world as the JavaScript of the website you are visiting.
Modules. Modern JavaScript lets developers split code into separate files called modules. One file can import another. This is the module system.
Top level await. An even newer feature lets a module wait for something slow (like a network request) before it finishes loading. This is called top level await. In SpiderMonkey, large parts of this feature are implemented in built-in JavaScript code rather than in C++. The specific function discussed lives in /js/src/builtin/Module.js, and the report links to it at revision [redacted].
Prototypes. This is the single most important idea in the article. In JavaScript, every object can have a parent object called its prototype. When you ask an object for a property it does not have, JavaScript looks at the object's prototype, then the prototype's prototype, and so on. This chain is called the prototype chain. A useful everyday comparison: if you ask a family member for a tool and they do not have it, they ask their parent, and so on up the family. The tool can come from far up the chain.
Getters and setters. A getter is a function that runs when someone reads a property. A setter is a function that runs when someone writes to a property. They let a programmer run custom code on an ordinary-looking read or write.
Prototype pollution. If an attacker can add or change properties on a shared prototype, then code that walks the prototype chain can be made to run the attacker's code or see the attacker's values. That class of bug is called prototype pollution. This first vulnerability is described as a prototype pollution vulnerability in the await implementation.
Memory corruption. Programs store data in memory at numbered addresses. If a program writes data outside the area it was supposed to write to, it can overwrite something else. That is memory corruption, and it is the usual route to taking over a program.
Memory-safe languages. Some languages, such as JavaScript and Rust, are designed so that ordinary code cannot write outside its own data. They are called memory-safe. The point of this article is that even memory-safe code can be made to corrupt memory if it is tricked into calling unsafe internal helpers.
The ECMAScript specification. JavaScript is standardised by a document called the ECMAScript specification. It describes what the language should do. The report notes that the specification defines GatherAsyncParentCompletions in terms of abstract lists and not actual JavaScript arrays. That detail becomes important later.
How the researcher found it
The researcher read the built-in JavaScript implementation of top level await in /js/src/builtin/Module.js. The report lists three facts about the relevant function that make it interesting. Each one is worth unpacking.
- The function runs in the same JavaScript context as the user's code. Global state, including prototypes of global objects, is shared between this built-in code and untrusted website code. In plain words: the engine's own JavaScript and the website's JavaScript live in the same room and share the same furniture. If the website rearranges the furniture, the engine's code will trip over it.
- The function has a default argument of
execList = []. A default argument is a value used when the caller does not supply one. In practice the function is called without specifying this argument, except for the recursive call inside the function itself. So a new empty array object is constructed for the argument. Like any ordinary array, this array object has the unique objectArray.prototypeas its prototype. In plain words: every time the engine runs this function, it quietly creates a fresh array, and that array inherits from the sharedArray.prototype. - The function invokes
std_Array_pushon this array object. That leads to a call to theArray.prototype.pushJavaScript method. Usingstd_Array_pushinstead ofArray.prototype.pushhelps prevent side effects up to a certain point, but the function can still interact with the object's prototype. In plain words: the engine tries to use a safer internal version of push, but the safer version still looks up the prototype chain, so the website can still get a word in.
The report contrasts this with other places in the same file where a different function, DefineDataProperty, is used to assign array values. DefineDataProperty is safe and will not interact in any way with the object's prototype. The comparison is useful: the safe pattern already existed in the same file, it just was not used here.
The semantics of Array.prototype.push with a single argument are roughly equivalent to an assignment. The assignment is not just the definition of a data property on the object itself: it searches the object's prototype chain for existing properties as per usual JavaScript semantics. If the imported module defines a getter or setter for property 0 on Array.prototype, the assignment triggers the setter. The report notes that this call technically violates the ECMAScript specification, which defines GatherAsyncParentCompletions in terms of abstract lists and not actual JavaScript arrays.
The crucial side effect is that the setter receives the value being assigned, which leaks a module object. The report calls this value "m" and describes it as representing a module. This object is not the same as the module namespace returned by import(). It is an internal type of the JavaScript engine not meant to be accessible to untrusted script. It exposes unsafe methods via its prototype, such as GatherAsyncParentCompletions. Calling that method results in a call to UnsafeSetReservedSlot, which can be used to achieve memory corruption if a non-module object is passed in.
In everyday terms: the engine has a private notebook it never meant to show anyone. Because it writes into a shared array using a method that consults the shared prototype, the website can plant a trap on that prototype. When the engine writes, the trap fires, and the trap is handed the private notebook. The notebook has a page that says "write a value into slot number 20 of whatever object I am given", and it does not check whether the object is the right kind.
Exploitation, step by step
Step 1: Leak the internal module object
The report says it is easy to trigger the vulnerability and obtain a Module object. The technique is to attach a setter to the 0 property of Array.prototype and wait for it to be called. The snippet must be imported as a module from another file, and the last line exists solely to mark the module as asynchronous, which is needed to trigger the bug.
Why this step is taken: the attacker needs the private module object before anything else can happen. The setter is the trap. The 0 property is the exact index the engine's push will write to. Importing the file as a module is required because the vulnerable code path only runs for modules. Marking the module asynchronous is required because the bug lives in the await machinery, which only runs for asynchronous modules.
Step 2: Reach UnsafeSetReservedSlot
With the leaked module object, the attacker calls mod.gatherAsyncParentCompletions with an object of the form {asyncParentModules:[obj]}. This results in a call to UnsafeSetReservedSlot. The call attempts to write the value obj.pendingAsyncDependencies-1 to the internal object slot numbered MODULE_OBJECT_PENDING_ASYNC_DEPENDENCIES_SLOT=20.
Why this step is taken: the leaked object has a method that the engine only intended to call on real modules. The attacker calls it on a fake object of their own design. The fake object supplies asyncParentModules as an array containing obj, and obj carries a pendingAsyncDependencies property. The engine subtracts one from that property and writes the result into slot 20. The attacker controls the value through pendingAsyncDependencies.
Step 3: Understand the slot layout
In SpiderMonkey, objects have space for up to 16 so-called fixed slots, which are for internal use only. This number is defined by the MAX_FIXED_SLOTS constant. Slots with a higher index are indexed from an array pointed to by the slots_ field. The write is therefore directed to the array pointed to by slots_. No bounds checking exists to make sure the slots_ array is large enough for the specified index, because UnsafeSetReservedSlot assumes, as the name implies, that the caller passes only suitable objects.
Why this matters: slot 20 is past the 16 fixed slots, so the write goes into the separate slots_ array. The function does not check that the array is long enough. The name UnsafeSetReservedSlot is a warning label: it trusts its caller. The attacker is now the caller, and the attacker is not trustworthy.
Step 4: Shape the heap so the write lands on elements_ capacity
The general idea is:
- Create a new array object.
- Set some named properties of the object to force the allocation of a
slots_array for the object. Among these properties, create one namedpendingAsyncDependencies. - Write to a few numbered elements of the object to ensure the allocation of
elements_, the backing store for array elements.
By getting the alignment right, slots_[4] will then point to the capacity value of elements_, which can then be overwritten. The report states that this is not trivial, but that the heap allocator is very simple and deterministic. All of the allocations so far take place in the nursery heap, a special area for small short-lived objects, where memory is allocated by a simple bump allocator.
Why this step is taken: the attacker does not just want to write a number somewhere. They want that number to land on something useful. The heap is the region of memory where a program keeps its objects. The nursery heap is a special area for small, short-lived objects, and it hands out memory by simply moving a pointer forward (a bump allocator). Because that allocator is simple and predictable, the attacker can arrange objects so that the out-of-bounds write lands exactly on the capacity value of the elements_ array. Capacity is the number that says how many elements the array can hold. If the attacker can raise it, the array will believe it has more room than it really does.
Step 5: Build read and write primitives
After increasing the capacity, the attacker can write out of bounds of the object's elements_ array and corrupt other nearby objects. From there, arbitrary read and write primitives are easily constructed by overwriting the data pointer of a typed array. The report warns that corruption in objects in the nursery heap cannot be used for very long, since the objects created there will soon be moved to the tenured heap. The best way to proceed is to use nursery corruption as a first stage only and immediately use it to produce corruption in the tenured heap, for example by corrupting ArrayBuffer objects.
Why this step is taken: a single out-of-bounds write is not enough to take over a program. The attacker needs two reusable abilities: read any memory, and write any memory. These are called primitives. A typed array is a JavaScript array with a fixed element type, and it keeps a pointer to its data. Overwrite that pointer and the typed array will read and write wherever the attacker points it. The tenured heap is the longer-lived area where objects are moved once they survive a while. Nursery corruption is temporary because the garbage collector moves objects out of the nursery. So the attacker uses the nursery as a stepping stone and immediately builds a more durable corruption in the tenured heap, for example by corrupting ArrayBuffer objects.
Step 6: Execute shellcode despite W^X
Firefox uses W^X JIT, so all JIT-produced executable pages are non-writable. Overwriting executable JIT code with shellcode is therefore not possible. A well-known method forces the JIT to emit arbitrary ROP gadgets by embedding chosen floating-point constants into a JIT-compiled JavaScript function, producing arbitrary short byte sequences in an executable page. Manfred Paul enhanced this technique so that ROP is not needed at all. The floating-point constants are embedded into a WebAssembly method, so they are compiled into consecutive memory in order of appearance. This makes it possible to insert not just ROP gadgets but somewhat longer stretches of shellcode by encoding them in the floating-point constants.
This paragraph is dense, so here is the unpacking. JIT stands for just-in-time compilation: the engine turns hot JavaScript into machine code while the page runs. W^X means a page of memory can be writable or executable, but not both. That blocks the classic trick of writing shellcode into executable memory. Shellcode is a small piece of machine code that does something useful for the attacker. ROP gadgets are short existing code fragments that can be chained together. WebAssembly is a fast, low-level language that browsers can run. Floating-point constants are numbers like 1.5 written in a program. The trick is that those numbers are stored as bytes, and the attacker chooses numbers whose bytes spell out machine code. Because WebAssembly compiles constants into consecutive memory in order of appearance, the bytes line up into a runnable sequence.
There are restrictions: no 8-byte block may appear twice, or the constant will only be emitted once, and due to ambiguity in representation, byte sequences equal to NaN might not be encoded correctly. Manfred Paul therefore opted for a minimal first-stage shellcode with just two pieces of functionality:
- The ability to read a pointer from the Windows PEB structure.
- The ability to invoke a function given the function's address.
Why these two: the PEB (Process Environment Block) is a Windows structure that holds information about the running process, and reading from it gives the attacker a foothold in memory. The second ability lets the attacker call any function once its address is known. Together they are enough to bootstrap the rest.
From ordinary JavaScript, the attacker triggers the first function to leak a value from the PEB. The JavaScript then uses this value together with the arbitrary read primitive to locate kernel32.dll and its functions in memory. Once it has the address of VirtualProtect, it invokes the second function to mark the backing store of an ArrayBuffer object as executable, making it possible to run a second-stage shellcode without constraints and compromise the renderer process.
Why this works: kernel32.dll is a Windows system library, and VirtualProtect is a function that changes memory permissions. Marking an ArrayBuffer's backing store as executable turns ordinary data into a place where code can run. The first-stage shellcode is tiny because of the encoding restrictions; the second stage has no such restrictions.
With code execution inside the renderer, the next step is to prepare to attack the sandbox. The report says this is covered in the second blog, coming next week.

Root cause
The built-in implementation of top level await uses a real JavaScript array with a default argument, execList = [], and pushes onto it with std_Array_push, which resolves to Array.prototype.push. Because built-in code shares the JavaScript context and global prototypes with untrusted page code, a page can define a setter for property 0 on Array.prototype. The push then triggers that setter and hands the page an internal module object that was never meant to be exposed. That object exposes GatherAsyncParentCompletions, which calls UnsafeSetReservedSlot. That function trusts its caller and performs no bounds checking against the slots_ array, so a crafted object with a pendingAsyncDependencies property produces an out-of-bounds write at slot index 20.
The report notes that the ECMAScript specification defines GatherAsyncParentCompletions in terms of abstract lists, not actual JavaScript arrays, so the implementation's use of a real array is itself a deviation. The report also notes that other places in the same file use DefineDataProperty, which is safe and does not interact with the prototype. The existing defence, using std_Array_push instead of Array.prototype.push, only helps up to a point and does not stop prototype interaction.
In one sentence: the engine used a shared, page-visible object as scratch space, and then trusted an internal helper that was never designed to be called by a page.
Impact
Under the conditions described, a website running JavaScript in the Firefox renderer can leak an internal module object, corrupt memory, build arbitrary read and write primitives, and execute shellcode in the renderer process. The report frames this as compromising the renderer process, with the sandbox attack left for part two. The write-up does not state a severity score or CVSS vector, and it does not describe what an attacker could do beyond the renderer without the second vulnerability. The chain as a whole was used at Pwn2Own Vancouver 2022, and the platform lists a bounty of 100,000.00 USD for the entry.
Fix
Mozilla fixed the vulnerability in Firefox 100.0.2 via Mozilla Foundation Security Advisory 2022-19. The report does not describe the code change itself. The report notes that other places in the same file use DefineDataProperty, which is safe and does not interact with the object's prototype.
Variants to test
Each one is a way to look for the same class of mistake elsewhere.
- Look for built-in JavaScript in the engine that constructs default array arguments and pushes onto them, then check whether a page-defined setter on
Array.prototypefor the relevant index is reached. A positive result is a setter firing with an internal engine object as its argument. - Look for built-in code that calls prototype methods on objects reachable from page-controlled prototypes, rather than using internal helpers such as
DefineDataProperty. A positive result is page code observing or influencing an internal operation. - Look for internal objects exposed through leaked values that carry methods calling slot writers such as
UnsafeSetReservedSlot. A positive result is a write to a slot index aboveMAX_FIXED_SLOTSlanding in theslots_array. - Test whether shaping named properties and numbered elements lets
slots_[4]align with the capacity ofelements_in the nursery heap. A positive result is an out-of-bounds write past the elements backing store. - Test whether WebAssembly floating-point constants can carry shellcode under the stated restrictions, namely no repeated 8-byte block and no NaN-equal byte sequences. A positive result is the intended byte sequence appearing in executable memory in order.
Glossary
- ArrayBuffer: a JavaScript object that holds a block of raw bytes, often used for binary data.
- Bump allocator: a memory allocator that hands out memory by simply moving a pointer forward, which makes it fast and predictable.
- Built-in JavaScript: JavaScript code that ships inside the engine itself, as opposed to code written by a website.
- CVE: a public identifier for a known vulnerability, here CVE-2022-1802.
- CVSS: a scoring system for the severity of a vulnerability.
- Default argument: a value a function uses when the caller does not supply one.
- DefineDataProperty: an internal helper that sets a property directly on an object without consulting its prototype, described in the report as safe.
- ECMAScript specification: the standard document that defines how JavaScript should behave.
- elements_: the internal backing store that holds an array's numbered elements.
- execList: the default array argument in the vulnerable built-in function, written as
execList = []. - Fixed slots: up to 16 internal storage places inside a SpiderMonkey object, defined by
MAX_FIXED_SLOTS. - GatherAsyncParentCompletions: an internal method on module objects that the report says should not be reachable from untrusted script.
- Getter / setter: functions that run when a property is read or written.
- Heap: the region of memory where a program keeps its objects.
- JIT: just-in-time compilation, turning JavaScript into machine code while the page runs.
- kernel32.dll: a Windows system library whose functions the attacker locates in memory.
- Memory corruption: writing data outside the intended area of memory.
- Memory-safe language: a language designed so ordinary code cannot write outside its own data, such as JavaScript or Rust.
- Module: a separate JavaScript file that can be imported by another file.
- Module object: the internal engine object representing a module, not the same as the module namespace returned by
import(). - NaN: "not a number", a special floating-point value whose byte representation is ambiguous.
- Nursery heap: a special area for small, short-lived objects, from which objects are later moved.
- Out-of-bounds write: a write past the end of an allocated area.
- PEB: the Windows Process Environment Block, a structure holding information about the running process.
- Primitive: a reusable ability, such as reading or writing arbitrary memory.
- Prototype: the parent object that JavaScript consults when a property is missing.
- Prototype chain: the sequence of prototypes followed when looking up a property.
- Prototype pollution: adding or changing properties on a shared prototype so that other code is influenced.
- Pwn2Own: a hacking contest where researchers demonstrate exploits against real products.
- Renderer process: the part of the browser that draws the page and runs its JavaScript.
- ROP gadget: a short existing code fragment used to build a chain of behaviour.
- Sandbox: the isolation around the renderer that limits what a compromised renderer can reach.
- Shellcode: a small piece of machine code that performs an action for the attacker.
- slots_: the internal array that holds an object's slots beyond the fixed ones.
- SpiderMonkey: Firefox's JavaScript engine.
- std_Array_push: an internal helper that leads to
Array.prototype.push. - Tenured heap: the longer-lived memory area where objects are moved after surviving in the nursery.
- Top level await: the feature that lets a module wait for an asynchronous operation before finishing.
- Typed array: a JavaScript array with a fixed element type that keeps a pointer to its data.
- UnsafeSetReservedSlot: an internal function that writes to an object slot and, as the name says, does not check its caller.
- VirtualProtect: a Windows function that changes the permissions of a region of memory.
- W^X: a rule that a page of memory may be writable or executable, but not both.
- WebAssembly: a fast, low-level language that browsers can run.
- ZDI-22-799: the Zero Day Initiative advisory identifier for this vulnerability.