What Is GitHub Actions OIDC?

GitHub Actions OIDC lets a GitHub Actions workflow authenticate to AWS, Azure or GCP with a short-lived, signed OpenID Connect token instead of a stored long-lived key, and the cloud side decides which tokens to trust from the claims inside the token. Pwned Labs teaches the attacker's view of this federated trust in its Abuse OpenID Connect and GitLab for AWS Access lab, where an overly permissive OIDC role trust policy lets a pipeline assume a privileged AWS role. The whole scheme is only as strong as how narrowly that cloud trust policy is scoped.
How the Trust Model Works
The GitHub Actions OIDC flow involves three parties: GitHub (the identity provider), the cloud provider (the relying party), and the workflow requesting access. When a workflow job starts and requests an OIDC token, GitHub's token service issues a signed JWT containing claims about the workflow's context, including the repository name, branch, workflow name, environment, actor, and triggering event.
On the cloud side, an IAM trust policy or workload identity configuration specifies which GitHub-issued tokens it will accept, based on the claims in the JWT. In AWS, this is configured as an IAM OIDC identity provider with a role trust policy that filters on the sub claim. In Azure, it is a federated identity credential on an app registration or managed identity. In GCP, it is a Workload Identity Federation pool with an attribute condition.
The critical security decision is how narrowly the cloud side scopes its trust. The sub claim in the GitHub-issued JWT follows the format repo:OWNER/REPO:ref:refs/heads/BRANCH for branch-triggered workflows, or repo:OWNER/REPO:environment:ENVIRONMENT_NAME for environment-scoped workflows. The cloud trust policy must match against these claims precisely. Pwned Labs teaches how these cloud-side trust policies are read and abused across AWS, Azure and GCP in the bootcamps behind its ACRTP, MCRTP and GCRTP certifications.
Security Risks and Misconfigurations
The most dangerous misconfiguration is an overly broad subject claim filter. A trust policy that matches repo:myorg/* grants every repository in the organization the ability to assume the configured cloud role. If any repository in the organization is compromised, including public forks, abandoned projects, or repositories with lax branch protection, the attacker inherits cloud access. This is not a theoretical risk; it has been exploited in the wild. The entry point is usually a compromised repository, which Pwned Labs recreates in its free Hunt for Secrets in Git Repos lab, where git-secrets and TruffleHog recover leaked credentials from a Git repository.
Organization-level versus repository-level OIDC policies add another dimension. GitHub allows organizations to restrict which repositories can request OIDC tokens through custom claims, but many organizations leave this at the default permissive setting.
Branch protection bypass is a related attack vector. If the trust policy scopes to ref:refs/heads/main but the repository does not enforce branch protection on main, an attacker with write access to the repository can push directly to main and trigger a workflow that receives a valid OIDC token. The cloud trust policy is only as strong as the repository governance backing it.
Environment-based scoping provides the strongest protection. By configuring the trust to accept only tokens with a specific environment claim, and configuring that GitHub environment with required reviewers and deployment protection rules, organizations add a human approval gate that prevents automated exploitation even if the repository is compromised.
Real Attack Scenarios
A common attack chain begins with a compromised GitHub repository, through a leaked personal access token, a malicious pull request exploiting a workflow_run trigger, or a compromised dependency that modifies workflow files. The attacker modifies a workflow to request an OIDC token, which GitHub issues because the workflow is running in a legitimate repository. If the cloud trust policy uses a broad claim filter, the attacker exchanges this token for cloud credentials and pivots into the target's cloud environment. Pwned Labs runs this repository-to-cloud pivot hands-on in its Abuse OpenID Connect and GitLab for AWS Access lab, using CloudFox for situational awareness, then enumerating IAM and assuming a role to escalate from the access the token grants.
Another scenario involves pull request triggers. Workflows triggered by pull_request_target run in the context of the base repository (not the fork), meaning they can access OIDC tokens for that repository. If a workflow checks out and executes code from the pull request head, a pattern called "pwn request," an external attacker can inject code that exfiltrates the OIDC token.
OIDC Federation vs. Long-Lived Cloud Keys
Before OIDC, connecting a CI/CD pipeline to a cloud account usually meant storing a long-lived access key or service account key as a secret in the pipeline. Those static credentials do not expire, are easy to leak, and grant standing access to anyone who obtains them. OIDC federation replaces them with short-lived tokens minted per workflow run and scoped by trust policy, so there is no permanent secret to steal. This is a meaningful reduction in blast radius, which is exactly why AWS, Azure, and GCP all built native federation for GitHub Actions. The catch is that the security now depends on how tightly the trust policy is scoped, rather than on how well a secret is stored. Pwned Labs shows what the stored-secret problem looks like in its Plunder Azure DevOps for Cloud Credentials lab, where secrets left in pipelines and service connections hand over the wider Azure estate.
The Broader CI/CD Identity Threat
OIDC misconfiguration sits inside a larger pattern of CI/CD systems being targeted for the credentials they hold. In 2021, the Codecov bash uploader was tampered with to exfiltrate environment variables, including cloud credentials, from thousands of build pipelines. In 2023, CircleCI disclosed a breach in which stolen session tokens exposed customers' stored secrets and environment variables. Both incidents underline the same lesson: any long-lived credential sitting in a build system is a target, and short-lived, tightly scoped OIDC tokens are a direct mitigation, provided the trust policy does not hand that reduced risk straight back through an overly broad claim filter. Pwned Labs recreates the committed-credential version of this threat in its Gain Entry to GCP via GitLab Commit lab, where secrets found in a public repository open a foothold in a GCP project.
Auditing OIDC Configurations
Auditing GitHub Actions OIDC requires reviewing both sides of the trust relationship. On the GitHub side, examine all workflow files for permissions: id-token: write declarations, identify which workflows request OIDC tokens, and verify that environments with protection rules gate sensitive deployments. On the cloud side, enumerate all OIDC identity providers and their associated trust policies, check for wildcard or overly broad subject claim filters, and verify that the IAM roles associated with OIDC trust have appropriately scoped permissions.
In AWS, query IAM OIDC providers with aws iam list-open-id-connect-providers and inspect each provider's associated role trust policies for the token.actions.githubusercontent.com audience. In Azure, review federated identity credentials on app registrations using Microsoft Graph. In GCP, examine Workload Identity Federation pools and their attribute conditions. Pwned Labs builds the cloud-side IAM and trust-policy enumeration this audit relies on in its hands-on AWS labs and the Amazon Cloud Attack and Defense bootcamp (the ACRTP certification).
Hardening GitHub Actions OIDC Trust
A well-scoped OIDC configuration follows a few concrete rules. Scope the subject claim to an exact repository and, where possible, a specific branch or environment, never a wildcard like repo:org/*. Prefer environment-based scoping and configure that GitHub environment with required reviewers so a human approval gate stands between a compromised repository and cloud access. Restrict at the organization level which repositories may request OIDC tokens rather than leaving the permissive default. Grant the assumed cloud role only the permissions the workflow genuinely needs, so even a valid token cannot reach beyond its purpose. Finally, enforce branch protection on any branch named in a trust policy, because the policy is only as strong as the repository governance behind it. Pwned Labs has practitioners build these scoping and branch-protection rules as the defensive half of its cloud bootcamps, right after exploiting a trust policy that left them out.
Related Labs
Pwned Labs runs the repository-to-cloud attack paths behind CI/CD identity federation as hands-on labs in live cloud environments. The first lab below is free.
- Hunt for Secrets in Git Repos (Free, Beginner): use git-secrets and TruffleHog to find leaked credentials in a Git repository, the usual first step in a repository compromise.
- Abuse OpenID Connect and GitLab for AWS Access (Premium, Beginner): exploit an overly permissive OpenID Connect role trust policy to move from GitLab into an AWS account, then enumerate IAM and escalate.
- Gain Entry to GCP via GitLab Commit (Premium, Beginner): recover secrets committed to a public GitLab repository and use them to get a foothold in a GCP project and move between its services.
- Plunder Azure DevOps for Cloud Credentials (Premium, Beginner): hunt Azure DevOps repositories, pipelines and service connections for secrets, then abuse a service principal to pivot into the Azure estate.
Learn OIDC Trust Analysis with Pwned Labs
Pwned Labs teaches CI/CD identity federation attack and defense hands-on. In its Abuse OpenID Connect and GitLab for AWS Access lab, practitioners exploit an overly permissive OIDC role trust policy to pivot from a Git platform into an AWS account, enumerate IAM with CloudFox, and escalate, then see how restricting role assumption to a specific project, branch or tag would have prevented it. Explore the CI/CD and cloud labs at pwnedlabs.io/explore.
Frequently Asked Questions
What is GitHub Actions OIDC?
A mechanism that lets a GitHub Actions workflow authenticate to a cloud provider using a short-lived, signed OIDC token instead of a stored long-lived key, with the cloud side deciding which tokens to trust based on claims in the token.
Why is OIDC more secure than storing keys?
Because there is no permanent secret to leak. Tokens are minted per run and expire quickly, and access is controlled by a trust policy rather than by how well a static credential is protected. Pwned Labs shows where a leaked static credential leads in its free Hunt for Secrets in Git Repos lab.
What is the most dangerous OIDC misconfiguration?
An overly broad subject claim filter, such as a wildcard covering every repository in an organization. If any of those repositories is compromised, the attacker can assume the configured cloud role.
What is a pwn request?
An attack where a workflow triggered by pull_request_target runs in the base repository's context and checks out untrusted pull request code, letting an external attacker inject code that can exfiltrate the OIDC token.
How do I audit OIDC trust?
Review both sides: workflow files for id-token write permissions on the GitHub side, and every cloud OIDC identity provider and its trust policies for wildcard or overly broad subject claim filters on the cloud side. Pwned Labs teaches the cloud-side IAM and trust-policy enumeration behind this audit in its hands-on AWS labs.
About Pwned Labs
Pwned Labs is a hands-on cloud and AI offensive security training platform. It runs real-world attack labs and bootcamps for AWS, Azure, GCP, Kubernetes and AI systems, including the ACRTP, MCRTP, GCRTP, KRTP and AISRTP certifications. Free labs are at pwnedlabs.io/explore.
Learn this hands-on in a bootcamp
What practitioners say.
Caleb Havens
Red Team Operator & Social Engineer, NetSPI
"I’ve attended two training sessions delivered by Pwned Labs: one focused on Microsoft cloud environments and the other on AWS. Both sessions delivered highly relevant content in a clear, approachable manner and were paired with an excellent hands-on lab environment that reinforced key concepts and skills for attacking and defending cloud infrastructures. The training was immediately applicable to real-world work, including Red Team Operations, Social Engineering engagements, Purple Team exercises, and Cloud Penetration Tests. The techniques and insights gained continue to be referenced regularly and have proven invaluable in live operations, helping our customers identify vulnerabilities and strengthen their cloud defenses."
Sebas Guerrero
Senior Security Consultant, Bishop Fox
"The AWS, Azure, and GCP bootcamps helped me get up to speed quickly on how real cloud environments are built and where they tend to break from a security standpoint. They were perfectly structured, with real-world examples that gave me rapid insight into how things can go wrong and how to prevent those issues from happening in practice. I’m now able to run cloud pentests more confidently and quickly spot meaningful vulnerabilities in customers’ cloud infrastructure.”
Dani Schoeffmann
Security Consultant, Pen Test Partners
"I found the Pwned Labs bootcamps well structured and strongly focused on practical application, with clear background on how and why cloud services behave the way they do and how common attack paths become possible. The team demonstrates both sides by walking through attacks and the corresponding defenses, backed by hands-on labs that build confidence using built-in and third-party tools to identify and block threats. The red-team labs are hands-on and challenge-driven, with clear walkthroughs that explain each step and the underlying logic. I’ve seen several of these techniques in real engagements, and the bootcamp helped me develop a repeatable methodology for cloud breach assessments and deliver more tailored mitigation recommendations."
Matt Pardo
Senior Application Security Engineer, Fortune 500 company
"I’ve worked in security for more than 15 years, and every step up came from taking courses and putting the lessons into practice. I’ve attended many trainings over the years, and Pwned Labs’ bootcamps and labs are among the best I’ve experienced. When you factor in how affordable they are, they easily sit at the top of my list. As a highly technical person, I get the most value from structured, hands-on education where theory is immediately reinforced through labs. Having lifetime access to recordings, materials, and training environments means you can repeat the practice as often as needed, which is invaluable. If you’re interested in getting into cloud security, sign up for Pwned Labs.”
Steven Mai
Senior Penetration Tester, Centene
“Although my background was mainly web and network penetration testing, the ACRTP and MCRTP bootcamps gave me a solid foundation in AWS and Azure offensive security. I’m now able to take part in cloud penetration testing engagements and have more informed security discussions with my team.”
