Skip to content
Memory corruption Write-up Advanced

Exploiting CVE-2021-21225 and disabling W^X

CVE-2021-21225 allowed an out-of-bounds read from a JavaScript array's elements buffer during Array.prototype.concat, leaking heap pointers and enabling creation of a fake object. The author chained this with other techniques to achieve arbitrary read/write and code execution, and also described disabling the W^X protection at runtime.

tiszka.com

Published on tiszka.com

Understanding the basics of V8 exploitation [link] is a pre-requisite for this post. Reading through CVE-2017-5030's exploit will also make this post easier to understand [link].

The author, on tiszka.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

What the attacker needed

V8 version 9.0.257; ability to run JavaScript in the browser

How it was found

  1. Trigger the vulnerability with a HOLEY/PACKED_DOUBLE_ELEMENTS array to leak the JSArray's map, properties, elements, and length as doubles.
  2. Use the leaked elements address to calculate the address of a subsequently allocated Float32Array (fake_object).
  3. Trigger the vulnerability again with a PACKED/HOLEY_ELEMENTS array to read a pointer from an overlapping Float32Array, and craft a fake JSArray in that Float32Array.
  4. Bypass Object::ToNumber by using a valueOf callback to capture the fake JSArray as a corrupted array.
  5. Build arbitrary read/write primitives and achieve code execution via WebAssembly's RWX memory.
  6. Leak the pointer compression isolate root and disable W^X by writing to the write_protect_code_memory_ flag.

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.

This is a deep dive into exploiting a bug in Chrome's JavaScript engine, V8. The bug let an attacker read memory beyond a JavaScript array, which could leak secret addresses and eventually let them run their own code on the victim's machine. The article assumes you already know how V8 exploits work and focuses on advanced tricks to turn the leak into full code execution.

What is Memory corruption?

Native code reads or writes memory it should not: overflows, use-after-free, type confusion. The core of browser, kernel and parser bugs.

Similar reports

View all

Same bug class and techniques, clearest first.

Memory corruption

The lesson behind this report.

Native code reads or writes memory it should not: overflows, use-after-free, type confusion. The core of browser, kernel and parser bugs.