You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: src/macos-hardening/macos-security-and-privilege-escalation/macos-files-folders-and-binaries/macos-bundles.md
+63-2Lines changed: 63 additions & 2 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -10,7 +10,7 @@ Bundles in macOS serve as containers for a variety of resources including applic
10
10
11
11
Within a bundle, particularly within the `<application>.app/Contents/` directory, a variety of important resources are housed:
12
12
13
-
-**\_CodeSignature**: This directory stores code-signing details vital for verifying the integrity of the application. You can inspect the code-signing information using commands like:
13
+
-**\_CodeSignature**: This directory stores code-signing details vital for verifying the integrity of the application. You can inspect the code-signing information using commands like:
@@ -44,7 +44,68 @@ This structure ensures that all necessary components are encapsulated within the
44
44
45
45
For more detailed information on `Info.plist` keys and their meanings, the Apple developer documentation provides extensive resources: [Apple Info.plist Key Reference](https://developer.apple.com/library/archive/documentation/General/Reference/InfoPlistKeyReference/Introduction/Introduction.html).
-**Gatekeeper / App Translocation**: When a quarantined bundle is first executed, macOS performs a deep signature verification and may run it from a randomized translocated path. Once accepted, later launches only perform shallow checks; resource files in `Resources/`, `PlugIns/`, nibs, etc., were historically unchecked. Since macOS 13 Ventura a deep check is enforced on first run and the new *App Management* TCC permission restricts third‑party processes from modifying other bundles without user consent, but older systems remain vulnerable.
50
+
-**Bundle Identifier collisions**: Multiple embedded targets (PlugIns, helper tools) reusing the same `CFBundleIdentifier` can break signature validation and occasionally enable URL‑scheme hijacking/confusion. Always enumerate sub‑bundles and verify unique IDs.
51
+
52
+
## Resource Hijacking (Dirty NIB / NIB Injection)
53
+
54
+
Before Ventura, swapping UI resources in a signed app could bypass shallow code signing and yield code execution with the app’s entitlements. Current research (2024) shows this still works on pre‑Ventura and on un-quarantined builds:
55
+
56
+
1. Copy target app to a writable location (e.g., `/tmp/Victim.app`).
57
+
2. Replace `Contents/Resources/MainMenu.nib` (or any nib declared in `NSMainNibFile`) with a malicious one that instantiates `NSAppleScript`, `NSTask`, etc.
58
+
3. Launch app. The malicious nib executes under the victim’s bundle ID and entitlements (TCC grants, microphone/camera, etc.).
59
+
4. Ventura+ mitigates by deep‑verifying the bundle on first launch and requiring *App Management* permission for later modifications, so persistence is harder but initial-launch attacks on older macOS still apply.
60
+
61
+
Minimal malicious nib payload example (compile xib to nib with `ibtool`):
62
+
```bash
63
+
# create a nib that runs osascript -e 'do shell script "id"'
Because `@rpath` lookups prefer bundled Frameworks/PlugIns, dropping a malicious library inside `Contents/Frameworks/` or `Contents/PlugIns/` can redirect load order when the main binary is signed without library validation or with weak `LC_RPATH` ordering.
73
+
74
+
Typical steps when abusing an unsigned/ad‑hoc bundle:
- XPC services under `Contents/XPCServices/` often load sibling frameworks—patch their binaries similarly for persistence or privilege escalation paths.
-[Bringing process injection into view(s): exploiting macOS apps using nib files (2024)](https://sector7.computest.nl/post/2024-04-bringing-process-injection-into-view-exploiting-all-macos-apps-using-nib-files/)
0 commit comments