unnamed sandbox escape (CVE-2023-32364) - a macOS sandbox escape by mounting
A macOS sandbox escape was possible because the quarantine flag was only enforced on the top-level app directory and the executable, and an attacker could create a directory without the flag on a devfs mount and symlink the executable to bash. This allowed a sandboxed app to run code outside the sandbox.
Published on gergelykalman.com
This post is a writeup of CVE-2023-32364, a macOS application sandbox escape bug I found. It was supposed to be unveiled in my upcoming talk:
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
Impact
An attacker could escape the application sandbox and execute arbitrary commands outside the sandbox.
What the attacker needed
Sandboxed app; ability to mount devfs; user interaction to open app
The fix
Apple fixed this bug by preventing sandboxed applications from creating directories on devfs, and now also forces the app to have the .app extension.
How it was found
- Create a directory with the .app extension on a devfs mount without the quarantine flag.
- Symlink the executable inside the app to /bin/bash.
- Set environment variables like BASH_ENV via Info.plist to execute commands.
- Use the open command to launch the app via launchd, which runs bash outside the sandbox.
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.
macOS sandboxing is a security feature that limits what an app can do. The quarantine flag is a marker that tells macOS to warn you before opening downloaded files. The bug let a sandboxed app create a fake app that bypassed the quarantine check, so it could run commands outside the sandbox.