threatdeck
Live 13:45 UTC ·

Detection library

KQLHunting query: tune before alertingMCP servers and agent configuration

AI tool MCP or agent configuration written by a process other than the tool

SANDWORM_MODE's McpInject module (February 2026) wrote a rogue MCP server into ~/.claude/settings.json, ~/.cursor/mcp.json, ~/.continue/config.json, Windsurf and Claude Desktop configs so the AI tool would launch it on next start. MCP servers are defined in ~/.claude.json and .mcp.json (Claude Code), ~/.cursor/mcp.json (Cursor), claude_desktop_config.json (Claude Desktop), ~/.gemini/settings.json (Gemini CLI) and ~/.codex/config.toml (Codex). This hunt lists writes to those files by anything other than the owning tools.

Log source
Microsoft Defender for Endpoint: DeviceFileEvents
Techniques
AML.T0081 Modify AI Agent Configuration · ASI04 Agentic Supply Chain Vulnerabilities · AML.T0110 AI Agent Tool Poisoning · LLM03 Supply Chain
MITRE ATT&CK
T1546Event Triggered Execution
Reviewed
2026-11-10

Query

let ai_agents = dynamic(["claude", "claude.exe", "codex", "codex.exe", "cursor-agent", "Cursor", "Cursor.exe", "Cursor Helper (Plugin)", "gemini", "copilot", "Windsurf", "Windsurf.exe", "q"]);
let ai_package_regex = @"(@anthropic-ai[\\/]claude-code|@google[\\/]gemini-cli|@openai[\\/]codex)";
DeviceFileEvents
| where Timestamp > ago(14d)
| where ActionType in ("FileCreated", "FileModified", "FileRenamed")
| where FileName in~ ("mcp.json", ".mcp.json", "claude_desktop_config.json", ".claude.json", "mcp_config.json")
     or (FileName =~ "settings.json" and (FolderPath contains "/.claude/" or FolderPath contains @"\.claude\"
                                          or FolderPath contains "/.gemini/" or FolderPath contains @"\.gemini\"))
     or (FileName =~ "config.json" and (FolderPath contains "/.continue/" or FolderPath contains @"\.continue\"))
     or (FileName =~ "config.toml" and (FolderPath contains "/.codex/" or FolderPath contains @"\.codex\"))
| where not(InitiatingProcessFileName in~ (ai_agents)
            or InitiatingProcessFileName in~ ("Claude", "Claude.exe", "Code", "Code.exe", "Code Helper (Plugin)")
            or InitiatingProcessFolderPath contains "/.local/share/claude/versions/"
            or InitiatingProcessCommandLine matches regex ai_package_regex)
| project Timestamp, DeviceName, ActionType, FolderPath, FileName, InitiatingProcessFileName,
          InitiatingProcessCommandLine, InitiatingProcessParentFileName, InitiatingProcessAccountName
| order by Timestamp desc

Expected false positives

  • git clone / checkout of repositories that contain .mcp.json or .claude/settings.json
  • Dotfile managers, MDM or configuration management that deploy approved MCP configs
  • IDE extensions that register MCP servers during setup

Sources

Reviewed against vendor documentation, not tested in your environment. Defensive use only.

Following

Follow the vendors, products, AI tools, techniques and actors you care about. Matching stories, CVEs and exploited bugs are marked, a Following tab appears in the feed, and returning visits show what changed. Saved only in this browser.

Presets

Get updates

A personal RSS feed of new stories on everything you follow. Paste it into any feed reader, Slack or Teams RSS app.