Query Details

Suspicious VS Code Extensions Hunting

Query

# *Suspicious VS Code Extensions Hunting*

## Query Information

#### MITRE ATT&CK Technique(s)

| Technique ID | Title    | Link    |
| ---  | --- | --- |
| T1059 | Command and Scripting Interpreter | https://attack.mitre.org/techniques/T1059/ |


#### Description
This Kusto Query Language (KQL) script is designed to hunt for potentially malicious Visual Studio Code extensions across two risk profiles.

The first section defines SuspiciousExtension, which monitors for new file creations in the VS Code extensions folder that were not initiated by trusted processes (like VS Code itself or system setup tools). It specifically looks for files created by suspicious parent processes such as PowerShell, CMD, curl, or Wget.

The second section defines HighRiskExtension, which also monitors the extensions folder but narrows the search to high-risk file types (like .js, .exe, or .ps1) that appear from sources other than official updater processes.

Finally, the query unions these two datasets and applies a reputation check using the FileProfile function, filtering out common, well-known files to focus only on rare or unique files (Global Prevalence < 10000) that warrant further investigation.

#### Risk
Defense Evasion

#### Author <Optional>
- **Name: Benjamin Zulliger**
- **Github: https://github.com/benscha/KQLAdvancedHunting**
- **LinkedIn: https://www.linkedin.com/in/benjamin-zulliger/**

#### References
- 

## Defender XDR
```KQL
let SuspiciousExtension = DeviceFileEvents
| where TimeGenerated > ago(1h)
| where ActionType == "FileCreated"
| where FolderPath has_any ("vscode", "visual studio code", "microsoft vs code")
| where FolderPath has "extensions"
// Extension was NOT created by a normal VSCode process
| where InitiatingProcessFileName !in~ (
    "code.exe", "code-insiders.exe", "node.exe", 
    "winget.exe", "setup.exe", "CodeSetup.exe", "jamf app installers"
  )
// Suspicious parent processes
| where InitiatingProcessFileName has_any (
    "powershell", "cmd", "wscript", "cscript", 
    "mshta", "curl", "wget", "certutil"
  );
let HighRiskExtension = DeviceFileEvents
| where TimeGenerated > ago(1h)
| where ActionType == "FileCreated"
| where FolderPath has_any ("vscode", "visual studio code", "microsoft vs code")
| where FolderPath has "extensions"
// Only suspicious file types
| extend FileExtension = tolower(tostring(parse_path(FileName).Extension))
| where FileExtension in ("js", "ts", "vsix", "json", "ps1", "sh", "exe", "dll", "py")
// Not from the normal VSCode updater process
| where InitiatingProcessFileName !in~ (
    "code.exe", "code-insiders.exe", "node.exe", "winget.exe", "setup.exe"
  );
union SuspiciousExtension, HighRiskExtension
| invoke FileProfile(SHA256)
| where GlobalPrevalence < 10000
```

Explanation

This KQL query is designed to detect potentially malicious activities related to Visual Studio Code extensions. It focuses on identifying suspicious file creations in the VS Code extensions folder that might indicate unauthorized or harmful actions. Here's a simplified breakdown:

  1. SuspiciousExtension Detection:

    • The query looks for new files created in the VS Code extensions folder within the last hour.
    • It filters out files created by trusted processes like VS Code itself or system setup tools.
    • It specifically targets files created by potentially harmful processes such as PowerShell, CMD, curl, or Wget.
  2. HighRiskExtension Detection:

    • Similar to the first part, this section also monitors the VS Code extensions folder for new files.
    • It focuses on high-risk file types like JavaScript (.js), executable files (.exe), and scripts (.ps1).
    • It excludes files created by the official VS Code updater processes.
  3. Combining and Filtering:

    • The results from both sections are combined.
    • A reputation check is applied using the FileProfile function to filter out common, well-known files.
    • It highlights rare or unique files (those with a global prevalence of less than 10,000) for further investigation.

Overall, this query helps in identifying potentially malicious VS Code extensions that could be used for defense evasion by attackers.

Details

Benjamin Zulliger profile picture

Benjamin Zulliger

Released: May 21, 2026

Tables

DeviceFileEvents

Keywords

DeviceFileEventsFolderPathInitiatingProcessFileNameFileExtensionSHA256GlobalPrevalence

Operators

let|where>ago()==has_any()!in~()has()extendtolower()tostring()parse_path()in()unioninvoke<

Actions