Detection rules › Sigma

Potential CommandLine Path Traversal Via Cmd.EXE

Status
test
Severity
high
Log source
category process_creation, product windows
Author
xknow @xknow_infosec, Tim Shelton
Source
github.com/SigmaHQ/sigma

Detects potential path traversal attempt via cmd.exe. Could indicate possible command/argument confusion/hijacking

Known false positives

  • Java tools are known to produce false-positive when loading libraries

MITRE ATT&CK coverage

Telemetry coverage

ProviderRecord / event type
SysmonEvent ID 1: Process creation

Rule body

title: Potential CommandLine Path Traversal Via Cmd.EXE
id: 087790e3-3287-436c-bccf-cbd0184a7db1
status: test
description: Detects potential path traversal attempt via cmd.exe. Could indicate possible command/argument confusion/hijacking
references:
    - https://hackingiscool.pl/cmdhijack-command-argument-confusion-with-path-traversal-in-cmd-exe/
    - https://twitter.com/Oddvarmoe/status/1270633613449723905
author: xknow @xknow_infosec, Tim Shelton
date: 2020-06-11
modified: 2023-03-06
tags:
    - attack.execution
    - attack.t1059.003
logsource:
    category: process_creation
    product: windows
detection:
    selection_img:
        - ParentImage|endswith: '\cmd.exe'
        - Image|endswith: '\cmd.exe'
        - OriginalFileName: 'cmd.exe'
    selection_flags:
        - ParentCommandLine|contains:
              - '/c'
              - '/k'
              - '/r'
        - CommandLine|contains:
              - '/c'
              - '/k'
              - '/r'
    selection_path_traversal:
        - ParentCommandLine: '/../../'
        - CommandLine|contains: '/../../'
    filter_java:
        CommandLine|contains: '\Tasktop\keycloak\bin\/../../jre\bin\java'
    condition: all of selection_* and not 1 of filter_*
falsepositives:
    - Java tools are known to produce false-positive when loading libraries
level: high

Stages and Predicates

Stage 0: condition

all of selection_* and not 1 of filter_*

Stage 1: selection_img

selection_img:
    - ParentImage|endswith: '\cmd.exe'
    - Image|endswith: '\cmd.exe'
    - OriginalFileName: 'cmd.exe'

Stage 2: selection_flags

selection_flags:
    - ParentCommandLine|contains:
          - '/c'
          - '/k'
          - '/r'
    - CommandLine|contains:
          - '/c'
          - '/k'
          - '/r'

Stage 3: selection_path_traversal

selection_path_traversal:
    - ParentCommandLine: '/../../'
    - CommandLine|contains: '/../../'

Stage 4: not filter_java

filter_java:
    CommandLine|contains: '\Tasktop\keycloak\bin\/../../jre\bin\java'

Exclusions

The rule actively suppresses these predicates.

FieldKindExcluded valuesSearch
CommandLinematch\Tasktop\keycloak\bin\/../../jre\bin\javaexcludes:CommandLine field:"CommandLine" value:"\Tasktop\keycloak\bin\/../../jre\bin\java"

Indicators

These rows show field, operator, and value matches.

FieldKindValuesSearch
CommandLinematch
  • /../../ corpus 2 (sigma 2)
  • /c corpus 15 (sigma 13, splunk 2)
  • /k
  • /r corpus 3 (sigma 3)
field:"CommandLine" kind:match
Imageends_with
  • \cmd.exe corpus 130 (sigma 130)
field:"Image" kind:ends_with value:"\cmd.exe"
OriginalFileNameeq
  • cmd.exe corpus 81 (sigma 43, elastic 21, splunk 17)
field:"OriginalFileName" kind:eq value:"cmd.exe"
ParentCommandLineeq
  • /../../
field:"ParentCommandLine" kind:eq value:"/../../"
ParentCommandLinematch
  • /c corpus 3 (sigma 3)
  • /k
  • /r corpus 2 (sigma 2)
field:"ParentCommandLine" kind:match
ParentImageends_with
  • \cmd.exe corpus 20 (sigma 20)
field:"ParentImage" kind:ends_with value:"\cmd.exe"