AWS Builder Center

Scoped or Spoofed: What a Missing OIDC Condition Really Costs You in AWS

This article explores how overly permissive GitHub Actions OIDC trust policies can expose AWS environments to unauthorized access, privilege escalation, and cross-account persistence. Through a hands-on attack scenario, it explains the attack chain and practical steps to strengthen IAM trust policies, enforce least privilege, and eliminate unauthorized access paths.

From the Stage to This Write-up

On November 7, 2026, I had the opportunity to speak at AWS Community Day Bandung 2026, held at Auditorium SBM ITB, where I presented this exact topic as a technical session.


In this session, I explored the security implications of overly permissive GitHub Actions OIDC trust policies, using the UNC6426 incident as a starting point. I also demonstrated a practical attack scenario in an AWS lab environment, showing how an unintended GitHub repository could assume an AWS IAM role and how excessive deployment permissions could lead to privilege escalation and a cross-account backdoor.

Introduction

GitHub Actions has become a common way to automate deployments to AWS. Instead of storing long-lived AWS access keys as GitHub secrets, teams can use OpenID Connect (OIDC) to let GitHub Actions request temporary AWS credentials. This is a significant security improvement. Credentials are short-lived, and there is no need to maintain static access keys in the repository.
But there is an important question:
How do you ensure that only the intended GitHub repository can assume your AWS IAM role?
Configuring an OIDC provider is only part of the solution. The trust policy must also validate the identity of the workload requesting access.
If the  sub  condition is too broad, a workflow from an unintended repository may be able to assume the same deployment role. And if that deployment role has excessive permissions, the consequences can extend far beyond the CI/CD pipeline.

The UNC6426 Incident: When CI/CD Becomes an Entry Point

In August 2025, attackers tracked as  UNC6426  reportedly stole a developer’s GitHub token, pivoted through CI/CD, and gained administrative access to an AWS environment. The incident highlighted how an overly permissive deployment role can turn a compromised developer credential into a serious cloud security breach.


 Datadog Security Labs  identified more than 500 publicly exposed IAM role ARNs across more than 275 AWS accounts associated with a related but distinct GitHub Actions OIDC trust-policy weakness.
These findings highlight a broader problem: a deployment role that trusts too many GitHub identities can become an entry point for unauthorized access.

The Misconception

Most teams treat GitHub-to-AWS OIDC as a solved problem: no more long-lived access keys sitting in repository secrets, just short-lived tokens exchanged through a trust relationship. That part is true, and it’s a real improvement over static credentials.


What gets missed is that OIDC only replaces how a workflow authenticates. It says nothing about which workflow should be trusted to do so. That’s the job of the trust policy’s  sub  condition — and when that condition is missing, or scoped too broadly, the “keyless” authentication story stops being a security improvement and starts being a liability with better marketing.

The Misconfiguration: Trusting an Entire Organization

Consider this simplified trust-policy condition:
{
"Condition": {
"StringEquals": {
"token.actions.githubusercontent.com:aud": "sts.amazonaws.com"
},
"StringLike": {
"token.actions.githubusercontent.com:sub": "repo:my-org/*"
}
}
}
At first glance, this configuration may look reasonable.
The audience is restricted to AWS STS, and the subject is restricted to a specific GitHub organization.
However, the wildcard allows repositories across that organization to match the subject condition.
That means the trust policy does not distinguish between the intended deployment repository and another repository within the same organization.
Imagine two repositories:
  • legit-repo: The intended repository responsible for deploying infrastructure.
  • spoof-repo: Another repository that should not have access to the deployment role.
If both repositories satisfy the wildcard subject condition, a workflow from spoof-repo may be able to request the same AWS role. The problem is not that GitHub OIDC is inherently insecure. The problem is that the AWS trust policy does not enforce a sufficiently narrow identity boundary. A valid OIDC token does not automatically mean it belongs to an authorized repository.

The Attack Chain


The path from a spoofed repository to AWS admin runs through five steps:
  1. Spoof repo — a GitHub Actions workflow in a repository that was never meant to have this access.
  1. OIDC token — GitHub issues a valid token, because the trust policy’s condition doesn’t actually check which repository is asking.
  1. Deploy role — the spoofed workflow assumes the role meant for a completely different, legitimate repository.
  1. CloudFormation — the deploy role has permission to create a new stack, including IAM resources.
  1. Escalated admin role — The stack creates a new role, attaches  AdministratorAccess , and configures its trust policy to allow an identity from the attacker's AWS account to assume it.
This attack scenario does not require stealing AWS access keys. It exploits an overly broad OIDC trust policy and excessive permissions in the deployment role. The attacker still needs the ability to execute a workflow in a repository that matches the overly broad trust condition.

Inside the Payload

The CloudFormation template uses an IAM role, an attached managed policy, and a parameter to establish this access:
  •  AWS::IAM::Role  — creates a new IAM role in the victim's AWS account.
  •  AdministratorAccess  — grants the role broad administrative permissions.
  •  AttackerAccountId  — a CloudFormation parameter used to add the attacker's AWS account to the role's trust policy.
The attacker must also use an identity in that account with permission to call  sts:AssumeRole .

You Fixed the Front Door. The Attacker Still Has a Key.

Fixing the OIDC trust policy blocks the spoofed GitHub workflow, but it does not remove the IAM role created during the attack.
If that role still trusts the attacker’s AWS account, the attacker can continue assuming it directly.
Fixing the entry point is not enough. Remove any unauthorized resources and trust relationships created during the attack.

The Fix: Exact Subject Matching

Restrict the OIDC trust policy to the intended repository and branch.
Before — Wildcard ( StringLike ):
repo:org/*
Allows multiple repositories within the organization.
After — Exact Match ( StringEquals ):
repo:org@id/repo@id:ref:refs/heads/main
Allows only the specified repository and branch, assuming this matches the configured GitHub subject format. Always validate the actual  sub  claim issued by GitHub Actions before configuring the trust policy.
Trust the exact workload, not the entire organization.

Defense-in-Depth

Securing OIDC is only one layer. The deployment role must also follow least privilege:
  • If CloudFormation uses a service role, review its permissions separately from the GitHub Actions deployment role.
  • Grant only the permissions needed for deployment, such as  s3:CreateBucket .
  • Treat CI/CD identities as potentially compromised.
A narrowly scoped OIDC policy means little if the deployment role still has excessive permissions.

Verification: Does the Remediation Work?

After applying the security controls, I verified three scenarios in the lab:
  • Spoofed repository: The workflow can no longer assume the deployment role because its repository does not match the expected  sub  condition.
  • Cross-account access: The attacker’s AWS identity receives  AccessDenied  after the unauthorized role or its trust relationship is removed.
  • Legitimate deployment: The intended GitHub repository can still deploy the expected S3 resource.
The goal is simple: block unauthorized access without breaking legitimate deployments. A successful remediation must address both the original entry point and any persistence established during the attack.

Conclusion

GitHub Actions OIDC provides a better alternative to long-lived AWS credentials, but its security depends on how IAM trust policies are configured.
An overly broad sub condition can allow unintended repositories to assume deployment roles. Combined with excessive permissions, this can lead to privilege escalation and additional access paths.
Audit your OIDC trust policies, apply least privilege to deployment identities, and make sure your remediation removes any unauthorized access established during an attack.
Trust the right workload. Limit its permissions. Verify every access path.
Any opinions in this article are those of the individual author and may not reflect the opinions of AWS.
Enjoyed reading this content? Let the author know!

Your likes, comments, shares, and saves help creators reach more builders.

Loading recommendations

Loading article