PIVTR-D
RAWS playbook · Pipelines and supply chain

CI/CD pipeline or OIDC trust abused

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

LogSearch for
CloudTrail, sts.amazonaws.comRole 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 sessionsLater 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.comChanges to identity providers, trust and role permissions: CreateOpenIDConnectProvider, AddClientIDToOpenIDConnectProvider, UpdateOpenIDConnectProviderThumbprint, UpdateAssumeRolePolicy, CreateRole, AttachRolePolicy, PutRolePolicy
IAM trust reviewRoles 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.comBuild overrides and webhook changes: StartBuild with buildspecOverride or environmentVariablesOverride, UpdateProject, CreateWebhook, UpdateWebhook, ImportSourceCredentials
CodeBuild buildsBuilds of a project: aws codebuild list-builds-for-project --project-name <project>
CodeBuild build detailInitiator, source version and log location of a build: aws codebuild batch-get-builds --ids <build-id>
CodePipeline and CodeDeployPipeline changes, approvals and deployments: UpdatePipeline, StartPipelineExecution, PutApprovalResult, CreateDeployment, RegisterApplicationRevision. List executions: aws codepipeline list-pipeline-executions --pipeline-name <pipeline>

Contain

#Item
1Export the trust policies, CloudTrail events and build logs before any change. See Evidence
2Pin 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
3Revoke 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
4Stop the running pipeline execution: aws codepipeline stop-pipeline-execution --pipeline-name <pipeline> --pipeline-execution-id <id> --abandon
5Block the deploy stage: aws codepipeline disable-stage-transition --pipeline-name <pipeline> --stage-name <stage> --transition-type Inbound --reason "IR block"
6Stop running builds: aws codebuild stop-build --id <build-id>
7Remove the push trigger destructive: aws codebuild delete-webhook --project-name <project>
8Stop a deployment and roll it back: aws deploy stop-deployment --deployment-id <id> --auto-rollback-enabled
9Delete 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>

Eradicate and recover

#Item
1Validate every federated trust policy: aws accessanalyzer validate-policy --policy-type RESOURCE_POLICY --validate-policy-resource-type AWS::IAM::AssumeRolePolicyDocument --policy-document file://trust.json
2Clear every finding the validation returns for OIDC trust, such as MISSING_GITHUB_REPO_CONDITION_KEY or this one: MISSING_CONDITION_KEY_FOR_OIDC_PRINCIPAL
3Give pull request workflows a read-only role, and limit the deploy role to a protected branch or environment
4Harden 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
5Rebuild and redeploy from a known-good commit, and check images pushed in the window with the ECR images playbook and Supply chain
6Rotate secrets the roles and build environments could read, with the Secrets Manager and SSM playbook
7Remove roles, providers and policies the attacker added, with the roles, keys, trust policies playbook
Watch out
  • 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.

Adapts material from Dynamic Incident Response: A Framework for Security Teams by Joshua Wright, © 2026 The Escal Institute of Advanced Technologies, Inc. d/b/a SANS Institute, licensed under CC BY 4.0. Figures reproduced under that license. Changes were made. Not published by, endorsed by, or affiliated with the SANS Institute.