(bedrockagentcore): 网关 L2 构造添加了冗余的无条件 STS: AssumeRole 信任声明
Describe the bug
aws_bedrockagentcore.Gateway (the L2 construct for AWS::BedrockAgentCore::Gateway) automatically generates a service-role trust policy (AssumeRolePolicyDocument) containing two statements for the bedrock-agentcore.amazonaws.com principal: 1. An unconditioned statement — no AWS:SourceAccount/AWS:SourceArn condition at all. 2. A correctly-scoped statement, restricting the same principal via AWS:SourceAccount/AWS:SourceArn (ArnLike) to this account and this specific Gateway's ARN pattern. Statement 2 alone is sufficient and correct. Statement 1 is redundant and is a classic confused-deputy gap: without any condition, any AWS resource that can name this specific role's ARN and assumes the bedrock-agentcore.amazonaws.com service principal (in principle, a different Gateway/AgentCore resource anywhere) could assume this role — nothing in that statement restricts the calling resource to this Gateway or even to this account. Confirmed live via iam:GetRole against a deployed Gateway (not just synth output): json { "Version": "2012-10-17", "Statement": [ { "Effect": "Allow", "Principal": { "Service": "bedrock-agentcore.amazonaws.com" }, "Action": "sts:AssumeRole" }, { "Effect": "Allow", "Principal": { "Service": "bedrock-agentcore.amazonaws.com" }, "Action": "sts:AssumeRole", "Condition": { "StringEquals": { "AWS:SourceAccount": "<account-id>" }, "ArnLike": { "AWS:SourceArn": "arn:AWS:bedrock-agentcore:<region>:<account-id>:gateway/<gateway-name>*" } } } ] } This appears to be a default-behavior quirk of the L2 construct's own role-generation logic — no prop on `agentcore.Gateway(...)`/`GatewayAuthorizer` exposes control over the generated trust policy's statement set, so there's no supported way to opt out of the unconditioned statement. ### Expected Behavior Only the correctly-scoped (conditioned) `sts:AssumeRole` statement should be present. The unconditioned statement should not be generated at all. ### Current Behavior Both statements are generated; the unconditioned one is a real, exploitable confused-deputy gap on the resulting IAM role. ### Reproduction Steps Python from aws_cdk import Stack, aws_bedrockagentcore as agentcore from constructs import Construct class ReproStack(Stack): def init(self, scope: Construct, construct_id: str, **kwargs) -> None: super().init(scope, construct_id, **kwargs) self.gateway = agentcore.Gateway( self, "MyGateway", gateway_name="my-gateway", protocol_configuration=agentcore.GatewayProtocol.mcp(), authorizer_configuration=agentcore.GatewayAuthorizer.using_aws_iam(), ) Deploy this stack, then inspect the generated Gateway service role's AssumeRolePolicyDocument via AWS iam get-role --role-name <role-name> (not just cdk synth — the behavior was confirmed against a deployed Gateway).
内容来源: aws/aws-cdk