Exploiting Chrome V8: Krautflare
A V8 JIT type-confusion bug in Math.expm1 mishandled negative zero, letting the optimiser wrongly narrow a value's type and eliminate a bounds check. An attacker could turn this into an out-of-bounds read/write and then arbitrary read/write, leading to code execution.
jaybosamiya.com
Published on jaybosamiya.com
In this challenge, we had to obtain remote code execution, simply by exploiting a 1-day bug that forgot the difference between -0 and +0. This has probably been one of the most difficult, fun, and frustrating bugs I have ever exploited.
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
Likely the optimiser's type inference did not account for Math.expm1 returning negative zero, so a value was typed as a small integer range and a bounds check was removed.
Impact
An attacker could gain out-of-bounds and then arbitrary read/write in the engine, which the author was working towards turning into remote code execution; the write-up does not show a completed shell.
What the attacker needed
A vulnerable d8 build; ability to run JavaScript in it
The fix
The bug was fixed upstream in two parts, and this challenge only reverted the second part.
How it was found
- Build a debug d8 and use the reverted regression test to confirm the bug triggers
- Craft code so the bug is hidden from the typer and load elimination but fires in simplified lowering
- Use the wrong type to remove a bounds check and get an out-of-bounds read/write
- Stabilise by overwriting a second array's length to a large value
- Build arbitrary read, arbitrary write and address-of primitives from adjacent arrays
- Leak the d8 base address and libc base to prepare for code execution
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.
A JavaScript engine speeds up hot code by guessing what types values have. Here it guessed wrong about a special negative zero value, so it skipped a safety check on an array index. That let the attacker read and write memory outside the array, which can end in running their own code.
What is RCE?
Running the attacker's code on the target's servers: through command or code injection, unsafe deserialisation or template injection.