Batch file run by the command shell from a user-writable path
AN0578 asks for interactive or scripted abuse of cmd.exe and batch files, but the bare observable — the command shell started — happens thousands of times a day on a healthy host, so this rule keeps MITRE's ScriptStoragePath knob and drops the rest: cmd.exe running a .bat or .cmd whose path sits in a staging directory any unprivileged account can write to, populated here with the per-user and Windows temp directories, roaming AppData, the public profile, Downloads, %ProgramData% and the recycle bin. The ParentProcessName knob MITRE names alongside it — cmd.exe spawned by a document viewer or browser — is deliberately not written, because the corpus already carries that lineage under T1204 and T1203 and a third copy would add no coverage; the CommandLinePattern knob is left out because chaining operators and `/c` are as common in vendor install scripts as in an implant. The brief offers Security EventID 4688 for this analytic but maps it onto the Sysmon-shaped `process_creation` category, and the rule is written in that vocabulary (`Image`, `CommandLine`): a 4688 feed needs `NewProcessName` mapped onto `Image` and `ProcessCommandLine` onto `CommandLine` before it can match at all, and 4688 itself requires *Audit Process Creation* plus the separate *Include command line in process creation events* policy, neither of which is on in a default install or in the MS/CIS baselines. AN0578's second log source, the Sysmon EventID 7 module load, is not used here. Two limits of the shape: the script name and the staging directory are independent substrings of the same `CommandLine`, so the rule does not actually assert that the batch file is the thing sitting in the writable path, and a batch file invoked by bare name from a working directory already set to that path puts no directory on the command line at all and is missed — on a Sysmon feed `CurrentDirectory` would close that gap, on a 4688 feed nothing does. UNVERIFIED AS AUTHORED — derived from MITRE ATT&CK DET0202, not hand-written and not tested by its author. Any lab result is on this rule's own page.Full descriptionShow less
The detection
The 4 SIEM queries below are previews produced by Siemphony’s own translator, not pySigma, and none has been executed against a real backend — review before you deploy.
detection.yml
title: Batch file run by the command shell from a user-writable pathid: 8ce47038-ef50-40e1-ab92-98e0b623982dstatus: experimentaldescription: | AN0578 asks for interactive or scripted abuse of cmd.exe and batch files, but the bare observable — the command shell started — happens thousands of times a day on a healthy host, so this rule keeps MITRE's ScriptStoragePath knob and drops the rest: cmd.exe running a .bat or .cmd whose path sits in a staging directory any unprivileged account can write to, populated here with the per-user and Windows temp directories, roaming AppData, the public profile, Downloads, %ProgramData% and the recycle bin. The ParentProcessName knob MITRE names alongside it — cmd.exe spawned by a document viewer or browser — is deliberately not written, because the corpus already carries that lineage under T1204 and T1203 and a third copy would add no coverage; the CommandLinePattern knob is left out because chaining operators and `/c` are as common in vendor install scripts as in an implant. The brief offers Security EventID 4688 for this analytic but maps it onto the Sysmon-shaped `process_creation` category, and the rule is written in that vocabulary (`Image`, `CommandLine`): a 4688 feed needs `NewProcessName` mapped onto `Image` and `ProcessCommandLine` onto `CommandLine` before it can match at all, and 4688 itself requires *Audit Process Creation* plus the separate *Include command line in process creation events* policy, neither of which is on in a default install or in the MS/CIS baselines. AN0578's second log source, the Sysmon EventID 7 module load, is not used here. Two limits of the shape: the script name and the staging directory are independent substrings of the same `CommandLine`, so the rule does not actually assert that the batch file is the thing sitting in the writable path, and a batch file invoked by bare name from a working directory already set to that path puts no directory on the command line at all and is missed — on a Sysmon feed `CurrentDirectory` would close that gap, on a 4688 feed nothing does. UNVERIFIED AS AUTHORED — derived from MITRE ATT&CK DET0202, not hand-written and not tested by its author. Any lab result is on this rule's own page.references: - https://attack.mitre.org/techniques/T1059/003 - https://attack.mitre.org/detectionstrategies/DET0202author: Siemphony pipeline (machine-derived from MITRE ATT&CK v19.2)date: 2026-08-16tags: - attack.execution - attack.t1059.003logsource: category: process_creation product: windowsdetection: selection_shell: Image|endswith: '\cmd.exe' selection_script: CommandLine|contains: - '.bat' - '.cmd' selection_staging_path: CommandLine|contains: - '\AppData\Local\Temp\' - '\AppData\Roaming\' - '\Windows\Temp\' - '\Users\Public\' - '\Downloads\' - '\ProgramData\' - '\$Recycle.Bin\' condition: selection_shell and selection_script and selection_staging_pathfalsepositives: - "Installers, updaters and self-extracting archives that unpack a .bat or .cmd wrapper into the user or Windows temp directory and hand it to cmd.exe — MSI custom actions and vendor bootstrappers do this by design, and it is likely the largest single source of matches on a typical fleet." - "Endpoint-management and RMM platforms that stage remediation, inventory or detection scripts under %ProgramData% or the Windows temp directory before invoking them, which is the normal deployment path for configuration-management agents." - "Logon, imaging and build automation that keeps its batch files in the public profile so every account on a shared workstation, lab machine or kiosk can reach them." - "IT staff and developers running a downloaded setup or build script straight out of the Downloads folder, which produces the same shell-plus-user-writable-path event as a staged payload."level: lowSentinel · KQL
Run this as a search.
DeviceProcessEvents| where ((FolderPath endswith "\\cmd.exe" and (ProcessCommandLine contains ".bat" or ProcessCommandLine contains ".cmd")) and (ProcessCommandLine contains "\\AppData\\Local\\Temp\\" or ProcessCommandLine contains "\\AppData\\Roaming\\" or ProcessCommandLine contains "\\Windows\\Temp\\" or ProcessCommandLine contains "\\Users\\Public\\" or ProcessCommandLine contains "\\Downloads\\" or ProcessCommandLine contains "\\ProgramData\\" or ProcessCommandLine contains "\\$Recycle.Bin\\"))
Splunk · SPL
Run this as a search.
index=* ((Image="*\\cmd.exe" AND (CommandLine="*.bat*" OR CommandLine="*.cmd*")) AND (CommandLine="*\\AppData\\Local\\Temp\\*" OR CommandLine="*\\AppData\\Roaming\\*" OR CommandLine="*\\Windows\\Temp\\*" OR CommandLine="*\\Users\\Public\\*" OR CommandLine="*\\Downloads\\*" OR CommandLine="*\\ProgramData\\*" OR CommandLine="*\\$Recycle.Bin\\*"))Elastic · ES|QL
Run this as a search.
FROM logs-*| WHERE ((TO_LOWER(process.executable) LIKE "*\\\\cmd.exe" AND (TO_LOWER(process.command_line) LIKE "*.bat*" OR TO_LOWER(process.command_line) LIKE "*.cmd*")) AND (TO_LOWER(process.command_line) LIKE "*\\\\appdata\\\\local\\\\temp\\\\*" OR TO_LOWER(process.command_line) LIKE "*\\\\appdata\\\\roaming\\\\*" OR TO_LOWER(process.command_line) LIKE "*\\\\windows\\\\temp\\\\*" OR TO_LOWER(process.command_line) LIKE "*\\\\users\\\\public\\\\*" OR TO_LOWER(process.command_line) LIKE "*\\\\downloads\\\\*" OR TO_LOWER(process.command_line) LIKE "*\\\\programdata\\\\*" OR TO_LOWER(process.command_line) LIKE "*\\\\$recycle.bin\\\\*"))
Wazuh · XML rule
Deploy to your manager — this is a rule, not a search.
<group name="sigma,windows,process_creation,"> <!-- Rule ids must be unique on your manager; 100000+ is the user range. --> <rule id="100000" level="5"> <!-- Set <if_sid> to the decoder/base rule for windows so this only evaluates relevant events. --> <field name="Image" type="pcre2">(?i)\\cmd\.exe$</field> <field name="CommandLine" type="pcre2">(?i)(\.bat|\.cmd)</field> <field name="CommandLine" type="pcre2">(?i)(\\AppData\\Local\\Temp\\|\\AppData\\Roaming\\|\\Windows\\Temp\\|\\Users\\Public\\|\\Downloads\\|\\ProgramData\\|\\\$Recycle\.Bin\\)</field> <description>Batch file run by the command shell from a user-writable path</description> <mitre> <id>T1059.003</id> </mitre> </rule></group>
Verdicts · reactions · comments
Community
Verdicts from engineers who actually deployed it, and the conversation around it.
Nobody has run this in a real environment and said what happened.
Verdicts from engineers who deployed it
0 castNo verdicts reported yet. The first one is worth more than the tenth — say what you ran it against.
Log in to report a verdict.
Log in to join the discussion.
No comments yet. Someone who deploys this will have something to say about it.