# Avoiding mistakes with AWS OIDC integration conditions

AWS IAM OIDC trust policies missing sub/aud conditions let attackers from GitHub, GitLab, Terraform Cloud, Defender assume victim roles.

- Payout: Research
- Severity: high
- Program: Amazon
- Write-up by: Wiz Research
- Disclosed: 2025-01-01
- Write-up quality: 6/10
- Original: https://www.wiz.io/blog/avoiding-mistakes-with-aws-oidc-integration-conditions
- Library page: https://bugbountylibrary.com/r/blog%3Awiz-io-blog-avoiding-mistakes-with-aws-oidc-integration-conditions
- Tags: area:cloud domain:cloud impact:internal-access kind:research platform:threat-intel sev:high tech:aws tech:github-actions technique:source-review vuln:access-control vuln:auth-bypass vuln:misconfiguration

**Target:** AWS IAM role trust policy with OIDC federated identity provider
**Root cause:** OIDC trust policies that omit the sub (or vendor-specific) condition do not restrict which identities from the provider can assume the role, so any account holder on that SaaS can assume it.
**Steps:**
1. Identify an IAM role trusting token.actions.githubusercontent.com without a token.actions.githubusercontent.com:sub condition.
2. Create a GitHub repo and Action in attacker's own account.
3. Configure the Action to call sts:AssumeRoleWithWebIdentity against the victim role ARN.
4. Obtain temporary AWS credentials for the victim role.
**How found:** Reviewed public documentation of 20+ vendors' AWS OIDC integrations to determine which condition keys each requires, then built detections for integrations missing the required conditions.
**Exploitation:** Attacker signs up for the SaaS (e.g. GitHub), creates a workflow/repo, and requests a web identity token; with no sub restriction the STS call succeeds and returns credentials for the victim's IAM role, granting access to the AWS account.
**Insight:** Don't assume a 'sub' condition is universal: Microsoft Defender requires sts:RoleSessionName and DoIT/env0 use aws:RequestTag/*; also verify whether aud/provider URL values are truly customer-unique (Defender's are shared across all customers).

## Proof of concept (copied exactly from the original report)

**Correct GitHub Actions trust policy with sub condition**

```
{
 "Effect": "Allow",
 "Principal": {
 "Federated": "arn:aws:iam::123456789012:oidc-provider/token.actions.githubusercontent.com"
 },
 "Action": "sts:AssumeRoleWithWebIdentity",
 "Condition": {
 "StringEquals": {
 "token.actions.githubusercontent.com:sub": "repo:GithubOrg/GitHubRepo:ref:refs/heads/GitHubBranch",
 "token.actions.githubusercontent.com:aud": "sts.amazonaws.com"
 }
 }
}
```

