Potential AWS Bedrock AgentCore Execution Role Credential Replay

edit
IMPORTANT: This documentation is no longer updated. Refer to Elastic's version policy and the latest documentation.

Potential AWS Bedrock AgentCore Execution Role Credential Replay

edit

Identifies a successful Amazon Bedrock AgentCore operation that can execute attacker-controlled content inside a microVM, followed by AWS API activity from the same source address under a different temporary access key and AssumedRole identity. This can indicate that the caller retrieved an AgentCore execution role’s credentials and replayed them outside AgentCore. The correlation does not depend on execution-role naming and can provide coverage when command, code, or Browser automation content is obfuscated or unavailable.

Rule type: esql

Rule indices: None

Severity: high

Risk score: 73

Runs every: 10m

Searches indices from: now-30m (Date Math format, see also Additional look-back time)

Maximum alerts per execution: 100

References:

Tags:

  • Domain: Cloud
  • Data Source: AWS
  • Data Source: AWS CloudTrail
  • Data Source: Amazon Web Services
  • Platform: AWS
  • Data Source: AWS Bedrock
  • Data Source: Amazon Bedrock
  • Service: AWS Bedrock
  • Service: AWS IAM
  • Use Case: Threat Detection
  • Tactic: Privilege Escalation
  • Tactic: Credential Access
  • Resources: Investigation Guide
  • Threat: IMDS Credential Theft
  • Threat: Unauthorized AI Usage
  • Rule Type: ES|QL
  • Domain: GenAI
  • Mitre Atlas: AML.T0098

Version: 1

Rule authors:

  • Elastic

Rule license: Elastic License v2

Investigation guide

edit

Triage and analysis

Investigating Potential AWS Bedrock AgentCore Execution Role Credential Replay

AgentCore Runtime, Harness, Code Interpreter, and Custom Browser workloads can have an IAM execution role available from the Firecracker microVM metadata service. The AgentCore data-plane operation is authorized using the caller’s credentials; credentials recovered from the microVM identify as the workload’s separate AssumedRole identity when reused.

This rule correlates execution-bearing AgentCore operations with a later non-AgentCore AWS API call under a different access key from the same source address. This is resilient to alternate MMDS encodings, SDK credential retrieval, encrypted command output, and Custom Browser automation, whose CDP content is not recorded. The correlation is heuristic: it establishes temporal and network proximity, not a cryptographic link between the second role and the AgentCore resource.

Possible investigation steps

  • Review Esql.agentcore_actions, Esql_priv.agentcore_identity_arn_values, and Esql_priv.agentcore_access_key_id_values to identify the initial caller and execution-bearing operation. Esql.first_agentcore_event and Esql_priv.first_agentcore_access_key/Esql_priv.first_agentcore_identity_arn identify the specific matched invocation.
  • Review Esql.follow_on_actions, Esql_priv.follow_on_identity_arn_values, and Esql_priv.follow_on_access_key_id_values to identify the suspected stolen role and how it was used. Esql.last_follow_on_event and Esql_priv.last_follow_on_access_key/Esql_priv.last_follow_on_identity_arn identify the specific matched follow-on call, which is guaranteed to use a different access key and a different identity than the matched invocation.
  • Retrieve the matching CloudTrail events using the account, source address, request IDs, and the query’s time window. Confirm the target Runtime/Harness, Code Interpreter, or Browser resource ARN.
  • Determine whether the follow-on role is attached to the target AgentCore resource. Review its permissions and all actions taken with the associated temporary access key.
  • Look for an adjacent AgentCore runtime_logs or code_interpreter_application_logs alert showing direct MMDS access or returned temporary credentials.
  • For attacker-created resources, correlate CreateAgentRuntime, CreateHarness, CreateCodeInterpreter, CreateBrowser, CreateWorkloadIdentity, and iam:PassRole activity.

False positive analysis

  • Shared egress infrastructure may place independent principals behind the same address. Compare user agents, request IDs, resource ownership, and exact timing before escalating.
  • Platform automation can create or invoke AgentCore and then assume workload roles. Validate the deployment flow and exclude only the approved source/role pair.

Response and remediation

  • Revoke active sessions for the affected execution role and investigate all API activity performed with the access key.
  • Remove unnecessary execution roles from Code Interpreter and Browser resources. Reduce required Runtime/Harness roles to least privilege.
  • Restrict bedrock-agentcore:InvokeAgentRuntimeCommand, bedrock-agentcore:InvokeAgentRuntimeCommandShell, Code Interpreter and Browser session permissions, and `iam:PassRole to approved principals and resources.

Setup

edit

This rule requires AWS CloudTrail logs ingested through the Elastic AWS integration and data-event logging for the AWS::BedrockAgentCore::Runtime, AWS::BedrockAgentCore::RuntimeEndpoint, AWS::BedrockAgentCore::CodeInterpreterCustom, and AWS::BedrockAgentCore::BrowserCustom resource types. The non-AgentCore follow-on API event is ordinarily available through management or the applicable AWS data-event logging.

Rule query

edit
from logs-aws.cloudtrail-* metadata _id, _version, _index
| where data_stream.dataset == "aws.cloudtrail" and
    event.outcome == "success" and source.ip is not null and
    aws.cloudtrail.user_identity.access_key_id is not null and
    aws.cloudtrail.user_identity.arn is not null and (
        (
            event.provider == "bedrock-agentcore.amazonaws.com" and event.action in (
                "InvokeAgentRuntimeCommand",
                "InvokeCodeInterpreter",
                "InvokeAgentRuntimeCommandShell",
                "ConnectBrowserAutomationStream",
                "InvokeBrowser"
            )
        ) or (
            aws.cloudtrail.user_identity.type == "AssumedRole" and event.provider not in (
                "bedrock-agentcore.amazonaws.com",
                "bedrock-agentcore-control.amazonaws.com",
                "bedrock.amazonaws.com",
                "bedrock-runtime.amazonaws.com",
                "logs.amazonaws.com",
                "monitoring.amazonaws.com",
                "xray.amazonaws.com",
                "ecr.amazonaws.com",
                "ecr-public.amazonaws.com"
            )
        )
    )
| eval Esql.is_agentcore_invocation =
    event.provider == "bedrock-agentcore.amazonaws.com" and event.action in (
        "InvokeAgentRuntimeCommand",
        "InvokeCodeInterpreter",
        "ConnectBrowserAutomationStream",
        "InvokeBrowser"
    )
| eval Esql.is_assumed_role_follow_on = not Esql.is_agentcore_invocation
| eval Esql.invocation_sort_key = case(
    Esql.is_agentcore_invocation,
    concat(
        to_string(@timestamp), "|",
        aws.cloudtrail.user_identity.access_key_id, "|",
        aws.cloudtrail.user_identity.arn
    ),
    null
  )
| eval Esql.follow_on_sort_key = case(
    Esql.is_assumed_role_follow_on,
    concat(
        to_string(@timestamp), "|",
        aws.cloudtrail.user_identity.access_key_id, "|",
        aws.cloudtrail.user_identity.arn
    ),
    null
  )
| stats
    Esql.agentcore_event_count = sum(case(Esql.is_agentcore_invocation, 1, 0)),
    Esql.follow_on_event_count = sum(case(Esql.is_assumed_role_follow_on, 1, 0)),
    Esql.first_agentcore_sort_key = min(Esql.invocation_sort_key),
    Esql.last_follow_on_sort_key = max(Esql.follow_on_sort_key),
    Esql.agentcore_actions = values(case(Esql.is_agentcore_invocation, event.action, null)),
    Esql.follow_on_actions = values(case(Esql.is_assumed_role_follow_on, event.action, null)),
    Esql.follow_on_providers = values(case(Esql.is_assumed_role_follow_on, event.provider, null)),
    Esql_priv.agentcore_identity_arn_values =
        values(case(Esql.is_agentcore_invocation, aws.cloudtrail.user_identity.arn, null)),
    Esql_priv.follow_on_identity_arn_values =
        values(case(Esql.is_assumed_role_follow_on, aws.cloudtrail.user_identity.arn, null)),
    Esql_priv.agentcore_access_key_id_values =
        values(case(Esql.is_agentcore_invocation, aws.cloudtrail.user_identity.access_key_id, null)),
    Esql_priv.follow_on_access_key_id_values =
        values(case(Esql.is_assumed_role_follow_on, aws.cloudtrail.user_identity.access_key_id, null)),
    Esql.cloud_region_values = values(cloud.region),
    Esql.user_agent_original_values = values(user_agent.original),
    Esql.cloudtrail_request_id_values = values(aws.cloudtrail.request_id),
    Esql.cloudtrail_resource_arn_values = values(aws.cloudtrail.resources.arn)
  by cloud.account.id, source.ip
| where Esql.agentcore_event_count >= 1 and Esql.follow_on_event_count >= 1
| eval Esql.first_agentcore_parts = split(Esql.first_agentcore_sort_key, "|")
| eval Esql.follow_on_parts = split(Esql.last_follow_on_sort_key, "|")
| eval Esql.first_agentcore_event = to_datetime(mv_slice(Esql.first_agentcore_parts, 0, 0))
| eval Esql_priv.first_agentcore_access_key = mv_slice(Esql.first_agentcore_parts, 1, 1)
| eval Esql_priv.first_agentcore_identity_arn = mv_slice(Esql.first_agentcore_parts, 2, 2)
| eval Esql.last_follow_on_event = to_datetime(mv_slice(Esql.follow_on_parts, 0, 0))
| eval Esql_priv.last_follow_on_access_key = mv_slice(Esql.follow_on_parts, 1, 1)
| eval Esql_priv.last_follow_on_identity_arn = mv_slice(Esql.follow_on_parts, 2, 2)
| where Esql.last_follow_on_event > Esql.first_agentcore_event and
    Esql_priv.last_follow_on_access_key != Esql_priv.first_agentcore_access_key and
    Esql_priv.last_follow_on_identity_arn != Esql_priv.first_agentcore_identity_arn
| sort Esql.last_follow_on_event desc
| drop Esql.first_agentcore_sort_key, Esql.last_follow_on_sort_key, Esql.first_agentcore_parts, Esql.follow_on_parts
| keep Esql.*, Esql_priv.*, cloud.account.id, source.ip

Framework: MITRE ATT&CKTM