Course contentsShow
← Security
Lesson 1739 of 3,05235. Cloud Security - IAMFree lesson

External ID for Third-Party Access

Using External IDs to prevent confused deputy attacks when granting cross-account access to third parties.

External ID for Third-Party Access

What you'll learn: How to use External IDs to prevent attackers from tricking third-party services into accessing the wrong AWS account.

The Confused Deputy Problem

When you grant a third-party service (like a monitoring vendor or security scanner) access to your AWS account via AssumeRole, you create a potential vulnerability called the confused deputy attack. Here's the risk: if the third-party uses the same IAM role ARN for all customers, an attacker who is also a customer of that service could trick it into accessing your account instead of theirs.

Think of it like this: Imagine a delivery driver (the third-party) who has keys to many buildings. Without apartment numbers, a malicious tenant could redirect the driver to deliver someone else's package to their apartment instead.

How External ID Solves This

An External ID is a random, unique secret string you generate and share only with the trusted third-party. You add it as a condition in your role's trust policy:

{
  "Effect": "Allow",
  "Principal": {"AWS": "arn:aws:iam::123456789012:role/ThirdPartyRole"},
  "Action": "sts:AssumeRole",
  "Condition": {
    "StringEquals": {
      "sts:ExternalId": "unique-secret-12345"
    }
  }
}

Now the third-party must provide both your role ARN and the correct External ID. Since only you and the legitimate service know this value, an attacker cannot trick the service into assuming your role.

Implementation Best Practices

  • Generate a strong, random External ID (treat it like a password)
  • Never reuse External IDs across different third-parties
  • The third-party should store your External ID securely per-customer
  • Document which External ID belongs to which vendor

Key Takeaway: External IDs act as a shared secret that proves the third-party is acting on your behalf, preventing confused deputy attacks where malicious actors could otherwise hijack cross-account access.