Adversaries may execute their own payloads by placing a malicious dynamic library (dylib) with an expected name in a path a victim application searches at runtime. The dynamic loader will try to find the dylibs based on the sequential order of the search paths. Paths to dylibs may be prefixed with <code>@rpath</code>, which allows developers to use relative paths to specify an array of search paths used at runtime based on the location of the executable. Additionally, if weak linking is used, such as the <code>LC_LOAD_WEAK_DYLIB</code> function, an application will still execute even if an expected dylib is not present. Weak linking enables developers to run an application on multiple macOS versions as new APIs are added.
Adversaries may gain execution by inserting malicious dylibs with the name of the missing dylib in the identified path.(Citation: Wardle Dylib Hijack Vulnerable Apps)(Citation: Wardle Dylib Hijacking OSX 2015)(Citation: Github EmpireProject HijackScanner)(Citation: Github EmpireProject CreateHijacker Dylib) Dylibs are loaded into an application's address space allowing the malicious dylib to inherit the application's privilege level and resources. Based on the application, this could result in privilege escalation and uninhibited network access. This method may also evade detection from security products since the execution is masked under a legitimate process.(Citation: Writing Bad Malware for OSX)(Citation: wardle artofmalware volume1)(Citation: MalwareUnicorn macOS Dylib Injection MachO)
View in MITRE ATT&CK®Capability ID | Capability Description | Mapping Type | ATT&CK ID | ATT&CK Name |
---|---|---|---|---|
AC-2 | Account Management | Protects | T1574.004 | Dylib Hijacking |
AC-3 | Access Enforcement | Protects | T1574.004 | Dylib Hijacking |
AC-4 | Information Flow Enforcement | Protects | T1574.004 | Dylib Hijacking |
AC-5 | Separation of Duties | Protects | T1574.004 | Dylib Hijacking |
AC-6 | Least Privilege | Protects | T1574.004 | Dylib Hijacking |
CA-7 | Continuous Monitoring | Protects | T1574.004 | Dylib Hijacking |
CM-2 | Baseline Configuration | Protects | T1574.004 | Dylib Hijacking |
CM-6 | Configuration Settings | Protects | T1574.004 | Dylib Hijacking |
CM-8 | System Component Inventory | Protects | T1574.004 | Dylib Hijacking |
RA-5 | Vulnerability Monitoring and Scanning | Protects | T1574.004 | Dylib Hijacking |
SI-3 | Malicious Code Protection | Protects | T1574.004 | Dylib Hijacking |
SI-4 | System Monitoring | Protects | T1574.004 | Dylib Hijacking |
SI-7 | Software, Firmware, and Information Integrity | Protects | T1574.004 | Dylib Hijacking |