Multiple Elastic Defend Alerts from an Agentic Attack

Last updated 2 days ago on 2026-11-30
Created 2 days ago on 2026-11-30

About

Detects a host with Elastic Defend behavior alerts from an agentic attack. The command line, parent command line, executable path, or file path carries an intent ID such as i42463_dbg.b64 or i43345sys, or the command line prints at least three section banners that each end in a semicolon, such as echo "===SQL_CTX===" followed by a semicolon. The rule fires when one host.id has ten or more such alerts in the one-hour lookback, or alerts from at least two behavior rules. Repeat alerts for that host are suppressed for one hour.
Tags
Domain: EndpointUse Case: Threat DetectionTactic: ExecutionRule Type: Higher-Order RuleData Source: Elastic DefendRule Type: ES|QLThreat: Agentic Offensive FrameworksLanguage: esql
Severity
critical
Risk Score
99
MITRE ATT&CK™

Execution (TA0002)(external, opens in a new tab or window)

False Positive Examples
A short token inside a base64 blob, a Claude shell-snapshot suffix, or a build id such as i8129m can still match the intent pattern. One encoded-command rule firing a handful of times stays under the count of ten. Operators also label shell output with echo "=== section ===". Each banner has to end with a semicolon, so a label followed by && does not match, and the alert has to come from a production behavior rule. A production rule that repeats that script ten times in an hour can still alert, as can two production rules on one host. Exclude that host.id after confirming the commands are a known playbook.
License
Elastic License v2(external, opens in a new tab or window)

Definition

Integration Pack
Prebuilt Security Detection Rules
Related Integrations

(external, opens in a new tab or window)

Query
text code block:
from logs-endpoint.alerts-* metadata _id | where data_stream.dataset == "endpoint.alerts" // Lucene RLIKE is a whole-string match and has no lookaround. // Arm 1: i + 4-7 digits + at most 16 token characters (e.g. i42693_logon.txt). // Arm 2: anchored bare IDs (e.g. probe_i21481, artex-i42463). // Arm 3: path-shaped bare IDs (e.g. /tmp/i21481/, Temp\i44184\). Not fully open bare iNNNN. // Three or more echo "===section===" banners, each ending in ;. A label followed by && does not match. | where process.command_line rlike "(.*[^A-Za-z0-9])?i[0-9]{4,7}[A-Za-z_][A-Za-z0-9_]{0,15}([^A-Za-z0-9_].*)?" or process.command_line rlike ".*(artex|pentest|probe|canary)[-_]?i[0-9]{4,7}([^A-Za-z0-9].*)?" or process.command_line rlike ".*[/\\\\]i[0-9]{4,7}([/\\\\].*)?" or process.parent.command_line rlike "(.*[^A-Za-z0-9])?i[0-9]{4,7}[A-Za-z_][A-Za-z0-9_]{0,15}([^A-Za-z0-9_].*)?" or process.parent.command_line rlike ".*(artex|pentest|probe|canary)[-_]?i[0-9]{4,7}([^A-Za-z0-9].*)?" or process.parent.command_line rlike ".*[/\\\\]i[0-9]{4,7}([/\\\\].*)?" or process.executable rlike "(.*[^A-Za-z0-9])?i[0-9]{4,7}[A-Za-z_][A-Za-z0-9_]{0,15}([^A-Za-z0-9_].*)?" or process.executable rlike ".*(artex|pentest|probe|canary)[-_]?i[0-9]{4,7}([^A-Za-z0-9].*)?" or process.executable rlike ".*[/\\\\]i[0-9]{4,7}([/\\\\].*)?" or process.parent.executable rlike "(.*[^A-Za-z0-9])?i[0-9]{4,7}[A-Za-z_][A-Za-z0-9_]{0,15}([^A-Za-z0-9_].*)?" or process.parent.executable rlike ".*(artex|pentest|probe|canary)[-_]?i[0-9]{4,7}([^A-Za-z0-9].*)?" or process.parent.executable rlike ".*[/\\\\]i[0-9]{4,7}([/\\\\].*)?" or file.path rlike "(.*[^A-Za-z0-9])?i[0-9]{4,7}[A-Za-z_][A-Za-z0-9_]{0,15}([^A-Za-z0-9_].*)?" or file.path rlike ".*(artex|pentest|probe|canary)[-_]?i[0-9]{4,7}([^A-Za-z0-9].*)?" or file.path rlike ".*[/\\\\]i[0-9]{4,7}([/\\\\].*)?" or process.command_line rlike "((.|\n|\r)*echo[^A-Za-z0-9\n\r]{0,3}={3}[^=\n\r]{1,80}={3}[^A-Za-z0-9\n\r;]{0,3};(.|\n|\r)*){3}" | stats Esql.alert_count = count(*), Esql.rule_name_count_distinct = count_distinct(rule.name), Esql.rule_name_values = values(rule.name), Esql.process_command_line_values = values(process.command_line), Esql.process_parent_command_line_values = values(process.parent.command_line), Esql.process_executable_values = values(process.executable), Esql.process_parent_executable_values = values(process.parent.executable), Esql.file_path_values = values(file.path), Esql.user_name_values = values(user.name) by host.id, agent.id | where Esql.alert_count >= 10 or Esql.rule_name_count_distinct >= 2 | eval process.command_line = mv_first(Esql.process_command_line_values), process.parent.command_line = mv_first(Esql.process_parent_command_line_values), process.executable = mv_first(Esql.process_executable_values), process.parent.executable = mv_first(Esql.process_parent_executable_values), file.path = mv_first(Esql.file_path_values), user.name = mv_first(Esql.user_name_values) | keep host.id, agent.id, user.name, process.command_line, process.parent.command_line, process.executable, process.parent.executable, file.path, Esql.*

Install detection rules in Elastic Security

Detect Multiple Elastic Defend Alerts from an Agentic Attack in the Elastic Security detection engine by installing this rule into your Elastic Stack.

To setup this rule, check out the installation guide for Prebuilt Security Detection Rules(external, opens in a new tab or window).