Skip to content
Access control Write-up Advanced

iPhone Camera Hack

Safari mishandled URI parsing, origin management and secure-context initialisation, letting a malicious site impersonate a trusted site such as Skype or Zoom. An attacker could then use JavaScript to reach the victim's webcam and microphone without a permission prompt.

Ryan Pickren Follow

Published on ryanpickren.com

Bounty$75,000 View original

Imagine you are on a popular website when all of a sudden an ad banner hijacks your camera and microphone to spy on you. That is exactly what this vulnerability would have allowed.

Ryan Pickren, on ryanpickren.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.

Written with AI from the full original report and checked against it passage by passage; anything it could not back up was removed or toned down. The original is the record. 4 min read.

Context

This is a write-up of a Safari vulnerability chain that let unauthorised websites access the camera on iOS and macOS. The attack let a malicious site masquerade as a trusted site when viewed in Desktop Safari (for example on a Mac) or Mobile Safari (on an iPhone or iPad). The researcher's framing is that an ad banner on a popular site could hijack the camera and microphone to spy on the user.

The mechanism depends on a normal Safari feature: users can permanently save security settings on a per-website basis. Safari remembers which sites a user has trusted, and that trust is what the attack abuses. If a malicious site wanted camera access, it only had to masquerade as a trusted video-conferencing site such as Skype or Zoom.

The research uncovered seven zero-day vulnerabilities in Safari: CVE-2020-3852, CVE-2020-3864, CVE-2020-3865, CVE-2020-3885, CVE-2020-3887, CVE-2020-9784 and CVE-2020-9787. Three of them were used in the kill chain to reach the camera. In plain terms, the bug tricked Apple into thinking a malicious website was actually a trusted one. It did this by exploiting a series of flaws in how Safari parsed URIs, managed web origins and initialised secure contexts.

Setup

In the demonstration the victim had previously trusted skype.com, the site the attack impersonated. In the demonstration the victim had previously trusted skype.com. The attacker needs only the ability to run JavaScript that can create a popup. That includes a standalone website, an embedded ad banner or a browser extension.

The researcher reported the issue to Apple under the Security Bounty Program rules and used BugPoC to give Apple a live demo. Apple classified the exploit in the "Network Attack without User Interaction: Zero-Click Unauthorized Access to Sensitive Data" category and awarded $75,000. The technical walkthrough of how the bug was found is published separately.

Finding it

The starting point is the per-site security model. Safari stores trust decisions per website, so the origin of a page is what decides whether the camera can be opened without a prompt. That makes origin handling the interesting surface: if a page can be made to look like a different origin to Safari's own checks, the stored trust for the impersonated site applies.

The researcher's analysis identified three areas where Safari's handling could disagree with itself: URI parsing, origin management and secure context initialisation. Chaining flaws across those three areas is what produced the impersonation. The report does not walk through the individual parsing edge cases; it states the three areas and that three of the seven CVEs formed the chain.

Exploitation

Step 1: Get JavaScript that can open a popup

Any JavaScript code with the ability to create a popup can launch the attack. The report names a standalone website, an embedded ad banner and a browser extension as sufficient. No specific payload is given in the report.

Step 2: Masquerade as a trusted site

The malicious page uses the URI parsing, origin and secure context flaws so that Safari treats it as the trusted site, for example a video-conferencing site such as Skype or Zoom. The victim in the screen recording had previously trusted skype.com, which is the trust the attack borrows.

Step 3: Access the camera directly

With the impersonation in place, the page uses JavaScript to access the victim's webcam directly, without asking for permission. The report does not include the JavaScript used.

The screen recording below shows what the attack would look like if launched from Twitter.

Root cause

The flaws were in how Safari parsed URIs, managed web origins and initialised secure contexts; chaining them let a malicious page be treated as a trusted one. When those three disagree, a malicious page can present itself as a trusted origin and inherit that origin's saved permissions, including camera access. The page accessed the webcam without asking for permission, because Safari treated it as the trusted site. The report does not detail the individual code defects behind each CVE.

Impact

An attacker who can run popup-capable JavaScript, through a website, an ad banner or a browser extension, can access the victim's camera without a permission prompt, provided the victim has previously trusted the site being impersonated. The researcher's framing is that an ad banner could hijack the camera and microphone. It affects both Desktop Safari and Mobile Safari, so Mac, iPhone and iPad users are in scope. Apple treated it as zero-click unauthorised access to sensitive data.

Fix

The report does not describe the patches Apple shipped for the seven CVEs.

Variants to test

  1. Per-site permission stores in other browsers: check whether a page can be made to resolve to a different origin for permission lookup than for rendering. A positive result is a stored camera or microphone grant being applied to a page you control.
  2. URI parsing differences: feed the browser URLs with unusual encodings, userinfo, backslashes or mixed case in the host, and compare the origin the browser reports with the origin used for permission checks. A positive result is a mismatch between the two.
  3. Secure context checks: load a page over a non-secure channel but have it treated as a secure context through a parsing quirk. A positive result is access to APIs that should require a secure context.
  4. Popup-capable injection points: test ad banners and extensions as launch vectors, since the report names them explicitly. A positive result is the full chain running from an embedded context without navigation by the user.

Written with AI from the full original report and checked against it passage by passage; anything it could not back up was removed or toned down. The original is the record. 5 min read.

What happened, in plain words

A security researcher found a way to make Safari, Apple's web browser, believe that a malicious website was actually a trusted one. This let the malicious site open your camera and microphone without asking permission. The attack worked on both Mac computers (Desktop Safari) and iPhones or iPads (Mobile Safari).

The researcher reported the bug to Apple, which paid a bounty of $75,000. Apple classified the attack as "zero-click" unauthorised access to sensitive data. The report says any JavaScript able to create a popup, such as an ad banner or browser extension, could launch it.

Background: how Safari handles permissions

Safari lets you save security settings for each website. For example, you can tell Safari to always allow a site like skype.com to use your camera, so you don't have to approve it every time. Safari remembers this choice and applies it whenever you visit that site.

The attack abuses this trust. If a malicious site can trick Safari into thinking it is skype.com, then Safari will automatically give it camera access, because you already trusted skype.com.

The vulnerability

The researcher found seven zero-day vulnerabilities in Safari. A zero-day is a bug that the vendor (here, Apple) does not know about yet, so there is no fix at the time of discovery. The seven are tracked as CVE-2020-3852, CVE-2020-3864, CVE-2020-3865, CVE-2020-3885, CVE-2020-3887, CVE-2020-9784 and CVE-2020-9787. A CVE is a unique identifier for a publicly known security flaw.

Three of these bugs were used together in a chain to access the camera. The chain exploited how Safari:

  • parses URIs (web addresses),
  • manages web origins (the combination of protocol, host and port that identifies a site), and
  • initialises secure contexts (a secure context is a page loaded over HTTPS, which is required for many powerful features like camera access).

By combining flaws in these three areas, a malicious site could make Safari treat it as a different, trusted site.

How the attack works

Step 1: Get JavaScript that can open a popup

The attacker needs to run JavaScript that can create a popup window. JavaScript is the programming language of web pages. A popup is a new browser window opened by a script. The report says this can be done from:

  • a standalone website,
  • an embedded ad banner (ads are often JavaScript that runs inside other pages), or
  • a browser extension (an add-on installed in the browser).

No specific code is given for this step.

Step 2: Masquerade as a trusted site

The malicious page uses the URI parsing, origin and secure context flaws to make Safari believe it is the trusted site, such as a video-conferencing site like Skype or Zoom. In the demonstration, the victim had previously trusted skype.com, so the attack borrowed that trust.

Step 3: Access the camera directly

Once Safari is convinced the page is the trusted site, the page uses JavaScript to open the webcam without any permission prompt. The report does not include the JavaScript used for this.

The screen recording below shows what the attack would look like if launched from Twitter.

  • The victim in the screen recording had previously trusted skype.com.

Why it works (root cause)

Safari's per-site permissions are tied to the site's identity. But that identity is determined by how Safari parses the URI, manages origins and sets up secure contexts. By exploiting flaws in these three areas, a malicious page could make Safari treat it as a trusted site and access the camera. The page accessed the webcam without asking for permission, because Safari treated it as the trusted site. The report does not detail the individual code defects behind each CVE.

Impact

An attacker who can run popup-capable JavaScript (via a website, ad banner or browser extension) can access the victim's camera without a prompt, as long as the victim has previously trusted the site being impersonated. The researcher's framing is that an ad banner could hijack the camera and microphone. It affects both Desktop Safari and Mobile Safari, so Mac, iPhone and iPad users are at risk. Apple classified it as "Network Attack without User Interaction: Zero-Click Unauthorized Access to Sensitive Data".

Fix

The report does not describe the patches Apple shipped for the seven CVEs.

Variants to test

  1. Per-site permission stores in other browsers: Check whether a page can be made to resolve to a different origin for permission lookup than for rendering. A positive result is a stored camera or microphone grant being applied to a page you control.
  2. URI parsing differences: Feed the browser URLs with unusual encodings, userinfo, backslashes or mixed case in the host, and compare the origin the browser reports with the origin used for permission checks. A positive result is a mismatch between the two.
  3. Secure context checks: Load a page over a non-secure channel but have it treated as a secure context through a parsing quirk. A positive result is access to APIs that should require a secure context.
  4. Popup-capable injection points: Test ad banners and extensions as launch vectors, since the report names them explicitly. A positive result is the full chain running from an embedded context without navigation by the user.

Glossary

  • Zero-day: A vulnerability that is unknown to the vendor and has no patch yet.
  • CVE: A unique identifier assigned to a publicly disclosed cybersecurity vulnerability.
  • URI: A string that identifies a resource on the web, such as a URL.
  • Origin: The combination of protocol, host and port that defines a website's security boundary.
  • Secure context: A page loaded over HTTPS (or from localhost) that is considered secure and can use powerful features like camera access.
  • JavaScript: The programming language used to make web pages interactive.
  • Popup: A new browser window opened by a script.
  • Ad banner: An advertisement embedded in a web page, often using JavaScript.
  • Browser extension: A software module that adds features to a browser.
  • Permission prompt: A dialog asking the user to allow or deny access to a resource like the camera.
  • Kill chain: A sequence of steps that together achieve an attack.
  • Bounty: A reward paid by a company for reporting a security vulnerability.
  • BugPoC: A service for creating proof-of-concept demonstrations of bugs.
  • API: Application Programming Interface, a set of rules that lets software components communicate.

More by Ryan Pickren

View all

1 more disclosed report, best first.

More from Apple

View all

The newest disclosed reports for this program.

Similar reports

View all

Same bug class and techniques, clearest first.

Broken access control

The lesson behind this report.

A user can do something their role should not allow: reach an admin function, act on a feature they have not paid for, or skip a permission check. IDOR is the special case where the object belongs to someone else.