Skip to content
Memory corruption Write-up Advanced

Attacking Android Binder: Analysis and Exploitation of CVE-2023-20938

An error-handling path in the Android Binder driver released Binder objects that had never been processed, corrupting a node's reference count. An attacker could send a crafted transaction to free a Binder node while a pointer to it remained, giving a use-after-free that the researchers turned into root privilege from an untrusted app.

androidoffsec.withgoogle.com

Published on androidoffsec.withgoogle.com

/posts/attacking-android-binder-analysis-and-exploitation-of-cve-2023-20938/ map(name:Google)

The author, on androidoffsec.withgoogle.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 error path for an unaligned offsets_size passed a failed_at of zero into the buffer release routine, which then cleaned up every object in the transaction even though none had been processed, unbalancing the node's reference counters.

Impact

The researchers used the use-after-free to achieve root privilege from an untrusted app on a fully up-to-date Android device, affecting all devices on GKI kernels 5.4 and 5.10.

What the attacker needed

Ability to send Binder transactions; untrusted app on the device

The fix

It was fixed by patches released in the February 2023 and July 2023 Android Security Bulletins.

How it was found

  1. Open the Binder device and map its memory.
  2. Send a transaction containing two Node objects and an unaligned offsets_size.
  3. The driver takes the error path and skips processing the objects.
  4. The cleanup routine releases both Nodes, decrementing the target node's strong reference count twice.
  5. The node is freed while a dangling pointer remains, producing a use-after-free.

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.

Android apps are kept apart from each other, and they talk through a kernel component called Binder. A reference count is a tally of how many things still use an object; when it reaches zero the object is deleted. Here a mistake made the tally drop too far, so an object was deleted while something still pointed at it, and the researchers showed that misuse could lead to full control of the phone.

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.