LC_LOAD_DYLIB Addition
Adversaries may establish persistence by executing malicious content triggered by the loading of a dynamically linked shared library. Mach-O binaries on macOS have a series of load commands that dictate how/when the binary is executed, including a set of libraries to load. The LC_LOAD_DYLIB command in a Mach-O binary tells macOS to load a specific dynamic library (.dylib) when that binary executes. Adversaries can add their own LC_LOAD_DYLIB load command to any Mach-O binary, causing their malicious library to be loaded whenever the modified binary is executed. This provides persistence that is triggered by the execution of legitimate binaries.
DeviceProcessEvents
| where Timestamp > ago(24h)
| where DeviceOSPlatform has_any ("macOS", "Mac", "Darwin")
| where FileName in~ ("install_name_tool", "otool", "codesign", "lipo", "jtool", "jtool2", "macho_tool")
| extend IsDylibOperation = ProcessCommandLine has_any (
"-add_rpath", "-change", "-rpath", "LC_LOAD_DYLIB",
"@rpath", "@loader_path", "@executable_path"
)
| extend TargetBinary = extract(@"(?:install_name_tool|otool)\s+(?:-[\w]+\s+){0,5}([\S]+\.(dylib|app|bundle|bin|[a-z]+))", 1, ProcessCommandLine)
| where IsDylibOperation
| project Timestamp, DeviceName, AccountName, FileName, ProcessCommandLine,
TargetBinary, IsDylibOperation,
InitiatingProcessFileName, InitiatingProcessCommandLine
| sort by Timestamp desc Data Sources
Required Tables
False Positives
- Developers legitimately modifying Mach-O binaries during build processes (install_name_tool is commonly used in Xcode build scripts to fix dylib paths)
- Homebrew and MacPorts package managers that use install_name_tool to relocate dylib paths when installing packages
- Codesigning workflows that modify binary metadata as part of CI/CD pipelines for macOS application development
- Security researchers and reverse engineers using otool/jtool for binary analysis on their own machines
References (5)
- https://attack.mitre.org/techniques/T1546/006/
- https://github.com/redcanaryco/atomic-red-team/blob/master/atomics/T1546.006/T1546.006.md
- https://www.virusbulletin.com/virusbulletin/2015/03/dylib-hijacking-os-x
- https://objective-see.org/blog.html
- https://developer.apple.com/library/archive/documentation/DeveloperTools/Conceptual/DynamicLibraries/100-Articles/DynamicLibraryDesignGuidelines.html
Unlock Pro Content
Get the full detection package for T1546.006 including response playbook, investigation guide, and atomic red team tests.