When sts:AssumeRoleWithWebIdentity fails, the error string usually tells you which of four things is wrong: the IAM OIDC provider, the token, the role trust policy or the session request, but only if you know how to read it. This guide is an error-string lookup for the three places practitioners most often hit the call: EKS IAM Roles for Service Accounts (IRSA), generic OIDC issuers such as CI systems, and Amazon Cognito identity pools. For each message it gives the cause, the check that proves it and the fix that keeps the trust narrow. It is for cloud, platform and identity engineers who need to fix a failing workload today without widening a trust policy to make the error go away. The cross-cloud diagnostic method is in the Multi-Cloud Workload Identity Troubleshooting Guide; this page goes deeper on AWS messages only.
Key takeaways
- Decode the token first. Almost every failure is a mismatch between a claim in the token (
iss,aud,sub,exp) and what IAM expects. Read the token's payload before changing any policy. - InvalidIdentityToken is about the provider, AccessDenied is about the role. "No OpenIDConnect provider found" and "Incorrect token audience" point at the IAM OIDC provider; "Not authorized to perform sts:AssumeRoleWithWebIdentity" points at the trust policy.
- Condition keys are prefixed with the issuer host. Keys are the issuer URL without
https://plus the claim name, for exampletoken.actions.githubusercontent.com:sub. A typo in the prefix silently fails the condition. - Cognito has its own rules. Trust policies for
cognito-identity.amazonaws.commust include anaudcondition naming the identity pool, and the enhanced flow requires the role to be in the same account. - Never fix by widening. Replacing a
subcondition with a wildcard or removing theaudcheck makes the error disappear and lets other workloads assume the role.
How the call fails: four checkpoints
AssumeRoleWithWebIdentity does not need AWS credentials; the web identity token is the only proof of identity. STS checks it in a fixed order, and each checkpoint produces a different error.
| Checkpoint | What STS checks | Typical error | Where to look |
|---|---|---|---|
| 1. Provider | An IAM OIDC provider exists for the token's iss, its client ID list contains the token's audience, and the issuer's TLS certificate verifies | InvalidIdentityToken (provider not found, incorrect audience, thumbprint mismatch), IDPCommunicationError | IAM > Identity providers |
| 2. Token | Signature (RS256/384/512 or ES256/384/512), expiry, length 4 to 20,000 characters | ExpiredToken, InvalidIdentityToken, IDPRejectedClaim | The token payload; clock on the caller |
| 3. Role trust | The role's trust policy allows sts:AssumeRoleWithWebIdentity for the provider ARN, and every condition matches | AccessDenied: Not authorized to perform sts:AssumeRoleWithWebIdentity | Role > Trust relationships |
| 4. Session request | DurationSeconds, RoleSessionName, session policies and tags, STS Region status | MalformedPolicyDocument, PackedPolicyTooLarge, RegionDisabled | Calling code or SDK configuration |
Passing all four only proves the role was assumed. A later AccessDenied on S3 or DynamoDB is a permissions problem on the role, not a federation problem: see the AWS AccessDenied Troubleshooting Guide.
Error string lookup
Error codes and HTTP statuses below are from the AWS STS API reference; message strings are those AWS documentation and the AWS CLI show. SDKs wrap them differently, so search for the distinctive part of the message.
| Error and message | HTTP | Most likely cause | Check | Fix |
|---|---|---|---|---|
InvalidIdentityToken: No OpenIDConnect provider found in your account | 400 | No IAM OIDC provider matches the token's iss exactly (wrong account, cluster recreated, trailing path difference) | Compare the token's iss (or the EKS cluster's issuer URL) with aws iam list-open-id-connect-providers | Create the provider for that exact issuer in the account that owns the role |
InvalidIdentityToken: Incorrect token audience | 400 | The token's audience is not in the provider's ClientIDList | Decode the token's aud; read the provider's client IDs | Add the intended audience to the provider (for IRSA and most CI systems, sts.amazonaws.com) or request the token with the configured audience |
InvalidIdentityToken: OpenIDConnect provider's HTTPS certificate doesn't match configured thumbprint | 400 | AWS fell back to thumbprint verification and the stored thumbprint is wrong or stale | Check the CloudTrail field identityProviderConnectionVerificationMethod (IAMTrustStore or Thumbprint) | Recreate or update the provider thumbprint; include a thumbprint for both hosts if the issuer and jwks_uri differ |
InvalidIdentityToken: token could not be validated (other text) | 400 | Bad signature, unsupported algorithm, signature mismatch from a mis-ordered certificate chain, malformed token | Decode header alg and kid; confirm the key is in the issuer's JWKS | Fix the issuer's signing keys or chain; request a fresh token |
ExpiredToken | 400 | Token cached past its exp, or caller clock skew | Compare exp with the caller's UTC time | Request the token immediately before the call; sync time; for IRSA, make sure the SDK re-reads the token file |
IDPRejectedClaim | 403 | The identity provider reported authentication failed; for this API it can also mean the claim expired or was revoked | Check the issuer's own logs and token status | Issue a new token; fix the issuer-side rejection |
IDPCommunicationError | 400 | STS could not reach the issuer to verify the token; often transient | Fetch the issuer's discovery document and JWKS from the internet | Retry with back-off; make the issuer's discovery and JWKS endpoints publicly reachable |
AccessDenied: Not authorized to perform sts:AssumeRoleWithWebIdentity | 403 | Trust policy principal, action or a condition does not match the token | Compare each trust condition value with the decoded claims, character by character | Correct the condition to the exact claim value; do not wildcard it |
MalformedPolicyDocument | 400 | Invalid inline session policy passed in the call | Read the error detail | Fix the JSON; session policies (inline plus managed) are limited to 2,048 characters combined |
PackedPolicyTooLarge | 400 | Session policies and session tags made the session token too large | Count session tags (up to 50) and policy size; monitor SessionTokenUtilization | Trim tags or session policies |
RegionDisabled | 403 | STS is not activated in the requested Region for the account | Account settings > STS Regional endpoints | Activate the Region or call an enabled Regional endpoint |
| Duration exceeds the role's maximum | Varies by SDK | DurationSeconds above the role's maximum session duration (1 to 12 hours; API range 900 to 43,200 seconds, default 3,600) | Compare requested duration with the role setting | Request a shorter session rather than raising the role maximum |
IRSA on Amazon EKS
With IRSA, the EKS cluster is the OIDC issuer, the pod receives a projected service account token, and the SDK calls AssumeRoleWithWebIdentity using the role ARN and token file path that EKS injects as AWS_ROLE_ARN and AWS_WEB_IDENTITY_TOKEN_FILE.
- Provider: one IAM OIDC provider per cluster issuer (
https://oidc.eks.region.amazonaws.com/id/ID) withsts.amazonaws.comin the client ID list. A recreated cluster has a new issuer ID, which is the classic cause of "No OpenIDConnect provider found". - Trust conditions:
oidc.eks.region.amazonaws.com/id/ID:submust equalsystem:serviceaccount:namespace:service-accountand...:audmust equalsts.amazonaws.com. A namespace or service account name typo returns AccessDenied, not a clearer message. - Annotation: the service account needs
eks.amazonaws.com/role-arnnaming the role, and the pod'sserviceAccountNamemust point at that service account. - Environment: if
AWS_ROLE_ARNandAWS_WEB_IDENTITY_TOKEN_FILEare missing from the pod, it was not configured for IRSA; pods created before the annotation was added need a restart (kubectl rollout restart). - SDK: the AWS SDK in the container must be new enough to support the web identity credential provider; an old SDK silently falls back to the node's instance role, which then shows up as unexpected permissions rather than an error.
If you are moving clusters to EKS Pod Identity, most of these checks no longer apply. See How to migrate EKS workloads from IRSA to EKS Pod Identity and the EKS Identity Hardening Guide.
Generic OIDC issuers: CI systems and custom IdPs
For CI platforms and custom issuers, the provider ARN takes the form arn:aws:iam::account:oidc-provider/issuer-host-and-path, and condition keys use the same host and path as prefix: token.actions.githubusercontent.com:sub, or oidc.circleci.com/org/ORG_ID:aud for an issuer with a path.
| Condition key (default OIDC mapping) | Source claim | Usable after the session starts | Typical mistake |
|---|---|---|---|
:aud | azp, or aud if azp is not set | Yes | Expecting :aud to match aud when the issuer sets azp |
:oaud | aud | No (trust policy only) | Using it in a permissions policy |
:sub | sub | Yes | Matching a branch format when the job uses an environment, or the reverse |
:amr | amr | Yes | Rarely set by CI issuers |
:email | email | No (trust policy only) | Relying on a mutable value |
- GitHub Actions: IAM also exposes GitHub-specific keys such as
token.actions.githubusercontent.com:repository_id,:repository_owner_id,:job_workflow_refand:environment. If asubcondition used to work and now fails, check whether the repository emits GitHub's immutable subject format. The GitHub-side failures (missingid-token: write, wrong audience in the action) are covered in the GitHub Actions OIDC Errors Troubleshooting Guide. - StringEquals versus StringLike: a
subvalue containing*underStringEqualsmatches only a literal asterisk, so the trust fails; underStringLikeit matches anything. UseStringLikeonly with a bounded pattern, never a bare*. - Private issuers: STS must fetch the discovery document and JWKS over the internet. An issuer reachable only inside a VPC produces
IDPCommunicationErrororInvalidIdentityToken; publish the keys to a public endpoint.
Amazon Cognito identity pools
Cognito identity pools exchange a user's sign-in for AWS credentials. In the enhanced flow Cognito calls AssumeRoleWithWebIdentity in the background; in the basic (classic) flow the application calls it with a Cognito-issued token.
- Principal and action:
"Federated": "cognito-identity.amazonaws.com"withsts:AssumeRoleWithWebIdentity. - aud is mandatory:
cognito-identity.amazonaws.com:audmust name the identity pool ID. IAM refuses to save a new or modified trust policy for this principal without it. Older roles without the condition still work but cannot be edited until the condition is added, and cross-account basic-flow calls fail without it. - amr separates guests from users:
cognito-identity.amazonaws.com:amrwithauthenticatedorunauthenticated(usually underForAnyValue:StringLike). A mismatched role for the authentication type returns "Not authorized to perform sts:AssumeRoleWithWebIdentity"; AWS advises checking that the pool and authentication type have an appropriate role. - sub is a Cognito UUID:
cognito-identity.amazonaws.com:subis the identity pool's identity ID, not the user's original IdP subject, so a condition copied from the upstream IdP never matches. - Enhanced flow limits: the role must be in the same account as the identity pool. For unauthenticated users Cognito applies a scope-down session policy (
AmazonCognitoUnAuthedIdentitiesSessionPolicy), so calls to services outside that list fail with AccessDenied even when the role allows them. Do not widen this: AWS advises against granting guests more than the scope-down allows. - Source IP conditions: do not put
aws:SourceIpin trust policies for roles used in the enhanced flow; the call comes from Cognito, so the condition never matches.
See the Amazon Cognito Security Guide for identity pool hardening beyond error fixing.
A safe diagnostic order
- Capture the full error. Code, message and the role ARN requested. Note the Region and STS endpoint used.
- Decode the token payload (never paste a live token into an online decoder; decode locally) and record
iss,aud,azp,sub,exp. - Match the provider. Confirm an IAM OIDC provider exists in the role's account for exactly that issuer and lists the audience.
- Match the trust policy. Check principal ARN, action and each condition against the claims. Look for prefix typos and
StringEqualswith wildcards. - Check the session request. Duration against the role maximum, session name (2 to 64 characters, pattern
[\w+=,.@-]*), session policies and tags. - Read CloudTrail. Successful calls appear as
eventSourcests.amazonaws.com,eventNameAssumeRoleWithWebIdentity,userIdentity.typeWebIdentityUser, withsubjectFromWebIdentityTokenandaudiencein the response. CloudTrail logs non-authenticated web identity requests, but requests that are not sufficiently valid may not be logged. - Change one thing, retest, then revert any temporary logging. Record the root cause so the next engineer does not reach for a wildcard.
Detection and measurement
- Trust policy changes: alert on
UpdateAssumeRolePolicyfor federated roles, especially edits that remove anaudcondition or introduceStringLikewith a wildcard. - Provider changes: alert on
CreateOpenIDConnectProvider,AddClientIDToOpenIDConnectProviderandUpdateOpenIDConnectProviderThumbprintoutside change control. - Unexpected subjects: baseline
subjectFromWebIdentityTokenper role and alert on a new value.
Metrics
- Federated roles whose trust policy lacks an
audcondition (target zero). - Federated roles using
StringLikewith an unboundedsubpattern (target zero). - IAM OIDC providers with no role referencing them (stale providers, target zero).
- Mean time to resolve federation errors, from ticket to root cause recorded.
- Count of incidents where a federation error was "fixed" by widening trust (target zero).
To review providers and roles systematically, see How to audit AWS IAM Roles Anywhere and OIDC identity providers.
Common failure patterns
- Wildcard fix: an engineer replaces
repo:org/app:ref:refs/heads/mainwithrepo:org/*or*to clear AccessDenied, giving every repository (or every repository on the platform) the role. - Dropping the audience check: removing
:audto fix "Incorrect token audience" lets tokens minted for other services be replayed against the role. Fix the provider's client ID list instead. - Recreated cluster, old provider: the new EKS cluster issuer ID does not match the provider and every IRSA workload fails at once after a rebuild.
- Cognito guest over-permission: to get past the enhanced flow scope-down, teams switch to the basic flow and grant unauthenticated identities broad access.
- Silent instance-role fallback: an outdated SDK ignores the web identity variables and uses the node role, so there is no error but the workload runs with the wrong identity.
- Raising the role maximum session duration to cure a duration error, extending every session the role issues rather than fixing the caller.
Framework mapping
| Framework | Reference | Relevance |
|---|---|---|
| NIST SP 800-53 Rev 5 | IA-9 Service Identification and Authentication | Workloads authenticate with federated tokens bound to a provider |
| NIST SP 800-53 Rev 5 | IA-5 Authenticator Management | Short-lived tokens instead of stored access keys |
| NIST SP 800-53 Rev 5 | AC-6 Least Privilege | Exact sub and aud conditions, no wildcard trust |
| NIST SP 800-53 Rev 5 | CM-3 Configuration Change Control | Trust policy and provider changes go through change control |
| NIST CSF 2.0 | PR.AA-01, PR.AA-05 | Workload credentials and role trust managed and reviewed |
| MITRE ATT&CK | T1078.004 Cloud Accounts | Over-broad trust lets other workloads assume roles as valid cloud identities |
Practitioner checklist
- Decode the token locally and record
iss,aud,azp,subandexpbefore changing anything. - Confirm the IAM OIDC provider exists in the role's account for the exact issuer and lists the audience.
- Check condition key prefixes equal the issuer host and path without
https://. - Use
StringEqualsfor exact values and boundedStringLikepatterns only. - For IRSA, verify provider per cluster,
system:serviceaccount:subject, annotation, pod service account and SDK version. - For Cognito, require
:audequal to the pool ID and:amrmatching the authentication type. - Keep requested session duration within the role maximum instead of raising it.
- Alert on trust policy and OIDC provider changes for federated roles.
- Record every root cause and reject any fix that widens trust.
Standards and references
- AWS: AssumeRoleWithWebIdentity API reference
- AWS: IAM and AWS STS condition context keys
- AWS: Obtain the thumbprint for an OpenID Connect identity provider
- AWS: Amazon Cognito role trust and permissions
- AWS re:Post Knowledge Center: Troubleshoot OIDC provider and IRSA issues in Amazon EKS
- AWS: Logging IAM and AWS STS API calls with CloudTrail
- OpenID Foundation: OpenID Connect Core 1.0
Related NHI Mgmt Group resources: Multi-Cloud Workload Identity Troubleshooting Guide · AWS STS and AssumeRole Guide · GitHub Actions OIDC Errors Troubleshooting Guide · Amazon Cognito Security Guide