Detection rules › Sigma

Potentially Suspicious Child Process Of VsCode

Status
test
Severity
medium
Log source
product windows, category process_creation
Author
Nasreddine Bencherchali (Nextron Systems)
Source
github.com/SigmaHQ/sigma

Detects uncommon or suspicious child processes spawning from a VsCode "code.exe" process. This could indicate an attempt of persistence via VsCode tasks or terminal profiles.

MITRE ATT&CK coverage

Event coverage

Rule body yaml

title: Potentially Suspicious Child Process Of VsCode
id: 5a3164f2-b373-4152-93cf-090b13c12d27
status: test
description: Detects uncommon or suspicious child processes spawning from a VsCode "code.exe" process. This could indicate an attempt of persistence via VsCode tasks or terminal profiles.
references:
    - https://twitter.com/nas_bench/status/1618021838407495681
    - https://twitter.com/nas_bench/status/1618021415852335105
author: Nasreddine Bencherchali (Nextron Systems)
date: 2023-01-26
modified: 2023-10-25
tags:
    - attack.execution
    - attack.stealth
    - attack.t1218
    - attack.t1202
logsource:
    category: process_creation
    product: windows
detection:
    selection_parent:
        ParentImage|endswith: '\code.exe'
    selection_children_images:
        Image|endswith:
            - '\calc.exe'
            - '\regsvr32.exe'
            - '\rundll32.exe'
            - '\cscript.exe'
            - '\wscript.exe'
    selection_children_cli:
        Image|endswith:
            - '\powershell.exe'
            - '\pwsh.exe'
            - '\cmd.exe'
        CommandLine|contains:
            - 'Invoke-Expressions'
            - 'IEX'
            - 'Invoke-Command'
            - 'ICM'
            - 'DownloadString'
            - 'rundll32'
            - 'regsvr32'
            - 'wscript'
            - 'cscript'
    selection_children_paths:
        Image|contains:
            # Add more suspicious locations
            - ':\Users\Public\'
            - ':\Windows\Temp\'
            - ':\Temp\'
    condition: selection_parent and 1 of selection_children_*
falsepositives:
    - In development environment where VsCode is used heavily. False positives may occur when developers use task to compile or execute different types of code. Remove or add processes accordingly
level: medium

Stages and Predicates

Stage 0: condition

selection_parent and 1 of selection_children_*

Stage 1: selection_parent

selection_parent:
    ParentImage|endswith: '\code.exe'

Stage 2: selection_children_images

selection_children_images:
    Image|endswith:
        - '\calc.exe'
        - '\regsvr32.exe'
        - '\rundll32.exe'
        - '\cscript.exe'
        - '\wscript.exe'

Stage 3: selection_children_cli

selection_children_cli:
    Image|endswith:
        - '\powershell.exe'
        - '\pwsh.exe'
        - '\cmd.exe'
    CommandLine|contains:
        - 'Invoke-Expressions'
        - 'IEX'
        - 'Invoke-Command'
        - 'ICM'
        - 'DownloadString'
        - 'rundll32'
        - 'regsvr32'
        - 'wscript'
        - 'cscript'

Stage 4: selection_children_paths

selection_children_paths:
    Image|contains:
        - ':\Users\Public\'
        - ':\Windows\Temp\'
        - ':\Temp\'

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
  • DownloadString corpus 8 (sigma 7, kusto 1)
  • ICM
  • IEX corpus 6 (sigma 5, splunk 1)
  • Invoke-Command corpus 3 (sigma 2, splunk 1)
  • Invoke-Expressions
  • cscript corpus 15 (sigma 15)
  • regsvr32 corpus 15 (sigma 15)
  • rundll32 corpus 26 (sigma 23, chronicle 2, kusto 1)
  • wscript corpus 16 (sigma 16)
Imageends_with
  • \calc.exe corpus 13 (sigma 13)
  • \cmd.exe corpus 130 (sigma 130)
  • \cscript.exe corpus 73 (sigma 73)
  • \powershell.exe corpus 182 (sigma 182)
  • \pwsh.exe corpus 168 (sigma 168)
  • \regsvr32.exe corpus 65 (sigma 65)
  • \rundll32.exe corpus 95 (sigma 95)
  • \wscript.exe corpus 75 (sigma 75)
Imagematch
  • :\Temp\ corpus 13 (sigma 13)
  • :\Users\Public\ corpus 15 (sigma 15)
  • :\Windows\Temp\ corpus 9 (sigma 9)
ParentImageends_with
  • \code.exe