Let the Cache Cache and Let the WebAssembly Assemble: Knocking on Chrome's Shell
This talk demonstrates a novel exploit chain targeting the V8 JavaScript engine in Google Chrome and Microsoft Edge, leveraging a variant of CVE-2023-4427 to achieve an out-of-bounds read. The researchers utilize this primitive to perform heap manipulation and construct a fake object, ultimately achieving a field confusion vulnerability to bypass the V8 sandbox. The exploit concludes by hijacking the WebAssembly indirect call mechanism to gain arbitrary code execution outside the sandbox.
Bypassing the V8 Sandbox: A Deep Dive into Field Confusion
TLDR: Researchers at Black Hat 2024 demonstrated a sophisticated exploit chain that bypasses the V8 sandbox in Chrome and Edge. By leveraging a variant of CVE-2023-4427 to trigger an out-of-bounds read, they achieved heap manipulation and field confusion. This technique allows an attacker to hijack WebAssembly indirect calls, leading to arbitrary code execution outside the sandbox.
Modern browser security relies heavily on the V8 sandbox to isolate the JavaScript engine from the rest of the renderer process. When that sandbox is compromised, the entire security model of the browser collapses. The research presented at Black Hat 2024 regarding CVE-2024-3159 is a masterclass in how small, seemingly isolated bugs can be chained into a full sandbox escape.
The Anatomy of the Out-of-Bounds Read
The exploit begins with a variant of the enum cache vulnerability, originally identified by Google Project Zero. The enum cache is a performance optimization in V8 designed to speed up for-in loops by caching the keys of an object. When the JIT compiler, specifically TurboFan, optimizes a for-in loop, it assumes the object structure remains stable.
If an attacker can force a map transition during the execution of an optimized loop, the enum cache can become desynchronized from the actual object properties. This leads to an out-of-bounds read. In the demonstration, the researchers used a specific sequence of object property modifications to trigger this state. By carefully controlling the heap layout, they ensured that the out-of-bounds read landed on a predictable memory location, which they then used to leak the address of a target object.
From Heap Leak to Field Confusion
Once the researchers had an out-of-bounds read, they needed a way to turn that into a more powerful primitive. They used heap manipulation to place a "fake object" in memory. By overwriting the fields of this fake object, they could trick V8 into treating a standard JavaScript object as something else entirely.
This is where the concept of field confusion comes into play. By manipulating the internal representation of a WebAssembly instance, the researchers were able to confuse the engine about the location of the WebAssembly dispatch table. In V8, WebAssembly functions are called through an indirect call mechanism that relies on a table of function pointers. If you can control the index used to look up these pointers, you control the execution flow.
The researchers demonstrated that by overwriting the wasm_dispatch_table pointer within the trusted instance data, they could redirect the indirect call mechanism to an attacker-controlled memory region.
Hijacking WebAssembly Indirect Calls
The final stage of the exploit is the most elegant. WebAssembly functions are compiled into machine code and stored in an RWX (Read-Write-Execute) memory region. The researchers realized that they could use the WebAssembly compiler, specifically the Liftoff compiler, to their advantage.
When WebAssembly code is compiled, floating-point constants are often embedded directly into the machine code. By crafting a WebAssembly module that contains specific floating-point values, the researchers could effectively "spray" their shellcode into the RWX memory region.
(func (export "spray") (result f64)
f64.const 1.63052427775809e-270
f64.const 1.6183477236817195e-270
f64.const 1.6177848892830878e-270
f64.const 1.630523884017562e-270
)
Once the shellcode was in place, they used the field confusion primitive to point the WebAssembly indirect call table to the start of their shellcode. Triggering the indirect call then executed the shellcode with the privileges of the renderer process.
Real-World Implications for Pentesters
For those of us conducting red team engagements or bug bounty research, this talk highlights the importance of understanding the internal memory management of the target. You are not just looking for a buffer overflow; you are looking for ways to manipulate the engine's internal state.
If you are testing a browser-based application or a platform that utilizes embedded Chromium, assume that the sandbox is the primary barrier. Look for ways to trigger JIT optimizations and then invalidate the assumptions made by the compiler. The OWASP Top 10 doesn't explicitly cover browser engine internals, but the principles of input validation and state management remain the same.
Defensive Considerations
Defending against this level of exploitation is difficult because it targets the fundamental design of the engine. However, the move toward more granular sandboxing and the hardening of the V8 heap are steps in the right direction. Blue teams should focus on monitoring for anomalous renderer process behavior, such as unexpected child process spawning or unusual memory access patterns.
The most effective defense remains keeping browsers updated. The patch for this vulnerability involves adding strict checks to ensure that the enum cache and the object map remain synchronized during JIT-optimized operations. If you are managing a fleet of machines, ensure that your patch management process is aggressive, especially for browsers.
This research serves as a reminder that the "noise" of browser updates often hides critical security fixes. Don't ignore the release notes. When a vendor like Google or Microsoft pushes a security update for their browser engine, it is almost always addressing a vulnerability that is being actively researched by people who know exactly how to turn it into a shell.
Vulnerability Classes
Target Technologies
Up Next From This Conference
Similar Talks

Kill List: Hacking an Assassination Site on the Dark Web

Firewalls Under Fire: China's Ongoing Campaign to Compromise Network Protection Devices




