Wildcard Principal in IAM Trust Policies: The Open Door
Overview
An IAM role trust policy with a wildcard Principal and no conditions lets any AWS account call sts:AssumeRole. A bare account principal is narrower, trusting that one account rather than the internet, and SCPs cannot inspect trust policies at all.
At a glance
- Symptom
- An external party discovers the role ARN and calls sts:AssumeRole from an unrelated AWS account.
- Likely cause
- IAM role trust policy Principal set to a wildcard or bare account root with no ExternalId or PrincipalOrgID condition.
- Impact
- Any AWS account can assume the role and inherit its permissions, including data lake reads, secrets access, or KMS decrypt rights.
- Verification signal
- Re-run the detection test and a controlled negative-path test.
- Safe correction
- Scope Principal to the exact account ARN and enforce sts:ExternalId or aws:PrincipalOrgID conditions, backed by policy checks on templates in CI and alerts on new IAM Access Analyzer…
- Rollback or recovery
- Restore the exported configuration if the new control blocks required production traffic, then narrow the policy before redeployment.
The Trap
A cross-account IAM role trust policy written with "Principal": {"AWS": "*"} and no Condition block grants sts:AssumeRole to every principal in every AWS account on the internet, not just the vendor or subsidiary account the role was built for. One written with a bare account root ARN and no conditions is narrower but still loose: it trusts every principal in that account that its own IAM policies allow to assume the role.
The Default State
This pattern appears constantly during SaaS integration onboarding. A vendor’s setup script or Terraform module ships with the trust policy hardcoded as a wildcard because the vendor doesn’t know the customer’s account ID at template-generation time, with the intention that the customer will “tighten it later”.
Some CloudFormation quick-start stacks for monitoring and logging tools can do the same thing, defaulting to a broad principal and an optional, often-skipped ExternalId parameter. Engineers copy these templates for a proof of concept, the role gets attached to a production data pipeline, and the wildcard is never revisited because the role appears to work correctly with the intended account.
The Blast Radius
Any AWS account, anywhere, can now call sts:AssumeRole against that role ARN.
If the role carries permissions like s3:GetObject on a data lake bucket, secretsmanager:GetSecretValue, or kms:Decrypt, an attacker who simply discovers the role ARN, from a leaked CloudFormation output, a GitHub commit, or a public S3 bucket policy, can assume it from their own throwaway account and pull credentials scoped to the role’s permissions.
A wildcard principal is plain open access: without an ExternalId or organisation condition, there is nothing to distinguish the legitimate vendor call from an opportunistic one. A trust that names only the vendor’s account without an ExternalId carries the related confused deputy risk, which AWS documents the external ID as preventing.
CloudTrail will log the assumption as a normal, successful AssumeRole event from an unfamiliar account, which most SIEM rules don’t flag unless someone has built an explicit anomaly detection for cross-account assumption from unrecognised account IDs.
The Lead Mechanic Fix
Never leave Principal unscoped. Pin it to the exact account and require conditions: "Principal": {"AWS": "arn:aws:iam::VENDOR-ACCOUNT-ID:root"} with "Condition": {"StringEquals": {"sts:ExternalId": "unique-shared-secret"}} for a vendor or, where the caller is internal, "Condition": {"StringEquals": {"aws:PrincipalOrgID": "o-xxxxxxxxxx"}}.
Find existing offenders with IAM Access Analyzer external access findings for AWS::IAM::Role, from an organisation-wide analyzer or one per account, then audit CloudTrail for AssumeRole events where the calling userIdentity.accountId doesn’t match an approved allowlist.
An SCP cannot inspect the contents of a trust policy, so enforce this going forward with a policy check on templates in CI and alerts on new Access Analyzer findings.
Related reading
Apply the safer control
Before you change production
Confirm the affected scope, export the current configuration, and test the replacement control in a non-production environment first.
Fix commands and configuration
Principal"Principal": {"AWS": "arn:aws:iam::VENDOR-ACCOUNT-ID:root"}"Condition": {"StringEquals": {"sts:ExternalId": "unique-shared-secret"}}Verify, roll back or escalate
Verify
Re-run the detection test and a controlled negative-path test. Confirm the unsafe behaviour is blocked while approved traffic still succeeds.
Rollback
Restore the exported configuration if the new control blocks required production traffic, then narrow the policy before redeployment.
Escalate
Escalate when the blast radius is uncertain, the control cannot be tested safely, or remediation requires an outage or security exception.
Fixed? Get the next one before it hits you: The KBY Brief
Practical fixes for the systems you run, by email about twice a week. Unsubscribe at any time.
About this page
Credited to
Dates
Published
Last updated
Corrections
- : Corrected during a review of published articles. Details
Was this useful?
Reports go to the site owner and are used to correct pages. Corrections are listed at /corrections.
