Suspicious Command Execution from Visual Studio Code

Last updated a day ago on 2026-10-26
Created a day ago on 2026-10-26

About

Detects Visual Studio Code ("Code.exe" on Windows or "Code Helper" on macOS) spawning a shell or downloader whose command line contains an encoded command, a download cradle, or a reverse-shell pattern. Malicious IDE extensions use the editor process to run these commands after install.
Tags
Domain: EndpointOS: WindowsOS: macOSOS: LinuxUse Case: Threat DetectionTactic: PersistenceTactic: ExecutionData Source: Elastic DefendRule Type: ES|QLPlatform: WindowsPlatform: macOSPlatform: LinuxLanguage: esql
Severity
medium
Risk Score
47
MITRE ATT&CK™

Persistence (TA0003)(external, opens in a new tab or window)

Execution (TA0002)(external, opens in a new tab or window)

License
Elastic License v2(external, opens in a new tab or window)

Definition

Integration Pack
Prebuilt Security Detection Rules
Related Integrations

endpoint(external, opens in a new tab or window)

Query
text code block:
FROM logs-endpoint.events.process-* METADATA _id, _version, _index | WHERE KQL("""event.category:process and event.type:start""") AND process.parent.name IN ("Code Helper (Plugin)", "Code Helper", "Code.exe", "code") AND process.name IN ( "cmd.exe", "powershell.exe", "sh", "bash", "zsh", "dash", "nohup", "curl.exe", "curl", "wget", "wget.exe", "pwsh.exe" ) AND TO_LOWER(process.command_line) RLIKE """.*(-ec |-enc|-encodedcommand|-nop |-w hidden|https|/dev/tcp|echo|irm |iwr |base64|nohup|http:|iex |invoke-expression|downloadstring|downloadfile|frombase64string|chmod \+|nc -e|ncat|certutil|bitsadmin|invoke-restmethod|curl.*\|.*sh|wget.*\|.*sh).*""" AND NOT TO_LOWER(process.command_line) RLIKE """.*(docker.internal|localhost|127.0.0.1|aka.ms/vscode-powershell).*""" | KEEP _id, _version, _index, data_stream.namespace, @timestamp, host.name, host.id, agent.id, host.os.type, user.name, user.domain, process.name, process.parent.name, process.parent.executable, process.command_line, process.executable, process.parent.command_line, process.parent.args

Install detection rules in Elastic Security

Detect Suspicious Command Execution from Visual Studio Code in the Elastic Security detection engine by installing this rule into your Elastic Stack.

To setup this rule, check out the installation guide for Prebuilt Security Detection Rules(external, opens in a new tab or window).