Windows Process Creation: csc.exe Dynamic .NET Compilation

Flags Windows runs of csc.exe with /noconfig /fullpaths and an @-file, consistent with dynamic .NET compilation.

FreeUnreviewedSigmamediumv1
title: "Windows Process Creation: csc.exe Dynamic .NET Compilation"
id: f73c02bc-d9d1-4359-97b2-fcaf4e05c795
related:
  - id: dcaa3f04-70c3-427a-80b4-b870d73c94c4
    type: derived
  - id: acf2807c-805b-4042-aab9-f86b6ba9cb2b
    type: derived
status: test
description: This rule identifies Windows executions of csc.exe where the command line includes /noconfig /fullpaths and an @-file argument, indicating compilation of provided .NET source or resources. Attackers may use on-the-fly compilation to generate assemblies for later stages and to reduce reliance on prebuilt binaries. It relies on process creation telemetry, matching the executed image name and specific command-line substrings.
references:
  - https://securityboulevard.com/2019/08/agent-tesla-evading-edr-by-removing-api-hooks/
  - https://www.clearskysec.com/wp-content/uploads/2018/11/MuddyWater-Operations-in-Lebanon-and-Oman.pdf
  - https://app.any.run/tasks/c6993447-d1d8-414e-b856-675325e5aa09/
  - https://twitter.com/gN3mes1s/status/1206874118282448897
  - https://github.com/SigmaHQ/sigma/blob/master/rules-threat-hunting/windows/process_creation/proc_creation_win_csc_compilation.yml
author: Nasreddine Bencherchali (Nextron Systems), Huntrule Team
date: 2023-08-02
tags:
  - attack.stealth
  - attack.t1027.004
  - detection.threat-hunting
logsource:
  category: process_creation
  product: windows
detection:
  selection:
    Image|endswith: \csc.exe
    CommandLine|contains: /noconfig /fullpaths @
  condition: selection
falsepositives:
  - Many legitimate applications make use of dynamic compilation. Use this rule to hunt for anomalies
level: medium
license: DRL-1.1

What it detects

This rule identifies Windows executions of csc.exe where the command line includes /noconfig /fullpaths and an @-file argument, indicating compilation of provided .NET source or resources. Attackers may use on-the-fly compilation to generate assemblies for later stages and to reduce reliance on prebuilt binaries. It relies on process creation telemetry, matching the executed image name and specific command-line substrings.

Known false positives

  • Many legitimate applications make use of dynamic compilation. Use this rule to hunt for anomalies

Detection content is published as a reviewed draft. Tune thresholds and exclusions against your own telemetry before enabling this rule for alerting.