Skip to content
Access control Write-up Advanced

CVE-2021-1815 – macOS local privilege escalation via Preferences

A local privilege escalation flaw in macOS's cfprefsd daemon allowed an attacker to create arbitrary directories with user or root ownership. By creating a directory used for periodic scripts, an attacker could place a script that would later run as root.

offsectraining Follow

Published on offensive-security.com

Research & Tutorials

OffSec Team, on offensive-security.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 patch for CVE-2020-9839 prevented following symbolic links but still allowed the cfprefsd daemon to create directories with user or root ownership in attacker-controlled locations.

Impact

A local attacker could escalate privileges to root, gaining full control of the system.

What the attacker needed

Local access to the macOS system

How it was found

  1. Verify that the target directory and file do not already exist.
  2. Compile and run the exploit that sends an XPC message to the cfprefsd daemon.
  3. The daemon creates the directory structure and the attacker writes a script there.
  4. Simulate the execution of periodic scripts with sudo periodic daily.
  5. Confirm that the script ran as root by checking for the created file.

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.

On macOS, a background service called cfprefsd manages preferences. A bug let a normal user ask this service to create folders anywhere on the disk, even in places only the system should control. The attacker could then put a script in a folder that the system runs automatically as the all-powerful root user, giving them full control.

What is Access control?

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.

More by offsectraining

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.