← Back to SOC feed Coverage →

Dynamic CSharp Compile Artefact

sigma LOW SigmaHQ
T1027.004
imFileEvent
This rule was pulled from an open-source repository and enriched with AI. Validate in a test environment before deploying to production.
View original rule at SigmaHQ →
Retrieved: 2026-03-25T03:05:59Z · Confidence: medium

Hunt Hypothesis

The Dynamic CSharp Compile Artefact rule detects adversaries dynamically compiling C# code to execute malicious payloads without writing to disk, leveraging the creation of temporary .cmdline files as part of the process. SOC teams should proactively hunt for this behavior in Azure Sentinel to identify potential in-memory execution and evasion tactics that bypass traditional file-based detection mechanisms.

Detection Rule

Sigma (Original)

title: Dynamic CSharp Compile Artefact
id: e4a74e34-ecde-4aab-b2fb-9112dd01aed0
status: test
description: |
    When C# is compiled dynamically, a .cmdline file will be created as a part of the process.
    Certain processes are not typically observed compiling C# code, but can do so without touching disk.
    This can be used to unpack a payload for execution
references:
    - https://github.com/redcanaryco/atomic-red-team/blob/f339e7da7d05f6057fdfcdd3742bfcf365fee2a9/atomics/T1027.004/T1027.004.md#atomic-test-2---dynamic-c-compile
author: frack113
date: 2022-01-09
modified: 2023-02-17
tags:
    - attack.defense-evasion
    - attack.t1027.004
logsource:
    product: windows
    category: file_event
detection:
    selection:
        TargetFilename|endswith: '.cmdline'
    condition: selection
falsepositives:
    - Unknown
level: low

KQL (Azure Sentinel)

imFileEvent
| where TargetFileName endswith ".cmdline"

False Positive Guidance

MITRE ATT&CK Context

Original source: https://github.com/SigmaHQ/sigma/blob/master/rules/windows/file/file_event/file_event_win_csharp_compile_artefact.yml