0Pricing
AWS Security Academy · Lesson

External ID and the Confused Deputy

Prevent third parties from being tricked into misusing access.

External ID and the Confused Deputy is a free AWS Security Academy lesson on CoddyKit — lesson 3 of 4. You can read the complete lesson below for free — then practise it hands-on in the browser with a built-in code editor and a 24/7 AI tutor. It is part of the AWS Security Academy learning path, one of 4 lessons in the course, and your progress syncs across the web and the CoddyKit app.

A Subtle Trust Problem

When you let a third party assume a role in your account, a security risk called the confused deputy problem can arise. The external ID is the simple but vital control that prevents it. This pattern appears on the exam whenever a SaaS vendor needs access to your AWS account.

What a Confused Deputy Is

A confused deputy is a trusted entity (the deputy) that is tricked into using its authority on behalf of an attacker. In AWS, a third-party service has permission to assume roles in many customer accounts; an attacker could trick it into assuming your role if nothing ties the request to the legitimate customer relationship.

The Vendor Scenario

Imagine a monitoring SaaS that assumes a role in each customer account. The SaaS uses one AWS identity for everyone. If an attacker who is also a customer guesses your role ARN, they might persuade the SaaS to assume your role, since the SaaS is the trusted principal. Account ID alone is not enough to stop this.

Enter the External ID

The external ID is a unique, secret value the vendor assigns to your relationship. You put it in your role's trust policy as a condition, and the vendor must supply the exact same value when calling AssumeRole. Because the attacker does not know your external ID, they cannot trick the vendor into assuming your role.

Trust Policy with External ID

This trust policy requires the matching external ID. AssumeRole succeeds only when the vendor passes the identical value, defeating the confused-deputy attack.

"Condition": {
  "StringEquals": {
    "sts:ExternalId": "unique-customer-12345"
  }
}

Who Sets the External ID

Crucially, the vendor generates and controls the external ID, not the customer. This prevents customers from colluding to reuse the same value. AWS guidance is explicit: as a third party, you must assign each customer a unique external ID and require it on every assumption.

Not a Secret Password

The external ID is not meant to be a secret like a password; it can appear in setup instructions. Its security value comes from being unique per customer and controlled by the vendor, so an attacker cannot make the deputy use the wrong customer's value. Treat it as an anti-impersonation token, not a credential.

Pairing with Least Privilege

The external ID controls who can assume, but you still scope what the role can do with tight permission policies. Even a correctly authorized vendor should receive only the minimum permissions needed. Combine external ID, a specific principal, and least-privilege permissions for safe third-party access.

Beyond Vendors

The confused-deputy pattern also applies to AWS services acting on your behalf. Service-to-service trust often uses condition keys like aws:SourceArn and aws:SourceAccount in resource policies to ensure the calling service is acting for your resource, the same defensive idea in a different wrapper.

Spotting the Exam Cue

Whenever a question describes a third-party or SaaS assuming a role across accounts, the secure answer almost always involves an external ID in the trust policy. If the scenario is service-to-service, look for aws:SourceArn/aws:SourceAccount conditions instead. Recognizing the cue points you straight to the right control.

Putting It Together

The confused deputy problem lets an attacker trick a trusted third party into misusing its access. The external ID, unique per customer and controlled by the vendor, prevents it by requiring a matching value on AssumeRole. For AWS services, use aws:SourceArn and aws:SourceAccount. Always pair these with least-privilege permissions.

Quick Check

Test the confused-deputy concept.

Recap

The confused deputy problem arises when a trusted third party is tricked into misusing its cross-account access. The external ID, unique per customer and controlled by the vendor, prevents it via a trust-policy condition on sts:ExternalId. For AWS service-to-service trust, use aws:SourceArn and aws:SourceAccount, always with least privilege.

Frequently asked questions

Is the “External ID and the Confused Deputy” lesson free?

Yes — the full text of “External ID and the Confused Deputy” is free to read here on the web, and the AWS Security Academy course includes 4 lessons in total. To practise it interactively (a built-in code editor and a 24/7 AI tutor) and unlock the rest of the AWS Security Academy course, upgrade to CoddyKit PRO.

What will I learn in “External ID and the Confused Deputy”?

Prevent third parties from being tricked into misusing access. You practise AWS Security Academy with hands-on code you run directly in the browser, and a 24/7 AI tutor answers your questions as you work through the lesson.

Do I need any experience to start AWS Security Academy?

No prior experience is required. AWS Security Academy on CoddyKit is structured for beginners through advanced learners; this is — lesson 3 of 4, so you can start here or from the beginning and move at your own pace.

How long does the “External ID and the Confused Deputy” lesson take?

Most CoddyKit lessons take about 5–10 minutes. Each one is bite-sized and interactive, so you make steady progress and pick up exactly where you left off across the web and the app.

Can I write and run code in this AWS Security Academy lesson?

Yes. Every AWS Security Academy lesson includes a built-in code editor, so you write and run real code right in your browser and get instant AI feedback — no local setup required.

All lessons in this course

  1. How STS Issues Temporary Credentials
  2. AssumeRole and the Session Lifetime
  3. External ID and the Confused Deputy
  4. Session Policies and Tag-Based Scoping
← Back to AWS Security Academy