T1574.004 Dylib Hijacking
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 @rpath
, 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 LC_LOAD_WEAK_DYLIB
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.5378 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.461
Item | Value |
---|---|
ID | T1574.004 |
Sub-techniques | T1574.001, T1574.002, T1574.004, T1574.005, T1574.006, T1574.007, T1574.008, T1574.009, T1574.010, T1574.011, T1574.012, T1574.013 |
Tactics | TA0003, TA0004, TA0005 |
Platforms | macOS |
Version | 2.0 |
Created | 16 March 2020 |
Last Modified | 30 March 2023 |
Procedure Examples
ID | Name | Description |
---|---|---|
S0363 | Empire | Empire has a dylib hijacker module that generates a malicious dylib given the path to a legitimate dylib of a vulnerable application.9 |
Mitigations
ID | Mitigation | Description |
---|---|---|
M1022 | Restrict File and Directory Permissions | Set directory access controls to prevent file writes to the search paths for applications, both in the folders where applications are run from and the standard dylib folders. |
Detection
ID | Data Source | Data Component |
---|---|---|
DS0022 | File | File Creation |
DS0011 | Module | Module Load |
References
-
Amanda Rousseau. (2020, April 4). MacOS Dylib Injection Workshop. Retrieved March 29, 2021. ↩
-
Apple Inc.. (2012, July 7). Run-Path Dependent Libraries. Retrieved March 31, 2021. ↩
-
Patrick Wardle. (2015, March 1). Dylib Hijacking on OS X. Retrieved March 29, 2021. ↩
-
Patrick Wardle. (2015). Writing Bad @$$ Malware for OS X. Retrieved July 10, 2017. ↩
-
Patrick Wardle. (2019, July 2). Getting Root with Benign AppStore Apps. Retrieved March 31, 2021. ↩
-
Patrick Wardle. (2020, August 5). The Art of Mac Malware Volume 0x1: Analysis. Retrieved March 19, 2021. ↩
-
Wardle, P., Ross, C. (2017, September 21). Empire Project Dylib Hijack Vulnerability Scanner. Retrieved April 1, 2021. ↩
-
Wardle, P., Ross, C. (2018, April 8). EmpireProject Create Dylib Hijacker. Retrieved April 1, 2021. ↩
-
Schroeder, W., Warner, J., Nelson, M. (n.d.). Github PowerShellEmpire. Retrieved April 28, 2016. ↩