An audit finds an IAM role whose GitHub OIDC trust policy checks only `token.actions.githubusercontent.com:aud = sts.amazonaws.com`
AdvancedTroubleshootingCloud identity: IRSA, Workload Identity and CI OIDC
Answer
Likely causes → Someone copied a minimal example. With no sub condition, any GitHub Actions workflow in any repository in the world can assume the role, because every workflow can get a token with that audience from the same issuer.
Diagnose →
aws iam get-role --role-name gha-deploy --query 'Role.AssumeRolePolicyDocument.Statement[].Condition'
# CloudTrail: check who actually assumed it
aws cloudtrail lookup-events --lookup-attributes AttributeKey=EventName,AttributeValue=AssumeRoleWithWebIdentity \
--query 'Events[].CloudTrailEvent' --output text | jq -r '.userIdentity.userName // .requestParameters.roleSessionName'
Fix → Add a strict sub condition right away (StringEquals on repo:acme/api:environment:prod). Review CloudTrail for the sub values that have used the role, and treat unknown ones as an incident.
Prevent → An IAM Access Analyzer custom policy check or a Checkov/OPA rule in CI that rejects GitHub OIDC trust policies without a sub condition, or with repo:* wildcards.
More on Cloud identity: IRSA, Workload Identity and CI OIDC
A pod configured for IRSA runs `aws sts get-caller-identity` and gets the node role (`eks-node-group-role`) instead of its own roleBeginner`An error occurred (AccessDenied) when calling the AssumeRoleWithWebIdentity operation: Not authorized to perform sts:AssumeRoleWithWebIdentity` from an IRSA podIntermediate`InvalidIdentityToken: No OpenIDConnect provider found in your account for https://oidc.eks.ap-south-1.amazonaws.com/id/ABC123`BeginnerIRSA env vars are present in the pod, but one legacy service still uses the node roleIntermediatePods without IRSA can still call AWS with the node's permissions through `169.254.169.254`IntermediateWith EKS Pod Identity, the pod gets `Unable to locate credentials` even though a pod identity association existsIntermediate