T1204.002 Elastic Security · Elastic

Detect Malicious File in Elastic Security

Adversaries rely on users opening malicious files to gain code execution. Files delivered via spearphishing attachments or placed in shared directories include .doc, .xls, .pdf, .rtf, .scr, .exe, .lnk, .pif, .cpl, .iso, and others. Social engineering lures users into enabling macros, extracting archives, or double-clicking payloads. Execution typically manifests as an Office application, PDF reader, or shell process spawning a scripting engine, command interpreter, or LOLBin as a child process.

MITRE ATT&CK

Tactic
Execution
Technique
T1204 User Execution
Sub-technique
T1204.002 Malicious File
Canonical reference
https://attack.mitre.org/techniques/T1204/002/

Elastic Detection Query

Elastic Security (Elastic)
eql
sequence by host.id with maxspan=2m
  [process where event.type == "start" and
   process.parent.name : ("winword.exe", "excel.exe", "powerpnt.exe", "outlook.exe", "onenote.exe", "mspub.exe", "visio.exe", "wordpad.exe", "acrord32.exe", "foxitreader.exe", "sumatra.exe") and
   process.name : ("cmd.exe", "powershell.exe", "pwsh.exe", "wscript.exe", "cscript.exe", "mshta.exe", "rundll32.exe", "regsvr32.exe", "certutil.exe", "bitsadmin.exe", "msbuild.exe", "wmic.exe", "installutil.exe", "regasm.exe", "regsvcs.exe", "cmstp.exe", "schtasks.exe", "net.exe", "netsh.exe", "curl.exe", "wget.exe")]
  [any where true]
| head 500

/* Branch 2: Script interpreter executing from user-writable paths */
process where event.type == "start" and
  process.name : ("wscript.exe", "cscript.exe", "mshta.exe") and
  (
    process.args : ("*\\AppData\\Local\\Temp\\*", "*\\AppData\\Roaming\\*", "*\\Downloads\\*", "*\\Desktop\\*", "*\\Public\\*", "*\\Windows\\Temp\\*") or
    process.args : ("*.vbs", "*.vbe", "*.js", "*.jse", "*.wsf", "*.hta", "*.ps1")
  )

/* Branch 3: Explorer spawning suspicious children from LNK/ISO context */
process where event.type == "start" and
  process.parent.name : "explorer.exe" and
  process.name : ("cmd.exe", "powershell.exe", "pwsh.exe", "wscript.exe", "cscript.exe", "mshta.exe", "rundll32.exe", "regsvr32.exe", "certutil.exe", "bitsadmin.exe", "msbuild.exe") and
  (
    process.working_directory : ("*\\AppData\\Local\\Temp\\*", "*\\AppData\\Roaming\\*", "*\\Downloads\\*", "*\\Desktop\\*", "*\\Public\\*", "*\\Windows\\Temp\\*") or
    process.parent.args : ("*.lnk")
  )

/* Branch 4: Dropped executable launched from user-writable path */
process where event.type == "start" and
  process.name : ("*.exe", "*.scr", "*.pif", "*.cpl", "*.com") and
  process.executable : ("*\\AppData\\Local\\Temp\\*", "*\\AppData\\Roaming\\*", "*\\Downloads\\*", "*\\Desktop\\*", "*\\Public\\*", "*\\Windows\\Temp\\*") and
  process.parent.name : ("winword.exe", "excel.exe", "powerpnt.exe", "outlook.exe", "onenote.exe", "acrord32.exe", "foxitreader.exe", "explorer.exe", "winrar.exe", "7z.exe")
high severity high confidence

Detects T1204.002 malicious file execution patterns: Office/PDF applications spawning suspicious child processes (macro execution), script interpreters launching from user-writable paths, Explorer spawning suspicious processes from LNK/ISO context, and dropped executables launched from temp/download locations.

Data Sources

Elastic Endpoint SecurityWinlogbeat with SysmonElastic Agent (endpoint)

Required Tables

logs-endpoint.events.process-*winlogbeat-*logs-system.security-*

False Positives & Tuning

  • Legitimate Office macros used by finance or operations teams to automate workflows may trigger Office_SuspiciousChildSpawn — validate against an approved macro inventory and user role.
  • IT automation scripts (e.g., SCCM deployment packages, software installers run by IT) legitimately launch executables from Temp/Downloads paths — correlate with change management tickets and software deployment logs.
  • Developers using WSL, Node.js, or Python tools installed in AppData may trigger Script_UserPathExecution — verify against developer machine baselines and software asset management.
  • PDF readers with JavaScript support (Acrobat) calling internal helper processes or plugin DLLs may generate false positives — check parent-child chain against known Acrobat plugin paths.
Download portable Sigma rule (.yml)

Other platforms for T1204.002


Testing Methodology

Validate this detection against 4 adversary techniques from Atomic Red Team. Each test below lists the behaviour to exercise and the telemetry you should expect to see. Executable commands and cleanup steps are available with Pro.

  1. Test 1Word Document Macro Spawning PowerShell

    Expected signal: Sysmon Event ID 1: Process Create with ParentImage=WINWORD.EXE and Image=cmd.exe, CommandLine containing 'whoami'. Security Event ID 4688 (if command line auditing enabled) with same parent-child relationship. Sysmon Event ID 11: File creation of df00tech-macro-test.txt by cmd.exe.

  2. Test 2VBScript Execution from Downloads Folder

    Expected signal: Sysmon Event ID 1: Process Create with Image=wscript.exe, CommandLine containing the path to df00tech-invoice.vbs in the Downloads folder. ParentImage will be cmd.exe (simulating Explorer shell execution). Sysmon Event ID 11: File creation of df00tech-vbs-test.txt by cmd.exe child of wscript.exe.

  3. Test 3HTA File Execution Simulating Phishing Payload

    Expected signal: Sysmon Event ID 1 (first): Process Create for mshta.exe with CommandLine pointing to df00tech-payload.hta in TEMP. Sysmon Event ID 1 (second): cmd.exe as child of mshta.exe with CommandLine containing 'whoami'. Sysmon Event ID 11: File creation of df00tech-hta-test.txt.

  4. Test 4ISO-Mounted LNK File Executing Payload (MOTW Bypass Simulation)

    Expected signal: Sysmon Event ID 1: Process Create with ParentImage=explorer.exe, Image=cmd.exe, with CommandLine containing path to payload.bat. Sysmon Event ID 11: File creation of invoice.lnk and payload.bat in the simulated ISO directory. Sysmon Event ID 11: df00tech-iso-result.txt created by cmd.exe.

Unlock Pro Content

Get the full detection package for T1204.002 including response playbook, investigation guide, and atomic red team tests.

Response PlaybookInvestigation GuideHunting QueriesAtomic Red Team TestsTuning Guidance

Related Detections