Windows PowerShell script sets COR_PROFILER environment variables for .NET CLR profiling

Alerts on PowerShell script blocks that set CLR profiler environment variables (COR_ENABLE_PROFILING/COR_PROFILER/COR_PROFILER_PATH).

FreeReviewedSigma · Medium · v2
Product
windows
Category
ps_script
Author
frack113 (SigmaHQ), DRL 1.1
Published
2021-12-30
Updated
2026-07-31
title: Windows PowerShell script sets COR_PROFILER environment variables for .NET CLR profiling
id: 9a3e2fad-06ef-4b3a-8f8c-26bbfbf58307
status: test
description: This rule matches PowerShell script block content that includes assignments or references to the COR_ENABLE_PROFILING, COR_PROFILER, and COR_PROFILER_PATH environment variables. These variables control which unmanaged profiling DLL is loaded into .NET processes that initialize the CLR, enabling attackers to influence managed application execution. It relies on Script Block Logging telemetry where the script text is available to search for all three environment-variable tokens.
references:
  - https://github.com/redcanaryco/atomic-red-team/blob/f339e7da7d05f6057fdfcdd3742bfcf365fee2a9/atomics/T1574.012/T1574.012.md#atomic-test-3---registry-free-process-scope-cor_profiler
  - https://github.com/SigmaHQ/sigma/blob/master/rules/windows/powershell/powershell_script/posh_ps_cor_profiler.yml
author: frack113, Huntrule Team
date: 2021-12-30
tags:
  - attack.privilege-escalation
  - attack.persistence
  - attack.execution
  - attack.stealth
  - attack.t1574.012
logsource:
  product: windows
  category: ps_script
  definition: "Requirements: Script Block Logging must be enabled"
detection:
  selection:
    ScriptBlockText|contains|all:
      - $env:COR_ENABLE_PROFILING
      - $env:COR_PROFILER
      - $env:COR_PROFILER_PATH
  condition: selection
falsepositives:
  - Legitimate administrative script
level: medium
license: DRL-1.1
related:
  - id: 23590215-4702-4a70-8805-8dc9e58314a2
    type: derived