Skip to content
Memory corruption Write-up Advanced

A deep dive into an NSO zero-click iMessage exploit: Remote Code Execution

A zero-click iMessage exploit used a fake GIF to trigger an integer overflow in the JBIG2 decoder, leading to memory corruption and arbitrary code execution. An attacker could silently compromise an iPhone by sending a malicious image.

googleprojectzero.blogspot.com

Published on googleprojectzero.blogspot.com

We want to thank Citizen Lab for sharing a sample of the FORCEDENTRY exploit with us, and Apple’s Security Engineering and Architecture (SEAR) group for collaborating with us on the technical analysis. The editorial opinions reflected below are solely Project Zero’s and do not necessarily reflect those of the…

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

Likely an integer overflow in the JBIG2 decoder when summing the sizes of referenced symbol dictionaries, leading to an undersized heap allocation and subsequent heap overflow.

Impact

An attacker could achieve remote code execution on the victim's iPhone without any user interaction, as demonstrated by the in-the-wild exploit.

What the attacker needed

Victim uses iMessage; attacker knows victim's phone number or AppleID; no user interaction required

How it was found

  1. Send a malicious image file with a .gif extension to the target via iMessage.
  2. The iMessage pipeline calls IMGIFUtils copyGifFromPath:toDestinationPath:error, which uses ImageIO to parse the file ignoring the extension.
  3. ImageIO detects the file as a PDF containing a JBIG2 stream and invokes the JBIG2 decoder.
  4. The JBIG2 stream contains crafted segment references that cause an integer overflow in numSyms, leading to an undersized allocation for syms.
  5. Heap grooming places the syms buffer before the GList backing buffer, so the overflow corrupts GList pointers.
  6. Further crafted segments overwrite the page JBIG2Bitmap fields, unbounding the canvas and enabling arbitrary memory read/write via logical operations.

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 report describes a very advanced attack where simply receiving a specially crafted image in iMessage could let an attacker take control of an iPhone without any user interaction. The image exploits a bug in how the phone's software decompresses a certain image format, causing memory corruption that the attacker can leverage to run their own code.

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.