Skip to content
Memory corruption Write-up Advanced

Getting Started

A use-after-free in WebKit's History API was fixed in 2013 but reintroduced in 2016 during refactoring, allowing an attacker to trigger the bug via a crafted page and potentially execute code. The vulnerability was exploited in the wild and patched again in 2022.

googleprojectzero.blogspot.com

Published on googleprojectzero.blogspot.com

Whenever there’s a new in-the-wild 0-day disclosed, I’m very interested in understanding the root cause of the bug. This allows us to then understand if it was fully fixed, look for variants, and brainstorm new mitigations.

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

The stateObject argument in FrameLoader::loadInSameDocument was changed from a reference-counted pointer to a raw pointer, so it was not properly reference-counted and could be freed while still in use.

Impact

An attacker could exploit this use-after-free to potentially execute arbitrary code when a victim visits a malicious web page.

What the attacker needed

Victim visits a malicious web page; browser is Safari/WebKit

How it was found

  1. Set up a history state with a URL that includes a hash, then another state, and call history.back() to trigger loadInSameDocument.
  2. Ensure an element has focus and attach an onblur handler that calls history.replaceState to free the stateObject.
  3. Trigger the blur event during loadInSameDocument, causing the stateObject to be freed before it is used in statePopped.

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 about a bug in a web browser's code that manages the back/forward history. The bug meant that a piece of memory could be freed while still in use, which can let an attacker run their own code. It was fixed, then accidentally brought back years later, and finally fixed again after being exploited.

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.