May 14, 2026
Posted by Suresh Sathyamurthy
CI/CD pipelines are the most privileged systems in most organisations’ infrastructure. They hold credentials to deploy to production, push container images, query cloud APIs, and configure databases. And yet they are frequently the least hardened, least monitored, and most credential-dense environments in the entire estate. GitGuardian’s 2026 State of Secrets Sprawl report found nearly 29 million new secrets exposed on public GitHub in 2025, a 34% year-over-year increase, with CI/CD configuration files and build artifacts among the primary exposure vectors.
The secrets living inside your pipelines, API keys, database credentials, cloud access tokens, SSH keys, TLS certificates, enable every deployment. They also represent your most consequential attack surface. A single hardcoded token in a GitHub Actions workflow can give an attacker push access to production. A verbose test runner printing environment variables exposes every secret injected into the build. This guide covers what CI/CD secrets management means in practice, where pipelines leak secrets, how to detect them before they reach production, and how to architect a pipeline that eliminates the static credential problem at its root.
| Key Takeaways • The CI/CD pipeline is typically the most privileged system in your infrastructure, credentials breach here mean production access, not just a dev environment. • Hardcoded secrets in pipeline YAML or source code are the most common exposure vector. Removing them from the current HEAD does not remove them from git history; assume compromise and rotate immediately. • Detection must be shift-left: pre-commit hooks (Gitleaks, detect-secrets), CI-step scanners (TruffleHog), and SAST scanning catch secrets before they propagate through stages. • OIDC federation eliminates static credentials for GitHub Actions → AWS/GCP/Azure integrations entirely, no long-lived keys to store, rotate, or leak. • Dynamic, JIT (Just-in-Time) secrets from a centralised manager like Akeyless ensure credentials are short-lived, tied to a specific pipeline run, and automatically expired, shrinking the blast radius of any breach to near zero. • Compliance frameworks (SOC 2 CC6.1, NIST SP 800-53, PCI DSS v4.0 Req 6.3/8.2, CISA Secure Software Development) require documented access controls, credential management, and audit logs for CI/CD environments. |
What is CI/CD Secrets Management?
Secrets management refers broadly to the lifecycle control of sensitive credentials, generation, storage, access control, rotation, and revocation. CI/CD secrets management is a specific, harder version of that problem, shaped by three properties unique to pipeline environments:
- Ephemeral runners: GitHub Actions, GitLab CI, and CircleCI runners spin up on demand and terminate after the job completes. There is no persistent filesystem to lock down, but also no persistent state to audit. Credentials injected at runtime must be treated as temporarily exposed to the runner environment, and any secret written to disk, logged, or printed to stdout persists in job logs long after the runner is gone.
- Multi-stage propagation: A secret injected at the source control stage may need to pass through a build step, a test step, a staging deployment, and a production promotion. Each handoff is an additional exposure point. Without careful scoping, a secret available in the build stage may still be readable during a deploy-to-production step it was never meant to reach.
- Third-party action supply chain: In GitHub Actions, a third-party action referenced in a workflow step has access to all environment variables and secrets available to that workflow. A compromised action, through account takeover or malicious package update, can silently exfiltrate every credential. Pinning actions to specific commit SHAs (not mutable tags like @v2) is a fundamental mitigation, but not universally practiced.
The key CI/CD platforms each handle secrets differently. GitHub Actions stores secrets at the repository, environment, or organisation level and injects them as environment variables. GitLab CI uses masked variables that are redacted from job output. Jenkins uses the Credentials Plugin to store secrets in the Jenkins credential store. CircleCI provides per-project and organisation-level context secrets. In all cases, the platform’s native secret store is a convenience layer, not a secrets management solution, it lacks dynamic credential generation, automated rotation, and cross-platform audit capabilities.
The Challenges of Secrets Management in CI/CD Pipelines
Secrets are critical to the functionality of CI/CD pipelines, they enable services to communicate, authenticate, and deploy. Their sensitive nature also makes them a prime target for breaches. GitGuardian found that 59% of machines with compromised credentials in 2025 were CI/CD runners, not personal laptops, confirming that pipelines, not developer workstations, are the primary breach surface.
1. Hardcoded Secrets in Source Code
The most common and most dangerous anti-pattern: API keys, access tokens, or database passwords committed directly into source code, pipeline YAML files, or Dockerfiles. Even in private repositories, hardcoded secrets are not safe, GitGuardian research has consistently found that private repositories are 6× more likely than public repositories to contain hardcoded secrets, and that 35% of customers’ private repositories contain plaintext credentials.
The compounding problem: removing a secret from the current HEAD does not remove it from git history. Every clone of the repository contains the full commit history and every secret ever committed to it. The only safe remediation is immediate rotation and revocation of the exposed credential, not just deletion from the current branch.
Example (anti-pattern to avoid, do not replicate in production):
# ❌ ANTI-PATTERN: hardcoded token in GitHub Actions workflow
env:
AWS_SECRET_ACCESS_KEY: AKIAIOSFODNN7EXAMPLE/wJalrXUt...
# ✅ CORRECT: reference a secret from the platform's secret store
env:
AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
2. Inconsistent Secret Sharing Across Pipeline Stages
Modern CI/CD pipelines span multiple stages, source control, build, test, staging deployment, production promotion, often across different tools (GitHub, Jenkins, Kubernetes). Without careful scoping, a secret injected for the build stage remains available to every subsequent stage in the same pipeline run. A database credential needed only for integration tests should not be accessible to the production deployment step, but broad-scoped pipeline environment variables make this isolation difficult to enforce.
Staging vs. production secrets drift is a common manifestation: staging credentials that should be weaker copies of production credentials accidentally gain the same permissions, or production credentials are used in staging environments where access controls are looser. Each case expands the attack surface beyond what the pipeline’s actual deployment authority justifies.
3. Excessive Permissions on Pipeline Secrets
Granting broad, persistent permissions for CI/CD secrets violates the principle of least privilege and dramatically increases the blast radius of a credential compromise. An IAM role attached to a CI runner that has s3:* and ec2:* permissions when the job only needs to copy artifacts to a single S3 bucket is an over-permissioned credential that gives an attacker who compromises the runner access to infrastructure far beyond the deployment pipeline’s legitimate scope.
The OWASP Secrets Management Cheat Sheet is explicit: CI/CD tooling should have designated service accounts which can only operate in the scope of the required secrets or orchestration of the consumers of a secret. Credential sharing across pipelines of different sensitivity levels should not occur: if pipeline A does not require access to the same secrets as pipeline B, they should not be shared.
4. Manual Rotation and Maintenance
Rotating secrets manually in a CI/CD environment is operationally hazardous. Each rotation requires updating every pipeline configuration, environment variable, and downstream service that references the credential, a process that is prone to error, easy to forget, and creates a window during which both old and new credentials must be active simultaneously. Under operational pressure, manual rotation gets deprioritised, and a single missed rotation on a high-privilege CI/CD credential can leave an active attack surface open for months.
The data is consistent: GitGuardian’s research found that 70% of secrets leaked in 2022 were still active in 2025. Many of those long-lived credentials are in CI/CD systems where rotation is operationally difficult and not automated.
5. Audit and Compliance Challenges
Regulatory and audit requirements for CI/CD secrets management are increasingly specific. Meeting them with native platform secret stores, which provide limited, siloed logging, is difficult at scale:
- SOC 2 Type II CC6.1: Logical access controls must cover all systems, including CI/CD infrastructure. Auditors require evidence of access control policies, least-privilege enforcement, and access log reviews for build and deployment systems.
- NIST SP 800-53 Rev. 5 (CM-3, IA-5, SI-3): Configuration change controls (CM-3), authenticator management (IA-5), and malicious code protection (SI-3) all apply directly to pipeline credential management and secret scanning requirements.
- PCI DSS v4.0 Requirements 6.3 and 8.2: Req 6.3 mandates security in the software development lifecycle, including secret scanning in CI/CD. Req 8.2 requires individual authentication of all users and systems, including service accounts in pipelines, shared or hardcoded credentials fail this requirement by design.
- CISA Secure Software Development (EO 14028 alignment): The US Executive Order on Improving the Nation’s Cybersecurity and CISA’s resulting guidance require documented secure development practices, including secrets management controls in CI/CD pipelines, for software sold to or used by the US federal government.
A centralised secrets management platform with comprehensive audit logging satisfies all four frameworks simultaneously, a single audit trail covers who accessed which credential, from which pipeline, at what time, and with what result.
Secrets Detection in CI/CD Pipelines
Detection must be shift-left: catching a hardcoded secret before it reaches the pipeline is fundamentally better than detecting it after it has been committed, cloned, built into a Docker image, and deployed. A layered detection approach covers three checkpoints:
Layer 1: Pre-Commit Hooks
Pre-commit hooks run on the developer’s machine before the commit is created, blocking the commit if a secret is detected. This is the highest-value, lowest-cost detection checkpoint, secrets caught here have never left the local environment.
Gitleaks (github.com/gitleaks/gitleaks) is the most widely adopted open-source option. Fast, configurable via TOML rules, and integrable as a pre-commit hook via the pre-commit framework:
# .pre-commit-config.yaml
repos:
- repo: https://github.com/gitleaks/gitleaks
rev: v8.24.2
hooks:
- id: gitleaks
Install and enable:
pip install pre-commit
pre-commit install # enables hook for this repo
pre-commit run --all-files # scan all existing files
detect-secrets (Python, from Yelp) takes a whitelist/allowlist approach, it creates a baseline of known-acceptable patterns and flags new secrets that exceed entropy thresholds, reducing false positives on large codebases where some string patterns look like secrets but are not.
Layer 2: CI Pipeline Scanning
For secrets that pass the pre-commit check (or in repositories where pre-commit hooks are not enforced), a CI-step scanner adds a second gate. TruffleHog classifies over 800 secret types and, crucially, verifies whether detected secrets are still active, reducing the noise of false positives that plague regex-only tools.
TruffleHog in a GitHub Actions workflow:
# .github/workflows/secret-scan.yml
on: [pull_request, push]
jobs:
trufflehog:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0 # scan full git history
- name: TruffleHog OSS
uses: trufflesecurity/trufflehog@main
with:
path: ./
base: ${{ github.event.repository.default_branch }}
head: HEAD
extra_args: --only-verified
Layer 3: Continuous Repository and Artifact Scanning
Point-in-time scans miss secrets added between scan runs. Scheduled full-history scans using GitGuardian, Gitleaks in batch mode, or TruffleHog Enterprise provide continuous coverage, including scanning Docker image layers (where 18% of images were found to contain secrets in GitGuardian’s 2026 research), build logs, and collaboration tools like Slack and Jira, which accounted for 28% of credential exposure incidents in 2025.
Practical Solutions for CI/CD Pipeline Secrets Management
Separate Secrets from Code
The foundational rule: no secret value ever appears in source code, pipeline YAML, Dockerfile, or any artifact committed to version control. The correct pattern is runtime injection, the pipeline requests credentials from a secrets manager at the moment they are needed, receives a short-lived value, and uses it for that step only. The secret value is never written to disk, never committed, and never appears in the pipeline YAML.
For environment variable injection specifically: .env files in local development should be in .gitignore and should never reach CI. In production, environment variables should be sourced from a secrets manager or platform vault at deploy time, not hard-coded into deployment manifests.
Adopt a Centralised Secrets Storage Solution
Platform-native secret stores (GitHub Encrypted Secrets, GitLab CI Variables) are convenient but are not secrets management solutions. They lack dynamic credential generation, automated rotation, cross-environment visibility, and compliance-grade audit logging. Centralised alternatives:
| Solution | Deployment | Dynamic Secrets | Auto-Rotation | Audit Logging | Best For |
|---|---|---|---|---|---|
| Akeyless | SaaS | ✅ Yes | ✅ Yes | ✅ Comprehensive | Multi-cloud, multi-pipeline; zero-knowledge; no infra to operate |
| HashiCorp Vault | Self-hosted / HCP | ✅ Yes | ✅ Yes | ✅ Audit backend | Teams with existing Vault investment; high configurability |
| AWS Secrets Manager | Cloud-native (AWS) | ⚠️ Limited | ✅ Yes (Lambda) | ✅ CloudTrail | AWS-only environments; per-secret cost at scale |
| GitHub Encrypted Secrets | SaaS (GitHub) | ❌ No | ❌ Manual | ⚠️ Limited | Simple pipelines; low-sensitivity credentials only |
Implement Least Privilege Access
Each pipeline step should receive only the credentials it needs for its specific task. In practice, this means:
- Separate service accounts per pipeline stage, the build runner’s credentials should not overlap with the production deployment runner’s credentials.
- Scope secrets to specific environments: production secrets should only be accessible from the production deployment branch, not feature branches or PRs.
- For GitHub Actions → cloud integrations, OIDC federation eliminates static credentials entirely. Instead of storing long-lived AWS IAM keys as GitHub Secrets, the workflow authenticates via a short-lived JWT that GitHub issues at runtime and the cloud provider verifies:
# GitHub Actions OIDC to AWS — no static credentials needed
permissions:
id-token: write # required for OIDC token request
contents: read
steps:
- name: Configure AWS credentials via OIDC
uses: aws-actions/configure-aws-credentials@v4
with:
role-to-assume: arn:aws:iam::123456789:role/my-pipeline-role
aws-region: us-east-1
# No AWS_ACCESS_KEY_ID or AWS_SECRET_ACCESS_KEY needed
Automate Secrets Rotation
Replace manual secrets updates with automated rotation policies. The OWASP guidance recommends that CI/CD credentials be treated as short-lived, with rotation triggered by deployment events rather than calendar schedules. Dynamic secrets take this further: instead of rotating a static credential, the secrets manager generates a unique, time-limited credential for each pipeline run, valid for the duration of the job and automatically expired afterward. The blast radius of a compromised dynamic secret is bounded by its TTL, typically minutes or hours, not months.
Monitor and Audit Secret Usage
Set up logging and monitoring to track how secrets are accessed and used within your CI/CD pipelines. The OWASP Cheat Sheet specifies that logs should be queryable for at least 90 days and stored for a more extended period in cold storage. Integrate secret access events with your SIEM (Splunk, Datadog, AWS Security Hub) to correlate pipeline credential usage with deployment events and surface anomalies, unexpected credential access from an unfamiliar region, at an unusual time, or from a pipeline that should not have access to a given secret.
Pipeline Secrets Management: Going Beyond the Basics
Effective secrets management for CI/CD pipelines is not just about eliminating hardcoded credentials, it is about rearchitecting the trust model of the pipeline itself so that credentials are issued on demand, scoped to the minimum required access, and expired automatically.
- Dynamic secrets for ephemeral CI/CD runners: Ephemeral runners in modern CI systems are perfectly suited for dynamic credentials. Each runner starts, requests a time-limited database credential or cloud access token from the secrets manager, uses it for the duration of the job, and the credential expires when the runner terminates. No rotation required; no long-lived credential to steal.
- Just-in-Time (JIT) credentials: JIT provisioning extends dynamic secrets to access patterns, a pipeline step requests permission to deploy to a specific environment immediately before it needs to, receives temporary access, and that access expires at the end of the step. This eliminates the problem of persistent, always-on permissions for CI/CD service accounts that represent standing privilege in production environments.
- Centralised multi-cloud management: As pipelines touch AWS, Azure, GCP, and on-premises environments, managing separate credential stores per cloud creates fragmentation and audit gaps. A centralised secrets management platform provides a unified control plane, audit log, and rotation policy that spans all environments, regardless of where the pipeline runs or what it deploys to.
How Akeyless Secures CI/CD Secrets
Akeyless integrates directly into the pipelines your team already uses, GitHub Actions, Jenkins, GitLab CI, and CircleCI, and replaces static credential injection with dynamic, short-lived secrets issued at runtime via authenticated, zero-knowledge vault access.
GitHub Actions + Akeyless (OIDC: No Static Credentials)
Using Akeyless’s GitHub Actions integration with JWT authentication, workflows authenticate to Akeyless via a GitHub-issued OIDC token. No Akeyless API key or static secret needs to be stored as a GitHub Secret:
# GitHub Actions workflow — pull a secret from Akeyless at runtime
permissions:
id-token: write
contents: read
steps:
- name: Fetch secret from Akeyless
uses: akeyless-community/akeyless-github-action@v1
with:
access-id: ${{ vars.AKEYLESS_ACCESS_ID }} # non-sensitive access ID
access-type: jwt # OIDC/JWT auth — no static secret
static-secrets: |
- name: 'my-secret'
path: '/prod/my-app/api-key'
output-name: MY_API_KEY
The secret value is injected as a masked environment variable for the duration of the job and is never stored in pipeline YAML or as a GitHub Secret.
Jenkins + Akeyless
For Jenkins pipelines, Akeyless provides a plugin that retrieves secrets from the Akeyless vault at runtime using the pipeline’s configured auth method (IAM role, API key, or JWT). Secrets are available as environment variables within the pipeline stage that requests them and are not persisted to the Jenkins credential store in plaintext.
Dynamic Secrets for Database and Cloud Credentials
For database credentials, the most common long-lived secret in CI/CD environments (used for integration tests and migration scripts), Akeyless generates unique, time-limited credentials for each pipeline run:
- The pipeline requests a database credential from Akeyless at the start of the integration test step.
- Akeyless generates a unique username/password pair directly in the database, valid for the job TTL (e.g., 30 minutes).
- When the job completes or the TTL expires, the credential is automatically revoked.
- No static database password exists to be rotated, leaked, or reused across environments.
The same pattern applies to dynamic cloud credentials, SSH certificates, and Kubernetes service account tokens, any credential with a backing Akeyless dynamic secrets producer becomes a JIT, scoped, automatically expiring credential.
Conclusion
Secrets mismanagement in CI/CD pipelines is one of the most consistently exploited entry points in modern infrastructure. The pattern is predictable: a static credential committed or injected somewhere it should not be, left active long after its legitimate use case has expired, and discovered by an attacker months or years later.
Addressing it requires three changes operating in parallel: shift-left detection that catches secrets before they reach the pipeline; runtime injection that replaces static credentials with dynamic, JIT values sourced from a centralised secrets manager; and continuous monitoring that surfaces anomalous access before it becomes a breach.
Akeyless provides all three, integrated directly into the CI/CD tooling your team already uses, GitHub Actions, Jenkins, GitLab CI, CircleCI, without adding operational overhead or requiring infrastructure to manage.
| Secure your CI/CD pipelines with AkeylessReplace static credentials in your pipelines with dynamic, JIT secrets generated at runtime. Zero-knowledge encryption, OIDC-based auth for GitHub Actions, and comprehensive audit logging, all from a SaaS platform with no infrastructure to operate.Book a custom demo or start free today. |
Frequently Asked Questions
How do I prevent secrets from being exposed in CI/CD pipeline logs?
Register all secrets with your platform’s native masking feature (GitHub Actions masks registered secrets; GitLab CI masks pipeline variables marked as masked). But masking is a convenience feature, not a security boundary, if your code transforms the secret (base64 encoding, URL encoding, splitting across variables), the masked string will not match and the output will appear in plaintext. The durable solution is to avoid passing secrets through log-generating processes at all: use dynamic secrets with short TTLs, inject them only into the step that needs them, and confirm in your pipeline configuration that debug logging is disabled for steps handling credentials.
What is the best way to manage secrets in GitHub Actions?
For cloud provider credentials (AWS, GCP, Azure), use OIDC federation: no static keys stored as GitHub Secrets, no rotation required, and access tokens are scoped to the specific workflow run. For application secrets (API keys, database credentials), use a centralised secrets manager like Akeyless integrated via GitHub Actions, secrets are retrieved at runtime, masked in logs, and never written to disk. Scope secrets to the minimum required environment (use GitHub Environments with protection rules to gate production secrets behind a manual approval step). And pin all third-party actions to specific commit SHAs, mutable tags can be updated by the action author and may silently introduce a compromised version.
How does secrets detection work in CI/CD pipelines?
Effective secrets detection uses a layered approach. Pre-commit hooks (Gitleaks, detect-secrets) run on the developer’s machine before a commit is created, blocking commits that contain detected secrets. CI-step scanners (TruffleHog in a GitHub Actions workflow) scan the full git history on every pull request, catching secrets that passed the pre-commit check or were introduced before hooks were installed. Scheduled repository scans with live verification confirm whether detected secrets are still active. The OWASP recommendation is to combine all three layers and to treat secret detection infrastructure with the same hardening and monitoring discipline applied to production systems.
What is pipeline secrets management and why does it matter?
Pipeline secrets management is the practice of securing the sensitive credentials, API keys, database passwords, cloud access tokens, SSH keys, TLS certificates, that CI/CD pipelines use to build, test, and deploy software. It matters because pipelines are the most privileged systems in most organisations’ infrastructure. A credential breach in a CI/CD pipeline typically grants an attacker the same access the pipeline itself has, which often includes push access to production, cloud infrastructure control, and the ability to modify running services. Most pipelines have weaker access controls and less monitoring than the production environments they deploy to, making them a high-value, relatively low-effort target.
Related Articles
- API Key Management: Why API Keys Are Insecure and What to Do Instead
- Solving the Secret Zero Problem
- Using External Secrets Operator (ESO) with Akeyless
- How to Choose a Secrets Management Vault
- Go Vaultless with Akeyless
- Secrets Management — Platform Overview
- What Is Identity Security and Why It Matters for Businesses