AWS Bedrock AgentCore Code Interpreter Accesses Instance Metadata Credentials

Last updated 7 days ago on 2026-11-25
Created 7 days ago on 2026-11-25

About

Identifies code or shell commands submitted to an Amazon Bedrock AgentCore Code Interpreter that attempt to retrieve IAM execution-role credentials from the microVM metadata service (MMDS), or a response that contains AWS temporary credentials. An attacker with permission to invoke a Code Interpreter that has an execution role can retrieve the role's credentials and reuse them outside AgentCore. This can elevate the attacker to the permissions of the attached role.
Tags
Domain: CloudData Source: AWSData Source: Amazon Web ServicesPlatform: AWSData Source: AWS BedrockData Source: Amazon BedrockService: AWS BedrockUse Case: Threat DetectionTactic: Credential AccessThreat: IMDS Credential TheftThreat: Unauthorized AI UsageRule Type: ES|QLDomain: GenAIMitre Atlas: AML.T0098Language: esql
Severity
high
Risk Score
73
MITRE ATT&CK™

Credential Access (TA0006)(external, opens in a new tab or window)

False Positive Examples
Authorized security testing or troubleshooting may query MMDS or inspect temporary credentials. Confirm the caller and purpose. Production Code Interpreters should not retrieve or return raw execution-role credentials.
License
Elastic License v2(external, opens in a new tab or window)

Definition

Integration Pack
Prebuilt Security Detection Rules
Related Integrations

aws_bedrock_agentcore(external, opens in a new tab or window)

Query
text code block:
from logs-aws_bedrock_agentcore.code_interpreter_application_logs-* metadata _id, _version, _index | where aws.bedrock_agentcore.code_interpreter.operation == "InvokeCodeInterpreter" and ( TO_LOWER(process.command_line) like ( "*169.254.169.254*", "*fd00:ec2::254*", "*/latest/api/token*", "*/latest/meta-data/iam*", "*security-credentials*", "*x-aws-ec2-metadata-token*" ) or TO_LOWER(aws.bedrock_agentcore.code_interpreter.request_payload.code) like ( "*169.254.169.254*", "*fd00:ec2::254*", "*/latest/api/token*", "*/latest/meta-data/iam*", "*security-credentials*", "*x-aws-ec2-metadata-token*" ) or ( aws.bedrock_agentcore.code_interpreter.response_payload.stdout like "*AccessKeyId*" and aws.bedrock_agentcore.code_interpreter.response_payload.stdout like "*SecretAccessKey*" and aws.bedrock_agentcore.code_interpreter.response_payload.stdout like ("*Token*", "*SessionToken*") ) or ( aws.bedrock_agentcore.code_interpreter.response_payload.stderr like "*AccessKeyId*" and aws.bedrock_agentcore.code_interpreter.response_payload.stderr like "*SecretAccessKey*" and aws.bedrock_agentcore.code_interpreter.response_payload.stderr like ("*Token*", "*SessionToken*") ) ) | keep _id, _version, _index, @timestamp, aws.*, cloud.*, event.*, process.*, data_stream.namespace

Install detection rules in Elastic Security

Detect AWS Bedrock AgentCore Code Interpreter Accesses Instance Metadata Credentials 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).