Skip to content
RCE Write-up Advanced

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 author, on jaybosamiya.com

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

  1. Build a debug d8 and use the reverted regression test to confirm the bug triggers
  2. Craft code so the bug is hidden from the typer and load elimination but fires in simplified lowering
  3. Use the wrong type to remove a bounds check and get an out-of-bounds read/write
  4. Stabilise by overwriting a second array's length to a large value
  5. Build arbitrary read, arbitrary write and address-of primitives from adjacent arrays
  6. 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.

Similar reports

View all

Same bug class and techniques, clearest first.

Remote code execution

The lesson behind this report.

Running the attacker's code on the target's servers: through command or code injection, unsafe deserialisation or template injection.