Replacing Static CI/CD Certificates with Ephemeral Keys and OIDC
Continuous Integration and Continuous Deployment (CI/CD) pipelines are the nervous system of modern software engineering. Because they require broad access to source code, infrastructure, and production environments, they are also a primary target for attackers. For years, the standard practice for managing cryptographic identities in these pipelines was to generate long-lived certificates or private keys and store them as static environment variables.
Today, this practice is a massive security liability.
Driven by the impending reality of 90-day maximum lifespans for public TLS certificates, the rise of software supply chain attacks, and strict new compliance mandates, organizations must fundamentally change how pipelines authenticate and sign artifacts. The era of storing .pem or .pfx files in GitHub Secrets or Jenkins credentials is over. The new standard is built on ephemeral certificates, keyless signing, and automated Machine Identity Management (MIM).
This post details why static certificates are failing, how to transition to OpenID Connect (OIDC) for pipeline authentication, and how to implement dynamic, short-lived certificate generation in your CI/CD workflows.
The Danger of Secret Sprawl and Stored Keys
Storing static certificates and private keys at rest within a CI/CD platform creates a persistent attack vector. If an attacker compromises a developer's account, a pipeline runner, or the CI/CD platform itself, those long-lived keys can be exfiltrated and used indefinitely.
Recent security incidents highlight the severity of this risk:
* The CircleCI Breach: Hackers compromised an engineer's laptop and stole active session tokens, gaining access to CircleCI’s internal systems. Because many customers stored static certificates and private keys as environment variables, those secrets were exposed, requiring mass rotations across thousands of organizations.
* The Microsoft Storm-0558 Key Leak: A stolen Microsoft Account (MSA) consumer signing key was used to forge authentication tokens, granting attackers sweeping access to enterprise email accounts. The fallout demonstrated that long-lived signing keys—if not strictly bound to Hardware Security Modules (HSMs) or managed via ephemeral processes—are a catastrophic liability.
Furthermore, GitGuardian’s State of Secrets Sprawl report found over 12.8 million secrets leaked on GitHub in a single year, with CI/CD configuration files serving as a primary vector.
Beyond security, static certificates cause operational nightmares. According to Keyfactor’s State of Machine Identity report, over 80% of organizations have experienced at least one outage caused by an expired certificate in the past 24 months. When a certificate stored in a CI/CD variable expires, deployments halt, builds fail, and troubleshooting often requires tracking down whoever originally generated the key months or years prior.
The Shift to Ephemeral Identity with OIDC
To eliminate the risks of static keys, the industry is transitioning from Secret Storage to Secret Generation. Instead of giving a pipeline a key that lasts for a year, the pipeline is given a cryptographic identity that allows it to request a key that lasts for an hour.
This is achieved using OpenID Connect (OIDC). Major CI/CD platforms—including GitHub Actions, GitLab CI, and Bitbucket—now support OIDC to authenticate with cloud providers (AWS, Azure, GCP) and secrets managers.
With OIDC, the pipeline runner acts as an untrusted entity that assumes a temporary role. It presents a JSON Web Token (JWT) to a cloud provider. The provider verifies the token's signature and claims (e.g., verifying the request truly came from your specific repository and branch) and returns short-lived, Just-In-Time (JIT) credentials.
Implementation: OIDC to AWS Secrets Manager in GitHub Actions
Instead of storing an AWS_ACCESS_KEY_ID and AWS_SECRET_ACCESS_KEY in GitHub to pull a deployment certificate from AWS, you can configure an AWS IAM Identity Provider to trust GitHub's OIDC provider.
Here is how you configure the GitHub Actions workflow to securely fetch a certificate without hardcoded keys:
name: Deploy Application with Ephemeral AWS Credentials
on:
push:
branches: [ "main" ]
# Grant the workflow permission to request an OIDC JWT token
permissions:
id-token: write
contents: read
jobs:
deploy:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Configure AWS Credentials via OIDC
uses: aws-actions/configure-aws-credentials@v4
with:
role-to-assume: arn:aws:iam::123456789012:role/GitHubActionsDeployRole
aws-region: us-east-1
- name: Fetch Certificate from AWS Secrets Manager
run: |
aws secretsmanager get-secret-value \
--secret-id production/app-certificate \
--query SecretString --output text > cert.pem
- name: Deploy to Infrastructure
run: ./deploy.sh --cert cert.pem
In this architecture, no static credentials exist. If the GitHub repository is made public accidentally, or if a developer's workstation is compromised, there are no AWS IAM keys to steal.
Keyless Code Signing with Sigstore
Achieving compliance frameworks like the SLSA (Supply-chain Levels for Software Artifacts) framework requires non-falsifiable provenance. To reach SLSA Level 3+, your CI/CD pipeline must automatically sign artifacts (like Docker images or binaries) using a secure certificate that cannot be accessed or tampered with by developers.
Historically, this meant managing a PGP or RSA private key, storing it securely, and rotating it regularly. Today, the standard is "keyless" signing using Sigstore.
Sigstore's cosign tool eliminates the need for long-lived private keys. When a pipeline signs an artifact, Cosign requests a short-lived certificate from the Fulcio certificate authority, bound to the OIDC identity of the CI/CD runner. The certificate lives just long enough to sign the artifact (typically 10 minutes) and is then discarded. The signature and public key are recorded in a tamper-resistant Certificate Transparency log called Rekor.
Implementation: Keyless Container Signing in GitHub Actions
Here is how to implement keyless signing for a Docker image using Cosign in a CI/CD pipeline:
name: Build and Sign Container
on:
push:
tags: [ 'v*.*.*' ]
permissions:
id-token: write # Required for keyless signing via OIDC
packages: write
contents: read
jobs:
build-and-sign:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Install Cosign
uses: sigstore/cosign-installer@v3.5.0
- name: Log into GitHub Container Registry
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Build and Push Image
id: docker_build
uses: docker/build-push-action@v5
with:
push: true
tags: ghcr.io/my-org/my-app:${{ github.ref_name }}
- name: Sign the Image (Keyless)
env:
COSIGN_EXPERIMENTAL: "true"
run: |
# Notice there is no --key flag used here.
# Cosign uses the OIDC token to generate an ephemeral certificate.
cosign sign --yes ghcr.io/my-org/my-app@${{ steps.docker_build.outputs.digest }}
Anyone verifying this image later will check the Rekor transparency log to confirm that the specific GitHub Actions workflow on your repository signed the image at the exact time it was built. No private keys are ever stored, rotated, or leaked.
Dynamic PKI Integration with HashiCorp Vault
For internal deployments requiring mutual TLS (mTLS) or internal service certificates, CI/CD pipelines should provision certificates dynamically rather than pulling static files. HashiCorp Vault’s PKI Secrets Engine is heavily utilized for this purpose.
Instead of a security team manually issuing a certificate via a Jira ticket, the pipeline requests one automatically.
- The pipeline authenticates to Vault using a JWT/OIDC token.
- The pipeline calls the Vault PKI secrets engine for a specific role.
- Vault generates a private key and certificate with a highly restricted Time-To-Live (TTL), such as 24 hours.
- The pipeline injects the certificate into the container or deployment manifest.
# Example Vault CLI command executed within a pipeline
vault write -format=json pki/issue/internal-app-role \
common_name="app.internal.company.com" \
ttl="24h" > cert_response.json
# Extract the certificate and private key for deployment
jq -r '.data.certificate' cert_response.json > tls.crt
jq -r '.data.private_key' cert_response.json > tls.key
By enforcing a 24-hour TTL, you drastically reduce the attack surface. Even if the certificate is intercepted during deployment, it will be useless by the next day.
Preventing Pipeline Outages and Managing Expiration
As organizations move toward 90-day TLS lifespans and short-lived internal certificates, automation via ACME (Automated Certificate Management Environment) protocols and tools like cert-manager for Kubernetes becomes mandatory. Manual rotation is mathematically unviable at enterprise scale.
However, automating certificate issuance in CI/CD pipelines introduces a new risk: silent automation failures.
If a pipeline's OIDC token permissions are accidentally revoked, if an ACME DNS challenge fails due to a network timeout, or if Vault runs out of storage backend capacity, the pipeline will fail to