Next time someone sends a song to your iPhone, maybe consider if the sender is trustworthy. Apple killed two vulnerabilities with iOS 10.3 that allowed malicious code to run as soon as an audio file ran on its phones.

An anonymous hacker working with Trend Micro’s Zero Day Initiative (ZDI) disclosed the bugs, which affects Apple TV and watchOS too. Defined as a memory corruption flaw, Apple said it had addressed the problem with “improved input validation.” For undisclosed reasons, ZDI wasn’t permitted to talk about the bugs until today.

It appears to be similar to an exploit of Google’s Android operating system back in 2015, when researchers discovered they could hide exploit code in MP3s and MP4s. The problems derived from the way Android processed metadata within music files.

This time it was just MP4s (specifically .M4A audio files) that were used by the anonymous hacker to bypass Apple security. Both vulnerabilities took advantage of the fact that there was a lack of proper validation of the length of user-supplied data on iOS. As soon as a specially-crafted audio file was opened, malicious code could execute.

Quirky iOS bugs

The audio attack was one of many Apple has patched in the last week that were novel in their execution. Just yesterday, the tech giant released iOS 10.3.1 with a fix for a weakness that meant an attacker within range could have executed malicious code on the phone’s Wi-Fi chip. Google, whose Project Zero staffer Gal Beniamini discovered the bug, hadn’t provided more information on what the attack entailed.

It could be similar to an issue outlined last week, when Forbes reported on a hack that only required an iPhone join an evil Wi-Fi network to be compromised. The research, from Keen Lab’s Marco Grassi, was outlined at the Black Hat Asia conference and was also rewarded by the ZDI.

ZDI lead Brian Gorenc explained the researcher discovered a series of logic issues that when used in conjunction with a memory corruption bug meant he could run rogue code outside the iOS sandbox – software designed to contain malicious activity and prevent it from spreading across the operating system. Grassi exploited WebSheet, an app that launched when an iPhone connected to a public Wi-Fi network that required the user to go through a web portal to login. According to Gorenc, WebSheet was over-privileged. “[Grassi] combined this with the ability to silently install configuration profiles, and then manipulated legacy diagnostics to pivot to an un-sandboxed application,” he added. Though only highlighted in the iOS 10.3 release, the weaknesses were actually patched in 10.2.

Not only did Apple patch that critical weakness, it had to patch another 82 separate vulnerabilities in iOS 10.3 last week. Perhaps the most alarming was a hack that required the user just view a JPEG image for malicious code to run. Again, the issue was disclosed by an anonymous researcher via the Zero Day Initiative. There were three other flaws that meant an attacker could have their exploit running once the photo was processed by ImageIO, the component of iOS handling images.

As an added bonus for anyone downloading iOS 10.3 today, it’s shipping with the new and encrypted Apple File System (APFS), which should make it harder for hackers and police forensics teams to grab data in plain text from iPhones.

Apple strikes down Thunderbolt password hack

The Cupertino firm also released macOS Sierra 10.12.4 last week, where more critical vulnerabilities were addressed. That included a bug that meant a hacker could siphon off passwords for FileVault encrypted storage on a Mac, as discovered by Swedish security professional Ulf Frisk.

He told Forbes he found the flaw in August last year and it was quietly patched back in December, using what’s known as a direct memory access attack. He created a $300 device – a malicious Thunderbolt adapter – that could extract the passwords using that technique.

Describing the nature of the threat, Frisk added: “Imagine leaving your MacBook locked or at sleep in your hotel room. Anyone with access to it could just have plugged in this $300 device, rebooted it, gotten the FileVault password, typed the password and logged in as you – having access to all your files, your iCloud, everything. You might not even have noticed afterwards. I can imagine a tool like this being used by governments and industrial spies.”

Indeed, the Wikileaks CIA files released earlier this month showed the agency was working on similar techniques, using a rogue Thunderbolt-to-Ethernet adapter as a way into Apple Mac internals.