Elastic Defend Alerts from GenAI Utility or Descendant

Detects Elastic Defend alerts (behavior, malicious file, memory signature, shellcode) where the alerted process or its direct parent is a GenAI coding or assistant utility (e.g. Cursor, Claude, Windsurf, Cody, Continue, Aider, OpenClaw, Moltbot, Clawdbot, Codeium, Tabnine, GitHub Copilot). Activity from these tools can indicate prompt injection, malicious skills, or supply-chain abuse; this Higher-Order rule helps prioritize such alerts for triage.

Elastic rule (View on GitHub)

  1[metadata]
  2creation_date = "2026/02/27"
  3maturity = "production"
  4min_stack_comments = "ES|QL inline stats became generally available in 9.3.0 and MV_INTERSECTION is in preview since 9.3."
  5min_stack_version = "9.4.0"
  6updated_date = "2026/11/25"
  7
  8[rule]
  9author = ["Elastic"]
 10description = """
 11Detects Elastic Defend alerts (behavior, malicious file, memory signature, shellcode) where the alerted process or its
 12direct parent is a GenAI coding or assistant utility (e.g. Cursor, Claude, Windsurf, Cody, Continue, Aider, OpenClaw,
 13Moltbot, Clawdbot, Codeium, Tabnine, GitHub Copilot). Activity from these tools can indicate prompt injection, malicious
 14skills, or supply-chain abuse; this Higher-Order rule helps prioritize such alerts for triage.
 15"""
 16from = "now-9m"
 17interval = "5m"
 18language = "esql"
 19license = "Elastic License v2"
 20name = "Elastic Defend Alerts from GenAI Utility or Descendant"
 21note = """## Triage and analysis
 22
 23### Investigating Elastic Defend Alerts from GenAI Utility or Descendant
 24
 25Elastic Defend has raised an alert on a process that is either a GenAI coding/assistant application or a direct child of one. This can indicate prompt injection, malicious extension/skill execution, or abuse of AI-assisted development tools (e.g. fake VS Code extensions, malicious ClawHub skills).
 26
 27### Possible investigation steps
 28
 29- Identify the GenAI utility by looking for a process with an entity_id in Esql.genai_ancestor_ids
 30- Review the alert rule name and message to understand what behavior was detected (e.g. script execution, network, file write).
 31- Inspect process_command_line and parent command lines for download-and-execute, encoded commands, or suspicious arguments.
 32- Correlate with the same host and user for other alerts or with network/DNS for C2 or exfiltration.
 33- If the tool is Cursor/VS Code: check for recently installed extensions.
 34- If OpenClaw/Moltbot/Clawdbot: review installed skills and conversation history for prompt injection or malicious skill execution.
 35
 36### False positive analysis
 37
 38- Legitimate use of GenAI tools (e.g. running builds, package installs, or approved scripts) can trigger behavior rules. Tune by excluding known-safe rule names or process command-line patterns, or limit to higher-severity alerts.
 39- Approved automation or CI that runs under a GenAI-related process may need to be allowlisted.
 40
 41### Response and remediation
 42
 43- If abuse is confirmed: disable or restrict the GenAI tool, remove malicious extensions/skills, rotate any exposed API keys or credentials, and block IOCs at network/EDR level.
 44"""
 45references = ["https://attack.mitre.org/techniques/T1059/", "https://attack.mitre.org/techniques/T1195/002/"]
 46risk_score = 99
 47rule_id = "d4e5f6a7-b8c9-7d0e-1f2a-3b4c5d6e7f8a"
 48severity = "critical"
 49tags = [
 50    "Domain: Endpoint",
 51    "Domain: GenAI",
 52    "Use Case: Threat Detection",
 53    "Tactic: Initial Access",
 54    "Rule Type: Higher-Order Rule",
 55    "Resources: Investigation Guide",
 56    "Data Source: Elastic Defend",
 57    "Noise: Medium",
 58    "Performance: Normal",
 59    "Profile: Recommended",
 60    "Threat: Supply Chain",
 61    "Threat: Unauthorized AI Usage",
 62    "Rule Type: ES|QL",
 63    "Mitre Atlas: AML.T0053",
 64    "Mitre Atlas: AML.T0011",
 65]
 66timestamp_override = "event.ingested"
 67type = "esql"
 68
 69query = '''
 70FROM logs-endpoint.alerts-*, logs-endpoint.events.process-* metadata _id, _version, _index
 71| EVAL is_genai_spawn = TO_LOWER(process.parent.name) IN (
 72        "claude", "claude.exe", "cursor", "cursor.exe", "cursor helper", "cursor helper (plugin)",
 73        "codex", "codex.exe", "cody", "cody.exe", "copilot", "copilot.exe", "gemini-cli", "gemini-cli.exe",
 74        "openai", "openai.exe", "ollama", "ollama.exe", "llm", "llm.exe",
 75        "aider", "aider.exe", "cline", "cline.exe", "continue", "continue.exe",
 76        "zed", "zed.exe", "windsurf", "windsurf.exe",
 77        "tabnine", "tabnine.exe", "codeium", "codeium.exe", "bolt", "bolt.exe",
 78        "devin", "devin.exe", "replit", "replit.exe", "ghostwriter", "ghostwriter.exe", "bito", "bito.exe"
 79    ),
 80    is_openclaw_spawn = process.parent.name IN ("node", "node.exe") AND (
 81        process.parent.command_line LIKE "*openclaw*" OR
 82        process.parent.command_line LIKE "*moltbot*" OR
 83        process.parent.command_line LIKE "*clawdbot*"
 84    )
 85| WHERE process.Ext.ancestry IS NOT NULL AND
 86        (data_stream.dataset == "endpoint.alerts" OR is_genai_spawn OR is_openclaw_spawn)
 87
 88// Identify GenAI tool spawn events and capture their entity_ids
 89| EVAL genai_entity_id = CASE(is_genai_spawn OR is_openclaw_spawn, process.parent.entity_id, NULL)
 90
 91// Collect ALL GenAI entity_ids globally across the dataset
 92| INLINE STATS
 93    all_genai_entity_ids = VALUES(genai_entity_id) WHERE genai_entity_id IS NOT NULL
 94
 95// Find which GenAI entity_ids appear in this process's ancestry
 96| EVAL Esql.genai_ancestor_ids = MV_INTERSECTION(all_genai_entity_ids, process.Ext.ancestry)
 97
 98// Elastic Defend alerts from a GenAI ancestor
 99| WHERE Esql.genai_ancestor_ids IS NOT NULL
100        AND data_stream.dataset == "endpoint.alerts"
101
102// Normalize detection identity: rule.name when present, else alert type (malicious_file, shellcode_thread, ...)
103| EVAL Esql.detection_name = COALESCE(rule.name, event.code)
104
105// Null-safe exclusion list
106| WHERE Esql.detection_name IS NOT NULL AND NOT Esql.detection_name IN (
107            "Persistence via GenAI Tool",
108            "Code Editor Untrusted or Unsigned Child Process Execution",
109            "Suspicious Credential Access via GenAI Tool",
110            "Credential Access via GenAI Tool Descendant",
111            "Execution via Electron Child Process Node.js Module",
112            "Potential Decoy Document via User Execution",
113            "Suspicious Communication via Mail Protocol",
114            "Decoy Document Creation via Curl",
115            "Sleep Execution from Suspicious Process Path"
116        )
117
118// Aggregate per agent + GenAI ancestor process
119| STATS
120    Esql.alerts_count = COUNT(*),
121    Esql.unique_detections_count = COUNT_DISTINCT(Esql.detection_name),
122    Esql.detection_name_values = VALUES(Esql.detection_name),
123    Esql.rule_name_values = VALUES(rule.name),
124    Esql.event_code_values = VALUES(event.code),
125    Esql.host_name_values = VALUES(host.name),
126    Esql.process_name_values = VALUES(process.name),
127    Esql.process_command_line_values = VALUES(process.command_line),
128    Esql.process_parent_command_line_values = VALUES(process.parent.command_line),
129    Esql.message_values = VALUES(message),
130    Esql.process_entity_id_values = VALUES(process.entity_id),
131    Esql.process_executable_values = VALUES(process.executable),
132    Esql.process_hash_values = VALUES(process.hash.sha256),
133    Esql.user_id_values = VALUES(user.id),
134    Esql.user_name_values = VALUES(user.name),
135    Esql.alert_id_values = VALUES(_id),
136    Esql.first_alert = MIN(@timestamp),
137    Esql.last_alert = MAX(@timestamp)
138  BY data_stream.namespace, host.id, host.name, agent.id, Esql.genai_ancestor_ids
139
140// 2 or more distinct detections (rule.name or event.code)
141| WHERE Esql.unique_detections_count >= 2
142| keep data_stream.namespace, host.id, host.name, agent.id, Esql.*
143'''
144
145
146[[rule.threat]]
147framework = "MITRE ATT&CK"
148[[rule.threat.technique]]
149id = "T1195"
150name = "Supply Chain Compromise"
151reference = "https://attack.mitre.org/techniques/T1195/"
152[[rule.threat.technique.subtechnique]]
153id = "T1195.002"
154name = "Compromise Software Supply Chain"
155reference = "https://attack.mitre.org/techniques/T1195/002/"
156
157
158
159[rule.threat.tactic]
160id = "TA0001"
161name = "Initial Access"
162reference = "https://attack.mitre.org/tactics/TA0001/"
163[[rule.threat_mappings]]
164framework = "MITRE ATLAS"
165version = "2026.08"
166[[rule.threat_mappings.threat]]
167framework = "MITRE ATLAS"
168[[rule.threat_mappings.threat.technique]]
169id = "AML.T0011"
170name = "User Execution"
171reference = "https://atlas.mitre.org/techniques/AML.T0011/"
172
173[[rule.threat_mappings.threat.technique]]
174id = "AML.T0053"
175name = "AI Agent Tool Invocation"
176reference = "https://atlas.mitre.org/techniques/AML.T0053/"
177
178
179[rule.threat_mappings.threat.tactic]
180id = "AML.TA0005"
181name = "Execution"
182reference = "https://atlas.mitre.org/tactics/AML.TA0005/"

Triage and analysis

Investigating Elastic Defend Alerts from GenAI Utility or Descendant

Elastic Defend has raised an alert on a process that is either a GenAI coding/assistant application or a direct child of one. This can indicate prompt injection, malicious extension/skill execution, or abuse of AI-assisted development tools (e.g. fake VS Code extensions, malicious ClawHub skills).

Possible investigation steps

  • Identify the GenAI utility by looking for a process with an entity_id in Esql.genai_ancestor_ids
  • Review the alert rule name and message to understand what behavior was detected (e.g. script execution, network, file write).
  • Inspect process_command_line and parent command lines for download-and-execute, encoded commands, or suspicious arguments.
  • Correlate with the same host and user for other alerts or with network/DNS for C2 or exfiltration.
  • If the tool is Cursor/VS Code: check for recently installed extensions.
  • If OpenClaw/Moltbot/Clawdbot: review installed skills and conversation history for prompt injection or malicious skill execution.

False positive analysis

  • Legitimate use of GenAI tools (e.g. running builds, package installs, or approved scripts) can trigger behavior rules. Tune by excluding known-safe rule names or process command-line patterns, or limit to higher-severity alerts.
  • Approved automation or CI that runs under a GenAI-related process may need to be allowlisted.

Response and remediation

  • If abuse is confirmed: disable or restrict the GenAI tool, remove malicious extensions/skills, rotate any exposed API keys or credentials, and block IOCs at network/EDR level.

References

Related rules

to-top