KQLHunting query: tune before alertingMCP servers and agent configuration
MCP server process started by an AI client connects to a rare internet destination
Local stdio MCP servers run as child processes (node, npx, python, uvx, docker) of the AI client. A poisoned or rogue server can send data anywhere: SANDWORM_MODE's server exfiltrated over HTTPS to a workers.dev endpoint, GitHub and DNS. This hunt summarises public destinations reached by processes whose parent is an AI client and keeps destinations seen on at most two devices, which is where unexpected servers stand out.
- Log source
- Microsoft Defender for Endpoint: DeviceNetworkEvents
- Techniques
- AML.T0086 Exfiltration via AI Agent Tool Invocation · ASI04 Agentic Supply Chain Vulnerabilities · AML.T0110 AI Agent Tool Poisoning · ASI02 Tool Misuse and Exploitation
- MITRE ATT&CK
- T1567Exfiltration Over Web ServiceT1071.001Web Protocols
- Reviewed
- 2026-11-10
Query
let ai_clients = dynamic(["claude", "claude.exe", "Claude", "Claude.exe", "Cursor", "Cursor.exe", "Code", "Code.exe",
"Windsurf", "Windsurf.exe", "codex", "codex.exe", "gemini"]);
let mcp_launchers = dynamic(["node", "node.exe", "npx", "npx.cmd", "python", "python3", "python.exe", "uv", "uvx", "uvx.exe",
"docker", "docker.exe", "deno", "bun"]);
DeviceNetworkEvents
| where Timestamp > ago(7d)
| where ActionType == "ConnectionSuccess" and RemoteIPType == "Public"
| where InitiatingProcessParentFileName in~ (ai_clients) and InitiatingProcessFileName in~ (mcp_launchers)
| extend Destination = iff(isnotempty(RemoteUrl), RemoteUrl, RemoteIP)
| summarize Devices = dcount(DeviceName), Connections = count(), FirstSeen = min(Timestamp),
SampleCommandLine = take_any(InitiatingProcessCommandLine)
by Destination, InitiatingProcessFileName, InitiatingProcessParentFileName
| where Devices <= 2
| order by FirstSeen desc Expected false positives
- Legitimate remote APIs used by approved MCP servers (GitHub, Jira, cloud providers) on few devices
- Package registry downloads when npx or uvx fetches the server on first run
Sources
- Socket: SANDWORM_MODE npm worm poisons AI toolchains (Feb 2026)
- Model Context Protocol security best practices
- Defender XDR: DeviceNetworkEvents table
- Elastic rule: GenAI process connection to unusual domain
Reviewed against vendor documentation, not tested in your environment. Defensive use only.