Skip to content
Race condition Write-up Advanced

CVE-2019-8561: A Hard-to-Banish PackageKit Framework Vulnerability in macOS

A time-of-check-to-time-of-use flaw in macOS PackageKit allowed an attacker to replace an Apple-signed PKG file with a malicious one after signature verification, so that malicious install scripts ran with root privileges and bypassed System Integrity Protection. The same flaw remained exploitable after the first patch because extraction opened the PKG file again without re-verifying its digest.

Mickey Jin Follow

Published on trendmicro.com

This blog entry details our investigation of CVE-2019-8561, a vulnerability that exists in the macOS PackageKit framework, a component used to install software installer packages (PKG files).

Mickey Jin (@patch1t), on trendmicro.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 installer verified the package digest once but later reopened the package file by path without re-checking the digest, creating a time-of-check-to-time-of-use race.

Impact

An attacker could gain root privileges, bypass code-signing checks and bypass System Integrity Protection, though the race window was small and the crafted package had to match the original file's internal offsets.

What the attacker needed

Local access to the Mac; ability to start a package install; win a narrow race window; crafted package with matching offsets

The fix

Apple patched it again in macOS Ventura by reading the package through a stream that updates a digest during extraction and comparing the real checksum with the expected one afterwards.

How it was found

  1. Install an Apple-signed PKG file that contains post-install scripts.
  2. The system_installd daemon handles the install request.
  3. During script extraction, replace the PKG file with a crafted one after the digest check and before the file is opened.
  4. The service extracts the malicious scripts from the crafted PKG file.
  5. Restore the original Apple-signed PKG file so later checks pass.
  6. The extracted scripts run as root in a SIP-bypass context.

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.

When macOS installs a signed package, it first checks that the package really comes from Apple. This bug let an attacker swap the package for a malicious one in the short moment after that check but before the installer read the files, so the installer ran the attacker's scripts with the highest level of permission. That level of permission normally cannot be obtained even by the root user because of a protection called System Integrity Protection.

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.

More by Mickey Jin

View all

113 more disclosed reports, 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.

Race conditions

The lesson behind this report.

Parallel requests reach a state the code assumed could not happen: a coupon used twice, a limit overrun, a check skipped.