AWS Bedrock High Risk Filesystem or Execution Tool Invocation

Detects when a Bedrock model is prompted to invoke high-risk tools associated with shell execution, filesystem operations, or process spawning. Adversaries may use compromised AI agent pipelines or manipulated prompts to instruct the model to execute arbitrary system commands, read or write sensitive files, or spawn subprocesses — extending the blast radius of a credential compromise or prompt injection attack.

Elastic rule (View on GitHub)

  1[metadata]
  2creation_date = "2026/07/27"
  3integration = ["aws_bedrock"]
  4maturity = "production"
  5updated_date = "2026/07/27"
  6
  7[rule]
  8author = ["Elastic"]
  9description = """
 10Detects when a Bedrock model is prompted to invoke high-risk tools associated with shell execution, filesystem
 11operations, or process spawning. Adversaries may use compromised AI agent pipelines or manipulated prompts to
 12instruct the model to execute arbitrary system commands, read or write sensitive files, or spawn subprocesses —
 13extending the blast radius of a credential compromise or prompt injection attack.
 14"""
 15false_positives = [
 16    """
 17    Authorized AI agent workflows that include shell or filesystem tools may trigger this rule. Validate that the
 18    user identity and tool usage pattern are consistent with expected application behavior.
 19    """,
 20]
 21from = "now-60m"
 22interval = "10m"
 23language = "esql"
 24license = "Elastic License v2"
 25name = "AWS Bedrock High Risk Filesystem or Execution Tool Invocation"
 26note = """## Triage and analysis
 27
 28### Investigating AWS Bedrock High Risk Filesystem or Execution Tool Invocation
 29
 30This rule detects Bedrock model invocations where the prompt contains patterns associated with shell execution, filesystem access, or process spawning. These patterns may indicate a prompt injection attack, a compromised AI agent pipeline, or an insider attempting to use a Bedrock-backed application to execute unauthorized system operations.
 31
 32### Possible investigation steps
 33
 34- Review `gen_ai.prompt` to identify the specific tool invocation pattern that triggered the rule and determine whether it represents a legitimate tool call or a malicious instruction.
 35- Identify the user (`user.id`) and determine whether they are expected to interact with tools that perform filesystem or shell operations.
 36- Review the model ID (`gen_ai.request.model.id`) and the application context to understand whether shell or filesystem tools are part of the intended agent architecture.
 37- Correlate with other Bedrock invocation events from the same user in the preceding hour to assess whether this is an isolated event or part of a pattern.
 38- If the application uses Bedrock Agents, review the agent's configured action groups and Lambda functions to determine whether the tool invocation could have resulted in actual execution.
 39- Check for downstream evidence of execution: CloudTrail Lambda invocation events, SSM RunCommand, or EC2 activity correlated with the same time window.
 40
 41### False positive analysis
 42
 43- AI coding assistants and developer tools built on Bedrock may legitimately reference shell commands or file operations in their prompt templates.
 44- Security tooling that uses Bedrock to analyze shell scripts or code may produce prompts containing these patterns.
 45
 46### Response and remediation
 47
 48- If a prompt injection is confirmed, identify the injection source and remediate the input validation gap in the application layer.
 49- Review and restrict the tools available to the Bedrock Agent to the minimum required for its function.
 50- Apply Bedrock Guardrails to block or flag prompts containing high-risk tool invocation patterns.
 51- If credentials were compromised, rotate them immediately and audit all Bedrock and downstream API activity.
 52"""
 53references = [
 54    "https://docs.aws.amazon.com/bedrock/latest/userguide/agents-action-groups.html",
 55    "https://docs.aws.amazon.com/bedrock/latest/userguide/guardrails.html",
 56    "https://owasp.org/www-project-top-10-for-large-language-model-applications/",
 57]
 58risk_score = 73
 59rule_id = "51d50385-aa3d-448c-bc48-7d6bc39108a3"
 60setup = """The AWS Bedrock integration must be enabled with model invocation logging configured to capture prompt
 61and completion content. Ensure `logs-aws_bedrock.invocation-*` is ingested into Elasticsearch."""
 62severity = "high"
 63tags = [
 64    "Domain: Cloud",
 65    "Domain: LLM",
 66    "Data Source: AWS Bedrock",
 67    "Use Case: Threat Detection",
 68    "Tactic: Execution",
 69    "Resources: Investigation Guide",
 70]
 71timestamp_override = "event.ingested"
 72type = "esql"
 73
 74query = '''
 75from logs-aws_bedrock.invocation-* metadata _id, _version, _index
 76
 77| eval Esql.lowercase_prompt = TO_LOWER(gen_ai.prompt)
 78
 79| where
 80    Esql.lowercase_prompt like "*/bin/sh*" or
 81    Esql.lowercase_prompt like "*/bin/bash*" or
 82    Esql.lowercase_prompt like "*sh -c*" or
 83    Esql.lowercase_prompt like "*cmd.exe*" or
 84    Esql.lowercase_prompt like "*powershell*" or
 85    Esql.lowercase_prompt like "*exec(*" or
 86    Esql.lowercase_prompt like "*os.system*" or
 87    Esql.lowercase_prompt like "*subprocess*" or
 88    Esql.lowercase_prompt like "*python -c*" or
 89    Esql.lowercase_prompt like "*python3 -c*" or
 90    Esql.lowercase_prompt like "*curl *" or
 91    Esql.lowercase_prompt like "*wget *" or
 92    Esql.lowercase_prompt like "*/dev/tcp/*" or
 93    Esql.lowercase_prompt like "*nc -e*" or
 94    Esql.lowercase_prompt like "*ncat *" or
 95    Esql.lowercase_prompt like "*socat *" or
 96    Esql.lowercase_prompt like "*openssl s_client*" or
 97    Esql.lowercase_prompt like "*perl -e*" or
 98    Esql.lowercase_prompt like "*ruby -e*" or
 99    Esql.lowercase_prompt like "*php -r*" or
100    Esql.lowercase_prompt like "*node -e*" or
101    Esql.lowercase_prompt like "*base64 -d*" or
102    Esql.lowercase_prompt like "*bash -i*"
103
104| keep _id, _version, _index, @timestamp, user.id, cloud.account.id, gen_ai.request.model.id, gen_ai.prompt, gen_ai.completion
105'''
106
107[[rule.threat]]
108framework = "MITRE ATT&CK"
109
110[[rule.threat.technique]]
111id = "T1059"
112name = "Command and Scripting Interpreter"
113reference = "https://attack.mitre.org/techniques/T1059/"
114
115[rule.threat.tactic]
116id = "TA0002"
117name = "Execution"
118reference = "https://attack.mitre.org/tactics/TA0002/"
119
120[rule.alert_suppression]
121group_by = ["user.id", "cloud.account.id"]
122duration = {value = 1, unit = "h"}
123missing_fields_strategy = "suppress"
124
125[rule.investigation_fields]
126field_names = [
127    "@timestamp",
128    "user.id",
129    "cloud.account.id",
130    "gen_ai.request.model.id",
131    "gen_ai.prompt",
132    "gen_ai.completion",
133]

Triage and analysis

Investigating AWS Bedrock High Risk Filesystem or Execution Tool Invocation

This rule detects Bedrock model invocations where the prompt contains patterns associated with shell execution, filesystem access, or process spawning. These patterns may indicate a prompt injection attack, a compromised AI agent pipeline, or an insider attempting to use a Bedrock-backed application to execute unauthorized system operations.

Possible investigation steps

  • Review gen_ai.prompt to identify the specific tool invocation pattern that triggered the rule and determine whether it represents a legitimate tool call or a malicious instruction.
  • Identify the user (user.id) and determine whether they are expected to interact with tools that perform filesystem or shell operations.
  • Review the model ID (gen_ai.request.model.id) and the application context to understand whether shell or filesystem tools are part of the intended agent architecture.
  • Correlate with other Bedrock invocation events from the same user in the preceding hour to assess whether this is an isolated event or part of a pattern.
  • If the application uses Bedrock Agents, review the agent's configured action groups and Lambda functions to determine whether the tool invocation could have resulted in actual execution.
  • Check for downstream evidence of execution: CloudTrail Lambda invocation events, SSM RunCommand, or EC2 activity correlated with the same time window.

False positive analysis

  • AI coding assistants and developer tools built on Bedrock may legitimately reference shell commands or file operations in their prompt templates.
  • Security tooling that uses Bedrock to analyze shell scripts or code may produce prompts containing these patterns.

Response and remediation

  • If a prompt injection is confirmed, identify the injection source and remediate the input validation gap in the application layer.
  • Review and restrict the tools available to the Bedrock Agent to the minimum required for its function.
  • Apply Bedrock Guardrails to block or flag prompts containing high-risk tool invocation patterns.
  • If credentials were compromised, rotate them immediately and audit all Bedrock and downstream API activity.

References

Related rules

to-top