CVE-2024-2887: A Pwn2Own Winning Bug In Google Chrome
A type confusion bug in V8's WebAssembly heap type handling allowed exceeding the maximum number of declared types, enabling arbitrary read/write within the V8 sandbox. Combined with an integer underflow in typed array length calculation for growable SharedArrayBuffers, an attacker could escape the sandbox and execute arbitrary shellcode in the renderer process.
Published on zerodayinitiative.com
In this blog, I describe a means of exploiting the V8 JavaScript and WebAssembly engine to gain execution of arbitrary shellcode inside the renderer process. This includes a bypass of the V8 memory sandbox (Ubercage), though code execution is still constrained by the process isolation-based browser sandbox.
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.
Not written yet. The AI write-up for this write-up has not been written yet. The Original tab links to the source.
How it worked
Root cause
The check on the number of WebAssembly heap types was insufficient because recursive type groups could contain many types, and types declared after such groups could exceed the maximum index, aliasing internal types.
Impact
An attacker could execute arbitrary shellcode inside the renderer process, though code execution is still constrained by the process isolation-based browser sandbox unless the --no-sandbox flag is used.
What the attacker needed
Victim visits a malicious webpage; browser runs V8 with WebAssembly support; browser sandbox may limit impact
How it was found
- Define a struct type with a single field of type anyref and assign it a type index equal to HeapType::kNone using the bug.
- Place a non-null reference value on the stack and call struct.new with the type index set to HeapType::kNone.
- Declare a struct with a normal type index lower than kV8MaxWasmTypes with a single field of the target reference type.
- Call ref.cast with this struct's type index; the engine will not perform any type check.
- Read back the reference stored in the struct by executing struct.get.
- Use the resulting arbitrary read/write primitives to manipulate a growable SharedArrayBuffer and overwrite WebAssembly code with shellcode.
Explained by bugbounty.wiki with AI from the original and checked against quotes from it; it can still be wrong. Read the original before relying on a detail.
Not written yet. The AI write-up for this write-up has not been written yet. The Original tab links to the source.
The bug is in how Chrome's JavaScript engine (V8) handles WebAssembly, a way to run code in the browser. By crafting a special WebAssembly module, an attacker could trick the engine into treating one type of data as another, giving them the ability to read and write memory inside a protected area. A second flaw then let them break out of that protected area and run their own code on the victim's computer.
What is RCE?
Running the attacker's code on the target's servers: through command or code injection, unsafe deserialisation or template injection.