Skip to main content

Triage and Remediation

Remediation

Using Console

To prevent a cross‑service confused deputy for Amazon Bedrock Agents, you need to lock down the trust policy on the IAM service role used by your agents.Below are step‑by‑step instructions using the AWS Management Console.

1. Identify the Bedrock Agent service role(s)

  1. Sign in to the AWS Management Console.
  2. Open Amazon Bedrock.
  3. In the left navigation, choose Agents.
  4. For each agent:
    • Click the agent name.
    • Go to the Agent configuration or Permissions section.
    • Note the IAM role shown as the service role used by the agent.
      Example: AmazonBedrockAgentExecutionRole or similar.
You’ll need to update the trust policy for each such role.

2. Open the role in IAM

  1. Open the IAM console.
  2. In the left navigation, choose Roles.
  3. Search for the role name you noted (e.g., AmazonBedrockAgentExecutionRole).
  4. Click the role name.

3. Restrict the trusted principal to Bedrock only

  1. In the role details, go to the Trust relationships tab.
  2. Click Edit trust policy.
  3. Make sure the Principal is only Amazon Bedrock, not a broader service list.
    It should look like this:
Replace 123456789012 with your AWS account ID.If your agent is in a single Region and you want to be stricter, you can use:
Make sure:
  • There is no other service listed in Principal.Service.
  • There is no wildcard * principal.

4. Save the trust policy

  1. After editing, click Update policy (or Save changes).
  2. Repeat steps 2–4 for every Bedrock Agent service role you use.

5. (Optional) Re‑associate or test agents

  1. Return to the Amazon Bedrock console.
  2. Open an agent that uses this role.
  3. Run a test invocation (e.g., “Test agent” or “Invoke”) to verify the agent still functions.
  4. Watch CloudWatch Logs for any access‑denied issues if you changed other permissions.

This remediation (adding aws:SourceAccount and aws:SourceArn conditions and limiting Principal.Service to bedrock.amazonaws.com) is what prevents a confused deputy scenario for Bedrock Agent service roles.
To prevent confused‑deputy issues for Amazon Bedrock Agents, you must restrict the IAM role trust policy that Bedrock assumes, using aws:SourceAccount and aws:SourceArn conditions.Below are step‑by‑step AWS CLI instructions.

1. Identify the Bedrock Agent service role

If you already know the role name, skip to step 2.Common patterns:
  • AmazonBedrockExecutionRoleForAgents_*
  • A custom role specified when you created the agent.
List roles and filter:
Assume the role name is:

2. Get the current trust policy

You’ll edit a new file instead of overwriting this backup.

3. Construct a secure trust policy

You must:
  • Keep the correct service principal:
    bedrock.amazonaws.com
  • Add both:
    • aws:SourceAccount – your AWS account ID
    • aws:SourceArn (or ArnLike/ArnEquals) – specific Bedrock Agent ARN(s)
First, get your account ID:
Get the Agent ARN(s). For example (Agents API):
Pick the relevant ARN or use a prefix pattern. Example agent ARN:
Create a new file bedrock-agent-trust-policy.json with content like:
Adjust:
  • Region: us-east-1 → your region
  • Account: 123456789012$ACCOUNT_ID
  • agent/* → specific agent ID if you want to restrict to one:
If this role is also used by other Bedrock features (e.g., knowledge bases), add separate statements for each service/ARN pattern instead of broadening the existing one.

4. Apply the updated trust policy


5. (Optional) Verify the applied trust policy

Confirm:
  • Principal.Service is bedrock.amazonaws.com
  • Condition includes:
    • aws:SourceAccount = your account ID
    • aws:SourceArn restricted to your Agent ARN(s)

If you share the exact current trust policy JSON, I can give you a precise before/after version tailored to your account, region, and agent IDs.
To prevent cross-service confused deputy issues for AWS Bedrock Agents, you must tighten the trust policy of the Agent’s service role so that only your account and your Bedrock agents can assume it. Below is how to do that with Python (boto3).

1. Decide the correct trust policy

Replace 123456789012 with your AWS account ID and set the Region(s) as needed (* is fine if you use multiple Regions):
This ensures:
  • Only Bedrock in your account can assume the role.
  • Only ARNs that match your Bedrock agents can use it (prevents confused deputy).

2. Python script to update an existing Bedrock Agent service role

Install dependencies:
Python script (e.g., fix_bedrock_agent_trust.py):
Run:

3. Verify the change

  1. In the AWS console, go to IAM → Roles → your Bedrock Agent role.
  2. Check the Trust relationships tab.
  3. Confirm:
    • Principal: Service: bedrock.amazonaws.com
    • Conditions include aws:SourceAccount and aws:SourceArn as shown above.

If you share the exact role name(s) or how you create Bedrock Agents (CDK, CloudFormation, console, etc.), I can adapt the Python example to generate/create the role as well, not just update it.
This change updates the IAM role’s trust policy to restrict sts:AssumeRole by bedrock.amazonaws.com to a specific Bedrock Agent ARN via the ArnLike aws:SourceArn condition, preventing the cross‑service confused deputy issue. It does not force replacement of the role; Terraform will perform an in‑place update of the trust policy, but you must ensure any other required principals or conditions are also modeled in aws_iam_policy_document to avoid breaking access.Verification: terraform plan should show an in‑place update to aws_iam_role.bedrock_agent_role with a change to assume_role_policy only, adding the Condition -> ArnLike -> aws:SourceArn constraint for the specified Bedrock Agent ARN.