Join our Newsletter — 33% off our NHI Course
Home› Guides› AssumeRoleWithWebIdentity Errors: Causes and Fixes for IRSA, OIDC…
Guide Identity & Access Management (IAM)

AssumeRoleWithWebIdentity Errors: Causes and Fixes for IRSA, OIDC and Cognito

PDF for newsletter subscribers · free to read online

← All guides
By NHI Mgmt Group, under the editorial direction of Lalit Choda Updated 27 November 2026 13 min read
On this page

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 example token.actions.githubusercontent.com:sub. A typo in the prefix silently fails the condition.
  • Cognito has its own rules. Trust policies for cognito-identity.amazonaws.com must include an aud condition naming the identity pool, and the enhanced flow requires the role to be in the same account.
  • Never fix by widening. Replacing a sub condition with a wildcard or removing the aud check 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.

CheckpointWhat STS checksTypical errorWhere to look
1. ProviderAn IAM OIDC provider exists for the token's iss, its client ID list contains the token's audience, and the issuer's TLS certificate verifiesInvalidIdentityToken (provider not found, incorrect audience, thumbprint mismatch), IDPCommunicationErrorIAM > Identity providers
2. TokenSignature (RS256/384/512 or ES256/384/512), expiry, length 4 to 20,000 charactersExpiredToken, InvalidIdentityToken, IDPRejectedClaimThe token payload; clock on the caller
3. Role trustThe role's trust policy allows sts:AssumeRoleWithWebIdentity for the provider ARN, and every condition matchesAccessDenied: Not authorized to perform sts:AssumeRoleWithWebIdentityRole > Trust relationships
4. Session requestDurationSeconds, RoleSessionName, session policies and tags, STS Region statusMalformedPolicyDocument, PackedPolicyTooLarge, RegionDisabledCalling 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 messageHTTPMost likely causeCheckFix
InvalidIdentityToken: No OpenIDConnect provider found in your account400No 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-providersCreate the provider for that exact issuer in the account that owns the role
InvalidIdentityToken: Incorrect token audience400The token's audience is not in the provider's ClientIDListDecode the token's aud; read the provider's client IDsAdd 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 thumbprint400AWS fell back to thumbprint verification and the stored thumbprint is wrong or staleCheck 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)400Bad signature, unsupported algorithm, signature mismatch from a mis-ordered certificate chain, malformed tokenDecode header alg and kid; confirm the key is in the issuer's JWKSFix the issuer's signing keys or chain; request a fresh token
ExpiredToken400Token cached past its exp, or caller clock skewCompare exp with the caller's UTC timeRequest the token immediately before the call; sync time; for IRSA, make sure the SDK re-reads the token file
IDPRejectedClaim403The identity provider reported authentication failed; for this API it can also mean the claim expired or was revokedCheck the issuer's own logs and token statusIssue a new token; fix the issuer-side rejection
IDPCommunicationError400STS could not reach the issuer to verify the token; often transientFetch the issuer's discovery document and JWKS from the internetRetry with back-off; make the issuer's discovery and JWKS endpoints publicly reachable
AccessDenied: Not authorized to perform sts:AssumeRoleWithWebIdentity403Trust policy principal, action or a condition does not match the tokenCompare each trust condition value with the decoded claims, character by characterCorrect the condition to the exact claim value; do not wildcard it
MalformedPolicyDocument400Invalid inline session policy passed in the callRead the error detailFix the JSON; session policies (inline plus managed) are limited to 2,048 characters combined
PackedPolicyTooLarge400Session policies and session tags made the session token too largeCount session tags (up to 50) and policy size; monitor SessionTokenUtilizationTrim tags or session policies
RegionDisabled403STS is not activated in the requested Region for the accountAccount settings > STS Regional endpointsActivate the Region or call an enabled Regional endpoint
Duration exceeds the role's maximumVaries by SDKDurationSeconds 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 settingRequest 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) with sts.amazonaws.com in 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:sub must equal system:serviceaccount:namespace:service-account and ...:aud must equal sts.amazonaws.com. A namespace or service account name typo returns AccessDenied, not a clearer message.
  • Annotation: the service account needs eks.amazonaws.com/role-arn naming the role, and the pod's serviceAccountName must point at that service account.
  • Environment: if AWS_ROLE_ARN and AWS_WEB_IDENTITY_TOKEN_FILE are 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 claimUsable after the session startsTypical mistake
:audazp, or aud if azp is not setYesExpecting :aud to match aud when the issuer sets azp
:oaudaudNo (trust policy only)Using it in a permissions policy
:subsubYesMatching a branch format when the job uses an environment, or the reverse
:amramrYesRarely set by CI issuers
:emailemailNo (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_ref and :environment. If a sub condition used to work and now fails, check whether the repository emits GitHub's immutable subject format. The GitHub-side failures (missing id-token: write, wrong audience in the action) are covered in the GitHub Actions OIDC Errors Troubleshooting Guide.
  • StringEquals versus StringLike: a sub value containing * under StringEquals matches only a literal asterisk, so the trust fails; under StringLike it matches anything. Use StringLike only 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 IDPCommunicationError or InvalidIdentityToken; 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" with sts:AssumeRoleWithWebIdentity.
  • aud is mandatory: cognito-identity.amazonaws.com:aud must 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:amr with authenticated or unauthenticated (usually under ForAnyValue: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:sub is 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:SourceIp in 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

  1. Capture the full error. Code, message and the role ARN requested. Note the Region and STS endpoint used.
  2. Decode the token payload (never paste a live token into an online decoder; decode locally) and record iss, aud, azp, sub, exp.
  3. Match the provider. Confirm an IAM OIDC provider exists in the role's account for exactly that issuer and lists the audience.
  4. Match the trust policy. Check principal ARN, action and each condition against the claims. Look for prefix typos and StringEquals with wildcards.
  5. Check the session request. Duration against the role maximum, session name (2 to 64 characters, pattern [\w+=,.@-]*), session policies and tags.
  6. Read CloudTrail. Successful calls appear as eventSource sts.amazonaws.com, eventName AssumeRoleWithWebIdentity, userIdentity.type WebIdentityUser, with subjectFromWebIdentityToken and audience in the response. CloudTrail logs non-authenticated web identity requests, but requests that are not sufficiently valid may not be logged.
  7. 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 UpdateAssumeRolePolicy for federated roles, especially edits that remove an aud condition or introduce StringLike with a wildcard.
  • Provider changes: alert on CreateOpenIDConnectProvider, AddClientIDToOpenIDConnectProvider and UpdateOpenIDConnectProviderThumbprint outside change control.
  • Unexpected subjects: baseline subjectFromWebIdentityToken per role and alert on a new value.

Metrics

  • Federated roles whose trust policy lacks an aud condition (target zero).
  • Federated roles using StringLike with an unbounded sub pattern (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/main with repo:org/* or * to clear AccessDenied, giving every repository (or every repository on the platform) the role.
  • Dropping the audience check: removing :aud to 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

FrameworkReferenceRelevance
NIST SP 800-53 Rev 5IA-9 Service Identification and AuthenticationWorkloads authenticate with federated tokens bound to a provider
NIST SP 800-53 Rev 5IA-5 Authenticator ManagementShort-lived tokens instead of stored access keys
NIST SP 800-53 Rev 5AC-6 Least PrivilegeExact sub and aud conditions, no wildcard trust
NIST SP 800-53 Rev 5CM-3 Configuration Change ControlTrust policy and provider changes go through change control
NIST CSF 2.0PR.AA-01, PR.AA-05Workload credentials and role trust managed and reviewed
MITRE ATT&CKT1078.004 Cloud AccountsOver-broad trust lets other workloads assume roles as valid cloud identities

Practitioner checklist

  • Decode the token locally and record iss, aud, azp, sub and exp before 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 StringEquals for exact values and bounded StringLike patterns only.
  • For IRSA, verify provider per cluster, system:serviceaccount: subject, annotation, pod service account and SDK version.
  • For Cognito, require :aud equal to the pool ID and :amr matching 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

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

PDF for subscribers

Take this guide with you

Every section, table and checklist in one PDF, with links to the sources and related guides. Subscribe to our weekly NHI & AI Identity Journal and we’ll email you a download link.

Free weekly newsletter

Subscribe to the NHI & AI Identity Journal

The latest on NHI and Agentic AI security – articles, research, breaches, news and events every week.

Bonus 33% off our NHI Course when you subscribe.

PDF Downloads for Newsletter Subscribers

Get the guide

Enter your details and we’ll email you a download link.

The full guide is free to read online. The PDF is a thank you for subscribing.

Fill in all fields marked * and tick both boxes to continue.