COR_PROFILER

T1574.012

Sub-technique of T1574 Hijack Execution Flow.View on attack.mitre.org

About this technique

Adversaries may leverage the COR_PROFILER environment variable to hijack the execution flow of programs that load the .NET CLR. The COR_PROFILER is a .NET Framework feature which allows developers to specify an unmanaged (or external of .NET) profiling DLL to be loaded into each .NET process that loads the Common Language Runtime (CLR). These profilers are designed to monitor, troubleshoot, and debug managed code executed by the .NET CLR.

The COR_PROFILER environment variable can be set at various scopes (system, user, or process) resulting in different levels of influence. System and user-wide environment variable scopes are specified in the Registry, where a Component Object Model (COM) object can be registered as a profiler DLL. A process scope COR_PROFILER can also be created in-memory without modifying the Registry. Starting with .NET Framework 4, the profiling DLL does not need to be registered as long as the location of the DLL is specified in the COR_PROFILER_PATH environment variable.

Adversaries may abuse COR_PROFILER to establish persistence that executes a malicious DLL in the context of all .NET processes every time the CLR is invoked. The COR_PROFILER can also be used to elevate privileges (ex: Bypass User Account Control) if the victim .NET process executes at a higher permission level, as well as to hook and impair defenses provided by .NET processes.

Detection rules2

Rules on DetectionCode tagged with T1574.012.

Sigma2

RuleLevelLog source
Enabling COR Profiler Environment Variablesmediumwindows / registry_set
Registry-Free Process Scope COR_PROFILERmediumwindows / ps_script

Splunk0

No Splunk rules are mapped to this technique yet.

Groups1

Software1

Campaigns0

None recorded.

Procedure examples2

Groups1

Used byProcedure example
GroupBlue Mockingbird

Blue Mockingbird has used wmic.exe and Windows Registry modifications to set the COR_PROFILER environment variable to execute a malicious DLL whenever a process loads the .NET CLR.

Software1

Used byProcedure example
MalwareDarkTortilla

DarkTortilla can detect profilers by verifying the `COR_ENABLE_PROFILING` environment variable is present and active.

References7

  1. Almond COR_PROFILER Apr 2019 Open source
    Almond. (2019, April 30). UAC bypass via elevated .NET applications. Retrieved June 24, 2020.
  2. GitHub OmerYa Invisi-Shell Open source
    Yair, O. (2019, August 19). Invisi-Shell. Retrieved June 24, 2020.
  3. Microsoft COR_PROFILER Feb 2013 Open source
    Microsoft. (2013, February 4). Registry-Free Profiler Startup and Attach. Retrieved June 24, 2020.
  4. Microsoft Profiling Mar 2017 Open source
    Microsoft. (2017, March 30). Profiling Overview. Retrieved June 24, 2020.
  5. Red Canary COR_PROFILER May 2020 Open source
    Brown, J. (2020, May 7). Detecting COR_PROFILER manipulation for persistence. Retrieved June 24, 2020.
  6. RedCanary Mockingbird May 2020 Open source
    Lambert, T. (2020, May 7). Introducing Blue Mockingbird. Retrieved May 26, 2020.
  7. subTee .NET Profilers May 2017 Open source
    Smith, C. (2017, May 18). Subvert CLR Process Listing With .NET Profilers. Retrieved June 24, 2020.

Data from MITRE ATT&CK® (Enterprise). ATT&CK® is a registered trademark of The MITRE Corporation.