How does spyware get on your phone?
Spyware is software that secretly collects your messages, contacts and location, and it can get on your phone through a software bug, a fake app or someone holding your phone.

Spyware
Spyware is software that secretly collects information from your phone, such as messages, contacts and location. One well-documented example is Pegasus, made by NSO. In 2021, Citizen Lab found it on a Saudi activist’s iPhone. It was delivered through iMessage, with no tap. Those listed abilities come from documented Pegasus for iOS capabilities, not from a confirmed list of what was taken from this activist’s phone.
That attack sits at the expensive end of spyware. Apple says such attacks cost millions of dollars, and that the vast majority of users will never be targeted. Stalkerware apps are far cheaper, sometimes as little as $7 per month according to Kaspersky researchers quoted in 2019. They usually need someone holding your phone. Fake apps are another route. So a bug, a fake app or someone’s hands can each plant spyware.
What Pegasus actually does
The iPhone attack needed only a phone number or Apple ID. Attackers sent files ending in .gif that were really PDFs (Portable Document Format files) containing a JBIG2 stream. JBIG2 (Joint Bi-level Image Experts Group) is a black-and-white image decoder. Before showing anything, iMessage handed the files to IMTranscoderAgent, a process outside Apple’s walled-off BlastDoor sandbox. Apple’s ImageIO code guessed the format and ignored the extension. That sent the file to the CoreGraphics PDF parser and its JBIG2 code, where the flaw was.
NSO claimed Pegasus leaves no traces. Amnesty found something else. Pegasus deleted process names from one table, ZPROCESS, in DataUsage.sqlite. It left the matching rows in another table, ZLIVEUSAGE, which holds data transfer volume per process. That gap became evidence. Amnesty saw no similar inconsistencies on any clean iPhones it analyzed.
How the bug became a tiny computer
- A number overflows its space. In the JBIG2 code,
numSymsgrew too big for its space. That integer overflow left a buffer calledsymstoo small. - Writes run past the end. The code then wrote past the end of that buffer. Those writes corrupted the segment list and the page bitmap.
- The page loses its limits. The corrupted page no longer had its normal limits. Project Zero describes this as unbounding the canvas.
- Commands build a computer. Over 70,000 segment commands used
AND,OR,XORandXNORoperations. They built registers, a 64-bit adder and a comparator.
The result was a tiny computer inside an image decoder. It could search memory and begin escaping the agent’s own sandbox. Apple patched the flaw on September 13, 2021.
An access check is not a spyware scan
It’s easy to think a phone’s safety tools will find spyware for you. They won’t. Safety Check on iPhone and the Accessibility list on Android help you check access, but neither one scans for spyware. So a clear result isn’t proof that your phone is clean. It only means that check didn’t show a problem with access.
What to do
- Check access today: use Safety Check on iPhone or review the Accessibility list on Android.
- Remember that neither one scans for spyware, so don’t treat a clear result as proof your phone is clean.
- If you suspect someone close, plan from a safer device first, because changing access or removing spyware can alert them.
Watch it in 60 seconds
