T1574.006: 动态链接器劫持
摘要
攻击者可能通过劫持动态链接器用于加载共享库的环境变量来执行自己的恶意载荷。在程序的执行准备阶段,动态链接器从各种环境变量和文件中加载共享库的指定绝对路径,例如 Linux 上的 <code>LD_PRELOAD</code> 或 macOS 上的 <code>DYLD_INSERT_LIBRARIES</code>。(Citation: TheEvilBit DYLD_INSERT_LIBRARIES)(Citation: Timac DYLD_INSERT_LIBRARIES)(Citation: Gabilondo DYLD_INSERT_LIBRARIES Catalina Bypass) 在环境变量中指定的库会首先加载,优先于具有相同函数名的系统库。(Citation: Man LD.SO)(Citation: TLDP Shared Libraries)(Citation: Apple Doco Archive Dynamic Libraries) 每个平台的链接器在执行的不同阶段使用一长串环境变量。这些变量通常被开发者用于在不重新编译的情况下调试二进制文件、消除映射符号冲突,以及在原始库中实现自定义函数。(Citation: Baeldung LD_PRELOAD) 劫持动态链接器变量可能授予对受害者进程内存、系统/网络资源的访问权,以及可能的提升权限。在 Linux 上,攻击者可能设置 <code>LD_PRELOAD</code> 指向与受害者程序所请求的合法库同名的恶意库,导致操作系统在受害者程序执行时加载攻击者的恶意代码。例如,攻击者曾使用 `LD_PRELOAD` 将恶意库注入到 `sshd` 守护进程的每个派生进程中,导致在合法进程下执行。当执行的子进程调用 `execve` 函数时,例如,恶意库的 `execve` 函数会被执行,而不是磁盘上系统库中包含的系统函数 `execve`。这使攻击者能够[隐藏痕迹](https://attack.mitre.org/techniques/T1564)以逃避检测,因为挂钩诸如 `execve` 和 `readdir` 之类的系统函数使恶意软件能够从 `ls`、`ldd`、`iptables` 和 `dmesg` 等命令的结果中清除自身的痕迹。(Citation: ESET Ebury Oct 2017)(Citation: Intezer Symbiote 2022)(Citation: Elastic Security Labs Pumakit 2024) 劫持动态链接器变量可能授予对受害者进程内存、系统/网络资源的访问权,以及可能的提升权限。
来源归属
来源:MITRE ATT&CK · 置信度:high
平台
- Linux
- macOS
战术
Stealth
参考来源
- https://attack.mitre.org/techniques/T1574/006
- https://developer.apple.com/library/archive/documentation/DeveloperTools/Conceptual/DynamicLibraries/100-Articles/OverviewOfDynamicLibraries.html
- https://www.baeldung.com/linux/ld_preload-trick-what-is
- https://theevilbit.github.io/posts/dyld_insert_libraries_dylib_injection_in_macos_osx_deep_dive/
- https://intezer.com/blog/research/new-linux-threat-symbiote/
- https://jon-gabilondo-angulo-7635.medium.com/how-to-inject-code-into-mach-o-apps-part-ii-ddb13ebc8191
- https://www.man7.org/linux/man-pages/man8/ld.so.8.html
- https://www.elastic.co/security-labs/declawing-pumakit
- https://www.tldp.org/HOWTO/Program-Library-HOWTO/shared-libraries.html
- https://blog.timac.org/2012/1218-simple-code-injection-using-dyld_insert_libraries/
- https://www.welivesecurity.com/2017/10/30/windigo-ebury-update-2/