Mac sandbox escape
A sandboxed Mac app could escape its sandbox by using Apple Events to control TextEdit, which has an entitlement that removes the quarantine attribute from saved files. This allowed the app to execute arbitrary shell scripts outside the sandbox.
lapcatsoftware.com
Published on lapcatsoftware.com
This blog post discloses a sandbox escape on macOS. I reported the issue to Apple Product Security on December 19 2019, the day the Apple Security Bounty program finally opened.
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 entitlement 'com.apple.security.files.user-selected.executable' allows apps like TextEdit to save files without quarantine, and Apple Events can be used to make TextEdit save a malicious script, removing its quarantine and enabling execution outside the sandbox.
Impact
A sandboxed app could escape the sandbox and run arbitrary code, but the attack requires user approval of an Apple Events permission dialog.
What the attacker needed
MacOS 10.15.2 or 10.14.6; user clicks to allow Apple Events control
How it was found
- Build and run the sample app.
- Click to allow when the system dialog asks if the sample app can control TextEdit via Apple Events.
- The sample app opens a shell script in TextEdit and uses Apple Events to tell TextEdit to save the file, removing quarantine.
- The script is executed outside the sandbox, creating a file in /Users/Shared and saying 'hi'.
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 sandbox is a security feature that restricts what an app can do, like a playpen. This report shows that a malicious app could trick a trusted app (TextEdit) into helping it run code outside the playpen, by exploiting a special permission that removes a safety flag from files.