Detect Shared Modules in Microsoft Sentinel
Adversaries may execute malicious payloads by loading shared modules into running processes. Shared modules are executable files (DLLs on Windows, .so on Linux, .dylib on macOS) loaded at runtime to provide reusable code or access OS API functions. Adversaries abuse this by loading malicious shared objects from arbitrary local paths or UNC network paths, allowing payload execution within the memory space of a legitimate host process. Windows uses LoadLibrary/LoadLibraryEx (via NTDLL.dll Native API), Linux uses dlopen/dlsym from dlfcn.h, and macOS uses both dlopen and Objective-C runtime calls. This technique enables modular malware architectures where the main dropper loads additional capability modules — seen in gh0st RAT, Astaroth, RotaJakiro, FoggyWeb, and BLINDINGCAN.
MITRE ATT&CK
- Tactic
- Execution
- Technique
- T1129 Shared Modules
- Canonical reference
- https://attack.mitre.org/techniques/T1129/
KQL Detection Query
let SuspiciousLoadPaths = dynamic([
"\\AppData\\Local\\Temp\\",
"\\AppData\\Roaming\\",
"\\Users\\Public\\",
"\\ProgramData\\Microsoft\\Windows\\Start Menu\\",
"\\Windows\\Temp\\",
"C:\\Temp\\",
"C:\\tmp\\",
"\\Downloads\\"
]);
let UNCPathPattern = @"\\\\[^\\]+\\[^\\]+\\.*\.dll";
let KnownGoodDirs = dynamic([
"\\Windows\\System32\\",
"\\Windows\\SysWOW64\\",
"\\Windows\\WinSxS\\",
"\\Program Files\\",
"\\Program Files (x86)\\"
]);
DeviceImageLoadEvents
| where Timestamp > ago(24h)
| where FileName endswith ".dll"
| where not(FolderPath has_any (KnownGoodDirs))
| where FolderPath has_any (SuspiciousLoadPaths)
or FolderPath matches regex UNCPathPattern
or (InitiatingProcessFileName in~ ("rundll32.exe", "regsvr32.exe", "mshta.exe", "wscript.exe", "cscript.exe", "msbuild.exe", "installutil.exe") and not(FolderPath has_any (KnownGoodDirs)))
| extend IsUNCPath = FolderPath matches regex @"^\\\\\\\\[^\\]+"
| extend IsTempPath = FolderPath has_any (SuspiciousLoadPaths)
| extend IsSuspiciousLoader = InitiatingProcessFileName in~ ("rundll32.exe", "regsvr32.exe", "mshta.exe", "wscript.exe", "cscript.exe", "msbuild.exe", "installutil.exe")
| extend IsUnsigned = isempty(Signer) or Signer == "" or IsCertificateValid == false
| project Timestamp, DeviceName, AccountName,
InitiatingProcessFileName, InitiatingProcessCommandLine,
FileName, FolderPath, SHA256,
Signer, IsCertificateValid,
IsUNCPath, IsTempPath, IsSuspiciousLoader, IsUnsigned
| sort by Timestamp desc Detects suspicious DLL/shared module loading via Microsoft Defender for Endpoint DeviceImageLoadEvents. Identifies modules loaded from high-risk locations (Temp, AppData, Public, Windows\Temp), UNC network paths, and suspicious host processes (rundll32, regsvr32, mshta, wscript, msbuild, installutil) loading from non-standard directories. Augments signal by flagging unsigned or invalid-certificate modules. This covers Windows LoadLibrary/LoadLibraryEx abuse patterns seen in modular malware families.
Data Sources
Required Tables
False Positives & Tuning
- Legitimate software installers temporarily staging DLLs in %TEMP% before moving them to installation directories
- Developer tools (Visual Studio, JetBrains IDEs) loading debug or test assemblies from user-writable paths during development builds
- Enterprise software with non-standard installation paths (e.g., installed to C:\Tools or user home directories by portable apps)
- Security tools and EDR agents loading kernel modules or helper DLLs from non-standard paths during startup
- Virtualization software (VMware Tools, VirtualBox Guest Additions) loading drivers from paths outside System32
Other platforms for T1129
Testing Methodology
Validate this detection against 5 adversary techniques from Atomic Red Team. Each test below lists the behaviour to exercise and the telemetry you should expect to see. Executable commands and cleanup steps are available with Pro.
- Test 1Load DLL from Temp Directory via rundll32
Expected signal: Sysmon Event ID 7 (ImageLoad): ImageLoaded path will be %TEMP%\df00tech-test-module.dll, Image will be C:\Windows\System32\rundll32.exe. Sysmon Event ID 1 (Process Create): rundll32.exe with command line containing the Temp path. Security Event ID 4688 if command line auditing is enabled.
- Test 2Load DLL via PowerShell Assembly.LoadFile from AppData
Expected signal: Sysmon Event ID 7: ImageLoaded will show AppData\Roaming\df00tech-module.dll loaded by powershell.exe. Sysmon Event ID 1: PowerShell process creation with LoadFile command. Sysmon Event ID 11: File creation of df00tech-module.dll in AppData\Roaming.
- Test 3Load Shared Object from /tmp via dlopen on Linux
Expected signal: Auditd syscall events: openat(2) call to /tmp/df00tech_test_module.so from python3 process. Linux audit event type=EXECVE for gcc and python3. If using Falco or Sysdig: proc.name=python3 with fd.name=/tmp/*.so triggers shared lib load from tmp rule. Syslog entry if auditd is configured to monitor /tmp for file opens.
- Test 4Regsvr32 Loading Unregistered DLL from User-Writable Path
Expected signal: Sysmon Event ID 7 (ImageLoad): ImageLoaded=C:\Windows\Temp\df00tech-reg-test.dll, Image=C:\Windows\System32\regsvr32.exe. Sysmon Event ID 1: regsvr32.exe with /s flag and the temp path. The /s flag suppresses the dialog box — this silence flag is itself a behavioral indicator used in malware deployment.
- Test 5Load dylib from /tmp on macOS via Python ctypes
Expected signal: macOS Endpoint Security Framework: ES_EVENT_TYPE_NOTIFY_MMAP event for the dylib mmap into python3 process address space. Unified log (log stream --predicate 'subsystem == "com.apple.dyld"') shows dylib load from /tmp. If Jamf Protect or CrowdStrike Falcon is deployed: 'Shared Library Loaded from /tmp' detection fires.
References (10)
- https://attack.mitre.org/techniques/T1129/
- https://learn.microsoft.com/troubleshoot/windows-client/deployment/dynamic-link-library
- https://developer.apple.com/library/archive/documentation/DeveloperTools/Conceptual/DynamicLibraries/100-Articles/OverviewOfDynamicLibraries.html
- https://tldp.org/HOWTO/Program-Library-HOWTO/shared-libraries.html
- https://blog.netlab.360.com/stealth_rotajakiro_backdoor_en/
- https://unit42.paloaltonetworks.com/unit42-new-improved-macos-backdoor-oceanlotus/
- https://github.com/redcanaryco/atomic-red-team/blob/master/atomics/T1129/T1129.md
- https://learn.microsoft.com/en-us/sysinternals/downloads/sysmon
- https://github.com/SigmaHQ/sigma/tree/master/rules/windows/image_load
- https://www.elastic.co/guide/en/security/current/prebuilt-rules.html
Unlock Pro Content
Get the full detection package for T1129 including response playbook, investigation guide, and atomic red team tests.