CVE-2023-42942: xpcroleaccountd Root Privilege Escalation
A race condition in xpcroleaccountd allowed replacing a copied XPC service bundle with a symbolic link, so that after signature verification the attacker could modify the bundle and have it launched as root. An attacker could escalate to root privileges.
jhftss.github.io
Published on jhftss.github.io
About two weeks ago, Apple published the CVE-2023-42942 in the security advisory. It was a race condition issue existed in the system service xpcroleaccountd, and it could be exploited for root privilege escalation.
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 a time-of-check to time-of-use (TOCTOU) race condition: the service copies a bundle to a temporary location, verifies its signature, but then uses the same path without ensuring it still points to the verified content, allowing a symbolic link to redirect to attacker-controlled files.
Impact
An attacker could escalate privileges to root by exploiting the race condition, as demonstrated by the researcher.
What the attacker needed
Local access to the system; ability to send XPC messages; timing to win the race condition
The fix
The issue was fixed in macOS 14.1 by adding a copyfile callback that checks if the destination is a symbolic link and aborts the copy if so.
How it was found
- Place the Apple-signed XPC service bundle at a writable location.
- Send an empty XPC message to the service bundle to trigger the issue.
- Before xpcroleaccountd calls copyfile, replace the bundle with a symbolic link pointing to the original Apple-signed bundle.
- After signature verification passes, modify the XPC bundle with a malicious payload.
- The malicious XPC bundle is launched with root privilege.
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.
A system service called xpcroleaccountd runs as root and helps launch special Apple-signed XPC services with root privileges. It copies the service to a temporary location, checks its signature, then moves it to a trusted place. The researcher found that by swapping the original service with a symbolic link (a shortcut to another file) during the copy, the signature check could be bypassed and a malicious version launched as root.
What is Race condition?
Parallel requests reach a state the code assumed could not happen: a coupon used twice, a limit overrun, a check skipped.