
š Your CI/CD Pipeline Could Be a Security Risk. Here's How to Fix It with AWS OIDC
Automated deployments save developers time, but what happens when your GitHub Actions workflow has access to your AWS account? Discover how OpenID Connect helps eliminate long-lived credentials and strengthen cloud security.
Imagine this.
You've just pushed a new feature to GitHub. Your GitHub Actions workflow starts automatically, builds your application, and deploys the latest version to AWS.
No manual uploads. No repetitive commands. Everything happens automatically.
But there's an important question hiding behind that convenience:
How does GitHub prove to AWS that it is allowed to access your cloud resources?
One common solution is storing AWS Access Keys and Secret Access Keys inside GitHub Secrets.
It works, but there's a catch.
These credentials can remain valid for extended periods. If they're accidentally exposed, improperly managed, or stolen, an attacker could potentially use them to access your AWS account.
Your deployment pipeline has effectively become another place where sensitive credentials must be protected.
Fortunately, AWS and GitHub support a more secure authentication approach: OpenID Connect (OIDC).
Let's explore why it matters.
1. The Hidden Problem with Permanent Credentials
Think about how many automated processes interact with your cloud infrastructure.
Your application might deploy every time code is merged. A testing workflow might upload reports to S3. Another workflow might update infrastructure.
If every workflow depends on permanent AWS credentials, you're increasing the number of places where those credentials must be secured.
Consider the risks:
- Credentials can accidentally appear in logs or configuration files.
- Keys may remain active longer than necessary.
- Rotation introduces additional maintenance.
- Compromised credentials can provide access beyond the original deployment task if permissions are too broad.
The bigger problem isn't automation itself.
It's giving automated processes permanent credentials when temporary access would be sufficient.
2. Meet OpenID Connect: Authentication Without Permanent AWS Keys
OpenID Connect is an identity layer built on OAuth 2.0.
In the GitHub Actions and AWS integration, OIDC allows GitHub to prove the identity of a workflow to AWS without requiring developers to store permanent AWS access keys in GitHub Secrets.
Instead, the workflow requests an identity token from GitHub.
AWS then verifies that token and determines whether the workflow is trusted to assume a particular IAM role.
If the conditions are satisfied, AWS Security Token Service (STS) issues temporary security credentials.
These credentials allow the workflow to perform the operations permitted by the IAM role.
When the temporary credentials expire, they can no longer be used.
That's a significant improvement over relying on long-lived access keys.
3. What Actually Happens Behind the Scenes?
Let's follow a deployment from start to finish.
Step 1: A workflow starts
A developer pushes code to an authorized GitHub repository, triggering a GitHub Actions workflow.
Step 2: GitHub generates an identity token
The workflow requests an OIDC token containing identity claims that describe the workflow's context.
These claims can include information about the repository, branch, and GitHub environment.
Step 3: AWS verifies the identity
AWS uses its configured GitHub OIDC identity provider and the IAM role's trust policy to evaluate whether the token comes from an authorized source.
Step 4: STS issues temporary credentials
If the token satisfies the trust policy, AWS Security Token Service allows the workflow to assume the IAM role and obtain temporary credentials.
Step 5: The deployment begins
The workflow uses those temporary credentials to interact with permitted AWS services.
The key difference?
GitHub doesn't need to hold permanent AWS access keys to authenticate the workflow.
4. Putting It Into Practice
Understanding the concept is useful, but let's look at what the implementation involves.
First, configure GitHub as an OIDC identity provider in AWS IAM.
Next, create an IAM role with a trust policy that restricts which GitHub repository, branch, or environment is allowed to assume it.
Then configure your GitHub Actions workflow.
Here's a simplified example:
name: Deploy to AWS
on: push: branches: - main
permissions: id-token: write contents: read
jobs: deploy: runs-on: ubuntu-latest
steps: - name: Checkout repository uses: actions/checkout@v4
- name: Configure AWS credentials uses: aws-actions/configure-aws-credentials@v4 with: role-to-assume: arn:aws:iam::YOUR_ACCOUNT_ID:role/GitHubActionsRole aws-region: ap-south-1Let's understand two important permissions.
Ā
id-token: writeĀ allows the workflow to request an OIDC identity token.Ā
contents: readĀ allows the workflow to read repository contents.The AWS credentials action exchanges the GitHub-issued OIDC token for temporary AWS credentials by assuming the configured IAM role.
Notice what's missing?
There are no AWS Access Keys or Secret Access Keys stored in the workflow configuration.
For production deployments, pin third-party actions to verified commit SHAs rather than relying solely on mutable version tags.
5. The Trust Policy: Where Security Gets Serious
Removing permanent credentials is a great start, but it doesn't mean every GitHub workflow should automatically receive AWS access.
This is where IAM trust policies become critical.
An IAM role trust policy defines which identities are allowed to assume that role.
For GitHub Actions, you should restrict access to the intended repository and deployment context.
For example, you might allow only:
Ā
repo:your-organization/your-repository:ref:refs/heads/mainĀ This is an example of a GitHub subject claim that can be used in a trust policy.
Why does this matter?
Without appropriate restrictions, an incorrectly configured trust policy could allow workflows from unintended repositories or branches to obtain AWS credentials.
Your goal should be to establish trust only where it is necessary.
6. OIDC Is Not a Substitute for Good Security Practices
Even with OIDC configured correctly, your CI/CD pipeline still needs additional security controls.
Here are some practices worth adopting:
Least privilege: Give the IAM role only the permissions required for its deployment tasks.
Restrict trusted repositories: Avoid allowing every repository in your organization to assume the same deployment role.
Protect deployment branches: Use GitHub branch protection and environment approval rules where appropriate.
Review third-party actions: Only use trusted actions, and pin them to verified commit SHAs.
Protect sensitive information: Never print tokens or credentials in workflow logs.
Separate environments: Consider using different IAM roles and permissions for development, testing, and production.
Remember, temporary credentials can still cause serious damage if they're issued to an untrusted workflow with excessive permissions.
7. The Bigger Picture: Secure Automation Is Better Automation
Modern development depends heavily on automation.
GitHub Actions, AWS services, and infrastructure-as-code tools allow developers to build and deploy applications faster than ever.
But every automated connection introduces an identity and access management decision.
Who is requesting access?
What resources can they access?
How long should that access remain valid?
And under what conditions should access be granted?
OIDC helps answer these questions by replacing the need for stored, long-lived AWS credentials with an identity-based authentication process.
It doesn't eliminate every security risk, but it gives developers a much stronger foundation for building secure deployment pipelines.
Final Thoughts š”
A successful CI/CD pipeline shouldn't just deliver code quickly. It should also protect the infrastructure receiving that code.
As developers, we should stop treating security as something that happens after deployment automation is complete.
Security belongs in the workflow from the beginning.
So the next time your GitHub Actions pipeline deploys successfully to AWS, ask yourself:
Does this workflow really need permanent credentials, or can it prove its identity and receive temporary access instead?
That small architectural decision can make a meaningful difference.

š¬ Let's discuss!
Are you currently using static AWS access keys in GitHub Actions, or have you implemented OIDC?
If you've configured OIDC, what was the most challenging part: creating the identity provider, writing the IAM trust policy, or configuring GitHub Actions?
Share your experiences, lessons, and security recommendations. Someone in this community might be facing exactly the same challenge.
Let's build faster, deploy smarter, and keep our cloud environments secure!
#AWS #GitHubActions #CloudSecurity #OIDC #IAM #DevOps #CICD #StudentBuilders
Enjoyed reading this content? Let the author know!
Your likes, comments, shares, and saves help creators reach more builders.
Loading recommendations
Loading article