Detection rules › Splunk

Visual Studio Code Tunnel Execution (Windows Event Log)

Group by
_time, host
Source
github.com/anvilogic-forge/armory

Adversaries may communicate using application layer protocols associated with web traffic to avoid detection/network filtering by blending in with existing traffic. Commands to the remote system, and often the results of those commands, will be embedded within the protocol traffic between the client and server. This use case detects the execution of Visual Studio Code tunnel in attempt to establish a C2 channel, accounting for instances where the binary has been renamed.

MITRE ATT&CK coverage

References

Event coverage

Rule body yaml

id: '40420.73843'
title: Visual Studio Code Tunnel Execution
description: Adversaries may communicate using application layer protocols associated
  with web traffic to avoid detection/network filtering by blending in with existing
  traffic. Commands to the remote system, and often the results of those commands,
  will be embedded within the protocol traffic between the client and server. This
  use case detects the execution of Visual Studio Code tunnel in attempt to establish
  a C2 channel, accounting for instances where the binary has been renamed.
logic_format: Splunk
logic: '`get_endpoint_data` `get_endpoint_data_winevent` (TERM(EventCode=4688) OR
  "<EventID>4688<" OR Type=Process) "tunnel" OR ("tunnel" ("--name " "--accept-server-license-terms")
  OR "--cli-data-dir") OR ("cmd.exe" " /d " " /c " "\\servers\\Stable-" "code-server.cmd")
  | where match(process, "(?i)\.exe(\x22)?\s+tunnel\s?") or ((match(process, "\.exe(\x22)?\s+tunnel\s?$")
  and like(process, "%--name %") and like(process, "%--accept-server-license-terms%"))
  or like(process, "%--cli-data-dir%") or (like(process_path, "%cmd.exe") and like(process,
  "% /d %") and like(process, "% /c %") and like(process, "%\\servers\\Stable-%")
  and like(process, "%code-server.cmd%"))) | table _time, host, user, process, process_*,
  parent_* | bin span=1s | stats values(*) as * by _time, host '
techniques:
- command-and-control:application layer protocol:web protocols
technique_id:
- T1071.001
data_category:
- Process command-line parameters
- Windows event logs
references:
- https://detection.fyi/sigmahq/sigma/windows/process_creation/proc_creation_win_vscode_tunnel_execution/
- https://attack.mitre.org/techniques/T1071/001/
- https://www.sentinelone.com/labs/operation-digital-eye-chinese-apt-compromises-critical-digital-infrastructure-via-visual-studio-code-tunnels/

Stages and Predicates

Stage 1: search

`get_endpoint_data` `get_endpoint_data_winevent` (TERM(EventCode=4688) OR "<EventID>4688<" OR Type=Process) "tunnel" OR ("tunnel" ("--name " "--accept-server-license-terms") OR "--cli-data-dir") OR ("cmd.exe" " /d " " /c " "\\servers\\Stable-" "code-server.cmd")

Stage 2: where

| where match(process, "(?i)\.exe(\x22)?\s+tunnel\s?") or ((match(process, "\.exe(\x22)?\s+tunnel\s?$") and like(process, "%--name %") and like(process, "%--accept-server-license-terms%")) or like(process, "%--cli-data-dir%") or (like(process_path, "%cmd.exe") and like(process, "% /d %") and like(process, "% /c %") and like(process, "%\\servers\\Stable-%") and like(process, "%code-server.cmd%")))

Stage 3: table

| table _time, host, user, process, process_*, parent_*

Stage 4: bucket

| bin span=1s

Stage 5: stats

| stats values(*) as * by _time, host

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
EventCodeeq
  • 4688 corpus 313 (splunk 283, kusto 30)
processlike
  • "% /c %" corpus 6 (sigma 4, splunk 2)
  • "% /d %" corpus 3 (sigma 2, splunk 1)
  • "%--accept-server-license-terms%" corpus 4 (sigma 3, splunk 1)
  • "%--cli-data-dir%"
  • "%--name %"
  • "%\\servers\\Stable-%"
  • "%code-server.cmd%" corpus 3 (sigma 2, splunk 1)
processmatch
  • "(?i)\.exe(\x22)?\s+tunnel\s?"
  • "\.exe(\x22)?\s+tunnel\s?$"
process_pathlike
  • "%cmd.exe" corpus 2 (sigma 1, splunk 1)

Search terms

Bare-string tokens in the SPL search body. Splunk matches each token against _raw (the untyped raw event text) anywhere it appears, not against a specific field. These don't surface in the Indicators table because they aren't predicates on a known field.

StageTerm
1TERM
1"<EventID>4688<"
1"tunnel"
1"tunnel"
1"--name "
1"--accept-server-license-terms"
1"--cli-data-dir"
1"cmd.exe"
1" /d "
1" /c "
1"\\servers\\Stable-"
1"code-server.cmd"