LoFP LoFP / a shared nat, proxy, or automation host may legitimately invoke agentcore and use another iam role during the same lookback window. confirm whether the second role is attached to the target agentcore resource and whether its aws activity matches the intended workload. narrow exclusions to approved source and role combinations.

Techniques

Sample rules

Potential AWS Bedrock AgentCore Execution Role Credential Replay

Description

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.

Detection logic

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