CVE-2023-23525: Get Root via A Fake Installer
The default application for opening PKG files could be changed to a fake installer that mimics the system installer. When a user granted root privileges to install a package, the fake installer could abuse the authorization to run arbitrary code with root privileges.
Published on jhftss.github.io
A few weeks ago, Rich Trouton noticed a new change in the latest macOS release: macOS Ventura 13.3 alters expected behavior for Finder’s Open With functionality for macOS installer packages. In this post, I want to share a simple LPE vulnerability associated with it and why Apple made the change.
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, macOS allowed users to change the default handler for installer package files, so a fake installer could receive the user's authorisation and misuse it.
Impact
A user who granted root privileges to the fake installer could have arbitrary code executed with root privileges.
What the attacker needed
Local access to the Mac; user opens a PKG file; user grants root privileges
The fix
Apple changed macOS so that users can no longer change the default application for PKG files.
How it was found
- Copy the system Installer.app to /Applications and remove its code signature.
- Replace the app's executable with a trampoline that injects a dynamic library and launches the original installer.
- Change the bundle identifier and re-sign the app ad hoc.
- Register the fake installer with LaunchServices and set it as the handler for the package file type.
- When the user opens a package and grants root privileges, the injected library hooks the authorisation call and runs a payload with root privileges.
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, double-clicking a package file normally opens the system installer, which asks for an administrator password. The researcher showed that the default app for package files could be swapped for a lookalike app, so the password prompt came from the fake app. Once the user approved, the fake app could use that approval to run its own commands as the administrator.
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.