COR_PROFILER
Adversaries abuse the .NET Common Language Runtime (CLR) profiling API via the COR_PROFILER and COR_ENABLE_PROFILING environment variables to load malicious DLLs into every .NET process. Setting COR_ENABLE_PROFILING=1 and COR_PROFILER={CLSID} causes any .NET application to load the registered COM profiler DLL. Starting with .NET 4.0, the COR_PROFILER_PATH variable can directly specify the DLL path without COM registration, enabling in-memory persistence. Blue Mockingbird used wmic.exe to set these registry variables system-wide, loading a malicious DLL into .NET processes. The Invisi-Shell tool uses this technique to bypass PowerShell logging. DarkTortilla malware checks for COR_ENABLE_PROFILING to detect sandbox analysis.
let CORProfilerKeys = dynamic([
"COR_ENABLE_PROFILING",
"COR_PROFILER",
"COR_PROFILER_PATH",
"CORECLR_ENABLE_PROFILING",
"CORECLR_PROFILER",
"CORECLR_PROFILER_PATH"
]);
DeviceRegistryEvents
| where Timestamp > ago(24h)
| where RegistryKey has "Environment"
| where RegistryValueName in~ (CORProfilerKeys)
| where not(InitiatingProcessFileName in~ ("msiexec.exe", "svchost.exe", "services.exe"))
| project Timestamp, DeviceName, AccountName, RegistryKey, RegistryValueName, RegistryValueData, InitiatingProcessFileName
| sort by Timestamp desc
| union (
DeviceProcessEvents
| where Timestamp > ago(24h)
| where ProcessCommandLine has_any (CORProfilerKeys)
| project Timestamp, DeviceName, AccountName, FileName, ProcessCommandLine, InitiatingProcessFileName
)
| sort by Timestamp desc Data Sources
Required Tables
False Positives
- Legitimate .NET profiling tools (dotMemory, dotTrace, JetBrains Rider) that set COR_PROFILER during development sessions
- Performance monitoring platforms (Dynatrace, New Relic, AppDynamics) that inject .NET agents via COR_PROFILER
- Code coverage tools (OpenCover, Coverlet) used in CI/CD pipelines that use COR_PROFILER for instrumentation
- Visual Studio diagnostic and performance profiling sessions
References (6)
- https://attack.mitre.org/techniques/T1574/012/
- https://redcanary.com/blog/cor_profiler-for-persistence/
- https://redcanary.com/blog/blue-mockingbird-cryptominer/
- https://github.com/OmerYa/Invisi-Shell
- https://offsec.almond.consulting/UAC-bypass-dotnet.html
- https://github.com/redcanaryco/atomic-red-team/blob/master/atomics/T1574.012/T1574.012.md
Unlock Pro Content
Get the full detection package for T1574.012 including response playbook, investigation guide, and atomic red team tests.