KQLHunting query: tune before alertingAI coding agents on endpoints
Destructive cloud or cluster CLI command launched under an AI coding agent
A malicious prompt shipped in Amazon Q Developer for VS Code 1.84.0 (AWS-2025-015) told the agent, run with --trust-all-tools --no-interactive, to wipe the home directory and use AWS profiles to list and delete cloud resources; it failed only because of a syntax error. This hunt finds aws, az, gcloud, kubectl and terraform commands that destroy resources when the parent or grandparent is an AI agent.
- Log source
- Microsoft Defender for Endpoint: DeviceProcessEvents
- Techniques
- AML.T0101 Data Destruction via AI Agent Tool Invocation · ASI02 Tool Misuse and Exploitation · LLM06 Excessive Agency · ASI10 Rogue Agents
- MITRE ATT&CK
- T1485Data DestructionT1578.003Delete Cloud InstanceT1059.009Cloud API
- 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)";
DeviceProcessEvents
| where Timestamp > ago(30d)
| where InitiatingProcessFileName in~ (ai_agents) or InitiatingProcessParentFileName in~ (ai_agents)
or InitiatingProcessCommandLine matches regex ai_package_regex
or InitiatingProcessFolderPath contains "/.local/share/claude/versions/"
| where ProcessCommandLine matches regex @"(?i)(ec2\s+terminate-instances|s3\s+rb\b|s3\s+rm\b.*--recursive|iam\s+delete-(user|role|access-key)|rds\s+delete-db-(instance|cluster)|cloudformation\s+delete-stack|az\s+group\s+delete|gcloud\s+projects\s+delete|kubectl\s+delete\s+(ns|namespace)\b|terraform\s+destroy)"
| project Timestamp, DeviceName, AccountName, InitiatingProcessParentFileName, InitiatingProcessFileName,
FileName, ProcessCommandLine
| order by Timestamp desc Expected false positives
- Engineers asking an agent to tear down their own sandbox or test stack
- Agents run inside ephemeral environments whose credentials only reach throwaway accounts
Sources
- AWS security bulletin AWS-2025-015 (Amazon Q Developer for VS Code 1.84.0)
- The Register: Amazon Q extension shipped a prompt to wipe systems and cloud resources (Jul 2025)
- Elastic rule: Destructive AWS CLI command executed by GenAI agent
- Defender XDR: DeviceProcessEvents table
Reviewed against vendor documentation, not tested in your environment. Defensive use only.