Detection rules › Sigma

Cmd.EXE Missing Space Characters Execution Anomaly

Status
test
Severity
high
Log source
product windows, category process_creation
Author
Florian Roth (Nextron Systems)
Source
github.com/SigmaHQ/sigma

Detects Windows command lines that miss a space before or after the /c flag when running a command using the cmd.exe. This could be a sign of obfuscation of a fat finger problem (typo by the developer).

MITRE ATT&CK coverage

Event coverage

Rule body yaml

title: Cmd.EXE Missing Space Characters Execution Anomaly
id: a16980c2-0c56-4de0-9a79-17971979efdd
status: test
description: |
    Detects Windows command lines that miss a space before or after the /c flag when running a command using the cmd.exe.
    This could be a sign of obfuscation of a fat finger problem (typo by the developer).
references:
    - https://twitter.com/cyb3rops/status/1562072617552678912
    - https://ss64.com/nt/cmd.html
author: Florian Roth (Nextron Systems)
date: 2022-08-23
modified: 2026-05-13
tags:
    - attack.execution
    - attack.t1059.001
logsource:
    category: process_creation
    product: windows
detection:
    selection1:  # missing space before the /c
        CommandLine|contains:
            - 'cmd.exe/c'
            - '\cmd/c'  # just cmd/c would be prone to false positives
            - '"cmd/c'
            - 'cmd.exe/k'
            - '\cmd/k'  # just cmd/k would be prone to false positives
            - '"cmd/k'
            - 'cmd.exe/r'
            - '\cmd/r'  # just cmd/r would be prone to false positives
            - '"cmd/r'
    selection2: # special cases verified via Virustotal Enterprise search
        CommandLine|contains:
            - '/cwhoami'
            - '/cpowershell'
            - '/cschtasks'
            - '/cbitsadmin'
            - '/ccertutil'
            - '/kwhoami'
            - '/kpowershell'
            - '/kschtasks'
            - '/kbitsadmin'
            - '/kcertutil'
    selection3:  # missing space after the /c
        CommandLine|contains:
            - 'cmd.exe /c'
            - 'cmd /c'
            - 'cmd.exe /k'
            - 'cmd /k'
            - 'cmd.exe /r'
            - 'cmd /r'
    filter_generic:
        CommandLine|contains:
            - 'cmd.exe /c '
            - 'cmd /c '
            - 'cmd.exe /k '
            - 'cmd /k '
            - 'cmd.exe /r '
            - 'cmd /r '
    filter_fp:
        - CommandLine|contains: 'AppData\Local\Programs\Microsoft VS Code\resources\app\node_modules'
        - CommandLine|endswith: 'cmd.exe/c .'
        - CommandLine: 'cmd.exe /c'
        - CommandLine: 'cmd /c'
    condition: 1 of selection* and not 1 of filter_*
falsepositives:
    - Legitimate use of cmd.exe with no arguments e.g. via system("") in C to enable ANSI escape codes
level: high

Stages and Predicates

Stage 0: condition

1 of selection* and not 1 of filter_*

Stage 1: selection1

selection1:
    CommandLine|contains:
        - 'cmd.exe/c'
        - '\cmd/c'
        - '"cmd/c'
        - 'cmd.exe/k'
        - '\cmd/k'
        - '"cmd/k'
        - 'cmd.exe/r'
        - '\cmd/r'
        - '"cmd/r'

Stage 2: selection2

selection2:
    CommandLine|contains:
        - '/cwhoami'
        - '/cpowershell'
        - '/cschtasks'
        - '/cbitsadmin'
        - '/ccertutil'
        - '/kwhoami'
        - '/kpowershell'
        - '/kschtasks'
        - '/kbitsadmin'
        - '/kcertutil'

Stage 3: selection3

selection3:
    CommandLine|contains:
        - 'cmd.exe /c'
        - 'cmd /c'
        - 'cmd.exe /k'
        - 'cmd /k'
        - 'cmd.exe /r'
        - 'cmd /r'

Stage 4: not filter_*

filter_generic:
    CommandLine|contains:
        - 'cmd.exe /c '
        - 'cmd /c '
        - 'cmd.exe /k '
        - 'cmd /k '
        - 'cmd.exe /r '
        - 'cmd /r '
filter_fp:
    - CommandLine|contains: 'AppData\Local\Programs\Microsoft VS Code\resources\app\node_modules'
    - CommandLine|endswith: 'cmd.exe/c .'
    - CommandLine: 'cmd.exe /c'
    - CommandLine: 'cmd /c'

Exclusions

Top-level NOT(...) conjuncts: predicates this rule actively suppresses.

FieldKindExcluded values
CommandLineends_withcmd.exe/c .
CommandLineeqcmd /c
CommandLineeqcmd.exe /c
CommandLinematchAppData\Local\Programs\Microsoft VS Code\resources\app\node_modules
CommandLinematchcmd /c
CommandLinematchcmd /k
CommandLinematchcmd /r
CommandLinematchcmd.exe /c
CommandLinematchcmd.exe /k
CommandLinematchcmd.exe /r

Indicators

Each row is a field, operator, and value that the rule matches. The corpus column counts how many other rules in the catalog look for the same combination: high numbers point to widely-used, community-vetted indicators. Blank or 1 shows that the indicator is specific to this rule.

FieldKindValues
CommandLinematch
  • "cmd/c
  • "cmd/k
  • "cmd/r
  • /cbitsadmin
  • /ccertutil
  • /cpowershell
  • /cschtasks
  • /cwhoami
  • /kbitsadmin
  • /kcertutil
  • /kpowershell
  • /kschtasks
  • /kwhoami
  • \cmd/c
  • \cmd/k
  • \cmd/r
  • cmd /c corpus 5 (sigma 5)
  • cmd /k corpus 4 (sigma 4)
  • cmd /r corpus 3 (sigma 3)
  • cmd.exe /c corpus 3 (sigma 3)
  • cmd.exe /k corpus 3 (sigma 3)
  • cmd.exe /r corpus 3 (sigma 3)
  • cmd.exe/c
  • cmd.exe/k
  • cmd.exe/r