Bedrock AgentCore Starter Toolkit Creates Gateway IAM Roles Without Confused Deputy Protections
The AgentCore Starter Toolkit CLI created IAM roles for the AgentCore Gateway whose trust policies lacked aws:SourceArn and aws:SourceAccount conditions, unlike the console and a Jinja2 template. An attacker in another AWS account could point their own AgentCore Gateway at the victim's role ARN and have the service assume that role, gaining access to secrets, Lambda, KMS, DynamoDB and S3 data.
Originally disclosed on HackerOne
- Fixed in 53 days
- Disclosed after 4 months
NOTE! Thanks for submitting a report to Amazon Web Services! Please replace all the [square] sections below with the pertinent details. Remember, the more detail you provide, the easier it is for us to triage and respond quickly, so be sure to take your time filling out the report!
Description: The Bedrock AgentCore Starter Toolkit (https://github.com/aws/bedrock-agentcore-starter-toolkit) CLI (agentcore gateway create) creates IAM roles for the AgentCore Gateway with trust policies that lack aws:SourceArn and aws:SourceAccount condition keys. This enables a cross-account confused deputy attack where any AgentCore workload in any AWS account can assume the victim's Gateway role. The role grants access to all secrets in the account, full KMS permissions, the ability to invoke any Lambda function, full DynamoDB access, and read access to all S3 buckets.
Note: The AWS Console correctly includes these conditions when creating a Gateway via the web UI. The vulnerability is specific to the CLI toolkit's code path, which is the primary interface for developers automating infrastructure deployment.
The security intent exists but was not applied consistently: the Jinja2 template at utils/runtime/templates/execution_role_trust_policy.json.j2 correctly includes both conditions, and the AWS Console includes them. The Gateway trust policy constant at src/bedrock_agentcore_starter_toolkit/operations/gateway/constants.py (lines 47-56) does not.
The same missing-condition pattern appears in the CDK template (agentcore-stack.ts.j2, lines 37-40 and 312-314) and Terraform template (bedrock_agentcore.tf.j2, lines 238-247), meaning all infrastructure-as-code deployment paths are affected.
Steps To Reproduce:
1. Install the Bedrock AgentCore Starter Toolkit and create a Gateway:
pip install bedrock-agentcore-starter-toolkit
agentcore gateway create --name my-gateway
2. Inspect the created IAM role's trust policy:
aws iam get-role --role-name <gateway-role-name> --query 'Role.AssumeRolePolicyDocument'
3. Observe the trust policy:
BEDROCK_AGENTCORE_TRUST_POLICY = {
"Version": "2012-10-17",
"Statement": [
{
"Effect": "Allow",
"Principal": {"Service": "bedrock-agentcore.amazonaws.com"},
"Action": "sts:AssumeRole",
}
],
}
No Condition block. Compare with the Jinja2 template which correctly includes:
"Condition": {
"StringEquals": {
"aws:SourceAccount": "{{ account_id }}"
},
"ArnLike": {
"aws:SourceArn": "arn:aws:bedrock-agentcore:{{ region }}:{{ account_id }}:*"
}
}
This inconsistency confirms the security intent exists but was not applied to the Gateway trust policy constant.
4. Confused deputy exploitation: From a different AWS account with AgentCore access, configure an AgentCore Gateway target using the victim's role ARN. When the attacker's Gateway makes calls, the AgentCore service assumes the victim's role on the attacker's behalf.
The role created with this trust policy is granted (lines 58-102):
bedrock-agentcore:*onarn:aws:bedrock-agentcore:*:*:*secretsmanager:GetSecretValueon*(every secret in the account)lambda:InvokeFunctiononarn:aws:lambda:*:*:function:*(every Lambda)kms:*onarn:aws:kms:*:*:*(full KMS admin including key deletion)AmazonDynamoDBFullAccessmanaged policyAmazonS3ReadOnlyAccessmanaged policy
Impact
Summary:
An attacker with their own AWS account and AgentCore access can:
- Read all secrets in the victim's account via
secretsmanager:GetSecretValueon* - Invoke any Lambda function in the victim's account
- Read all S3 data via
AmazonS3ReadOnlyAccess - Read/write/delete any DynamoDB table via
AmazonDynamoDBFullAccess - Manage KMS keys including disabling or scheduling deletion via
kms:*
The attacker only needs to know the victim's role ARN, which follows a predictable naming pattern generated by the toolkit.
Additionally, the same trust policy pattern (without conditions) appears in the CDK template (agentcore-stack.ts.j2, lines 37-40 and 312-314) and Terraform template (bedrock_agentcore.tf.j2, lines 238-247), affecting users who deploy via infrastructure-as-code.
Recommended Fix
Add condition keys to BEDROCK_AGENTCORE_TRUST_POLICY in constants.py, matching the pattern already used in the Jinja2 trust policy template:
BEDROCK_AGENTCORE_TRUST_POLICY = {
"Version": "2012-10-17",
"Statement": [
{
"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>:*"
}
},
}
],
}
Since the constant is used at runtime, the account ID and region should be parameterized (as the Jinja2 template already does).
Apply the same fix to the CDK and Terraform templates.
Additionally, consider scoping down the attached permissions:
secretsmanager:GetSecretValueshould be limited toarn:aws:secretsmanager:*:*:secret:bedrock-agentcore-identity!*kms:*should be scoped to specific actions needed (e.g.,kms:Decrypt,kms:GenerateDataKey)
Disclosure
For awareness, we plan to publish a blog post detailing these findings after remediation. We are happy to share a draft ahead of publication and coordinate on timing.
Not written yet. The AI write-up for this report has not been written yet. The Original tab links to the source.
How it worked
Root cause
The Gateway trust policy constant omitted the aws:SourceArn and aws:SourceAccount condition keys that the console and the Jinja2 template already apply, so the service principal was trusted from any account.
Impact
An attacker with their own AWS account could read all secrets, invoke any Lambda, read all S3 data, read and write DynamoDB tables and manage KMS keys including deletion, needing only the victim's predictable role ARN.
What the attacker needed
Attacker has an AWS account; attacker has AgentCore access; victim used the CLI or IaC templates; attacker knows the victim's role ARN
The fix
The trust policy constant should be parameterised with the account ID and region and include the same StringEquals aws:SourceAccount and ArnLike aws:SourceArn conditions as the Jinja2 template, with the same change in the CDK and Terraform templates and tighter permission scoping.
How it was found
- Install the toolkit and create a Gateway with the CLI.
- Read the created role's trust policy with the IAM API.
- Note that the policy has no Condition block, unlike the Jinja2 template.
- From another AWS account, configure a Gateway target using the victim's role ARN so the service assumes it.
Explained by bugbounty.wiki with AI from the original and checked against quotes from it; it can still be wrong. Read the original before relying on a detail.
Not written yet. The AI write-up for this report has not been written yet. The Original tab links to the source.
When one AWS service acts on your behalf it assumes a role, and the role's trust policy says who may assume it. Here the policy only named the AgentCore service, not which account's AgentCore, so anyone's AgentCore could borrow the role. This is called a confused deputy: a trusted service is tricked into using its access for someone else.
What is Access control?
A user can do something their role should not allow: reach an admin function, act on a feature they have not paid for, or skip a permission check. IDOR is the special case where the object belongs to someone else.