Skip to content
Memory corruption Write-up Advanced

Exploiting WebKit JSPropertyNameEnumerator Out-of-Bounds Read (CVE-2021-1789)

JavaScriptCore's JSPropertyNameEnumerator object, used to cache information for for-in loops, does not check the final size of the base object after iterating through the prototype chain, which can include a proxy with a trap callback. This leads to an out-of-bounds read, and the authors report they successfully exploited it on WebKitGTK.

starlabs.sg

Published on starlabs.sg

Initially, our team member, Đỗ Minh Tuấn, wanted to write about the RCA (Root Cause Analysis) of CVE-2021-1870 which APT used. But Maddie Stone pointed it to us that it was actually CVE-2021-1789.

The author, on starlabs.sg

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 engine caches property names for a for-in loop but does not re-validate the cached size after traversing the prototype chain, which may include a proxy trap, so the enumeration can read beyond the intended bounds.

Impact

An attacker could trigger an out-of-bounds read in JavaScriptCore, and the authors state they successfully exploited it on WebKitGTK; the text does not describe the concrete consequence beyond the read itself.

What the attacker needed

Ability to run JavaScript in the browser

The fix

The bug was fixed in Safari 14.0.3 according to the security content referenced in the text.

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 for-in loop in JavaScript walks through the property names of an object and its parent objects. The browser engine keeps a cached list of those names, and the bug is that it fails to re-check how long that list is after walking the chain, so it can read past the end of the list. Reading memory outside a buffer can crash the browser or, in the wrong hands, leak data.

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.