The attacker pushes a workflow or buildspec change from a branch, fork or repository that a loose OpenID Connect (OIDC) trust condition accepts, and a pipeline AWS trusts runs it. The run calls AssumeRoleWithWebIdentity and uses the deploy role to change infrastructure or push artifacts. Pin the role's trust policy and revoke its sessions first, then stop the pipeline.
Look here
Log
Search for
CloudTrail, sts.amazonaws.com
Role sessions started by pipelines. The subjectFromWebIdentityToken response field names the repository and ref. Also read userIdentity.identityProvider, requestParameters.roleArn and sourceIPAddress. Global endpoint calls land in us-east-1, regional endpoint calls in their Region: aws cloudtrail lookup-events --region us-east-1 --lookup-attributes AttributeKey=EventName,AttributeValue=AssumeRoleWithWebIdentity
CloudTrail, role sessions
Later calls by the same session: the ASIA key from the credentials.accessKeyId response field, in events that show AssumedRole with sessionContext.webIdFederationData
CloudTrail, iam.amazonaws.com
Changes to identity providers, trust and role permissions: CreateOpenIDConnectProvider, AddClientIDToOpenIDConnectProvider, UpdateOpenIDConnectProviderThumbprint, UpdateAssumeRolePolicy, CreateRole, AttachRolePolicy, PutRolePolicy
IAM trust review
Roles that trust an OIDC provider. List providers with aws iam list-open-id-connect-providers, then find the roles: aws iam list-roles --query "Roles[?contains(to_string(AssumeRolePolicyDocument), 'oidc-provider')].RoleName"
CloudTrail, codebuild.amazonaws.com
Build overrides and webhook changes: StartBuild with buildspecOverride or environmentVariablesOverride, UpdateProject, CreateWebhook, UpdateWebhook, ImportSourceCredentials
CodeBuild builds
Builds of a project: aws codebuild list-builds-for-project --project-name <project>
CodeBuild build detail
Initiator, source version and log location of a build: aws codebuild batch-get-builds --ids <build-id>
CodePipeline and CodeDeploy
Pipeline changes, approvals and deployments: UpdatePipeline, StartPipelineExecution, PutApprovalResult, CreateDeployment, RegisterApplicationRevision. List executions: aws codepipeline list-pipeline-executions --pipeline-name <pipeline>
Contain
#
Item
1
Export the trust policies, CloudTrail events and build logs before any change. See Evidence
2
Pin the trust policy to one repository and branch. The file has StringEquals on token.actions.githubusercontent.com:aud = sts.amazonaws.com and :sub = the repository and branch. For GitLab use gitlab.com:sub: aws iam update-assume-role-policy --role-name <role> --policy-document file://trust.json
3
Revoke sessions already issued. The policy denies * when aws:TokenIssueTime is before now: aws iam put-role-policy --role-name <role> --policy-name AWSRevokeOlderSessions --policy-document file://revoke.json
Remove the push trigger destructive: aws codebuild delete-webhook --project-name <project>
8
Stop a deployment and roll it back: aws deploy stop-deployment --deployment-id <id> --auto-rollback-enabled
9
Delete an OIDC provider nobody approved destructive, breaks every role that trusts it: aws iam delete-open-id-connect-provider --open-id-connect-provider-arn <arn>
Clear every finding the validation returns for OIDC trust, such as MISSING_GITHUB_REPO_CONDITION_KEY or this one: MISSING_CONDITION_KEY_FOR_OIDC_PRINCIPAL
3
Give pull request workflows a read-only role, and limit the deploy role to a protected branch or environment
4
Harden CodeBuild webhooks: ACTOR_ACCOUNT_ID filters, a FILE_PATH filter that excludes the buildspec, an inline or S3 buildspec, and separate test and deploy projects
5
Rebuild and redeploy from a known-good commit, and check images pushed in the window with the ECR images playbook and Supply chain
6
Rotate secrets the roles and build environments could read, with the Secrets Manager and SSM playbook
IAM requires a sub condition for GitHub, GitLab and other shared OIDC providers only on CreateRole and UpdateAssumeRolePolicy. Existing trust policies are not re-evaluated, and a value such as repo:<org>/* passes and trusts every repository in the organization.
Credentials issued before containment stay valid until they expire. The aws:TokenIssueTime deny ends them at once.
CodeBuild hides access key IDs and Parameter Store and Secrets Manager values in its logs. Plaintext environment variables stay in the project definition, so treat them as exposed.
AWS documentation: IAM creating a role for OIDC federation, identity-provider controls for shared OIDC providers, OIDC condition keys, CloudTrail integration for IAM and STS, policy validation checks; CloudTrail userIdentity element; CodeBuild webhooks, CloudTrail log entries and start-build; CLI reference for accessanalyzer, codebuild, codepipeline and deploy. Checked September 2026.