CI/CD security is the practice of protecting the systems that build, test and ship your software: the source repositories, the pipelines, the build servers and agents that run them, the artifacts they produce, and the credentials they use to deploy into your cloud. It matters because a pipeline is trusted twice. Your developers trust it to turn their code into a release, and your cloud trusts it to deploy that release. An attacker who controls the pipeline inherits both.
This guide explains how pipelines work, how they are attacked, and the controls that make the biggest difference, with a focus on teams building and deploying into Microsoft Azure.
What is a CI/CD pipeline?
CI/CD stands for continuous integration and continuous delivery (or deployment). It is the automated route code takes from a developer's commit to production. Most pipelines follow the same stages:
- Source. A developer pushes a change to a repository. A push, a pull request or a schedule triggers the pipeline.
- Build. A build server hands the job to an agent (sometimes called a runner). The agent checks out the code, pulls in dependencies and compiles it.
- Test. Unit tests, integration tests and security scans run against the build.
- Artifact. The output, such as a container image, package or installer, is stored in a registry or feed.
- Deploy. The pipeline signs in to the target environment, often Azure, and releases the artifact.
Common CI/CD platforms include GitHub Actions, Azure Pipelines, GitLab CI, Jenkins and TeamCity. The names differ, but the security questions are the same on all of them.
Why attackers target pipelines
A pipeline concentrates three things attackers want in one place.
- Credentials. To deploy, a pipeline needs permission to change production. That usually means a service principal, a cloud access key, a signing certificate or a package-publishing token, often with broad rights because it was easier to set up that way.
- Code execution on trusted machines. Build agents run whatever the pipeline definition tells them to, often with network access to internal systems and the internet.
- Reach. Whatever leaves the pipeline is trusted by everyone downstream. A tampered artifact is a supply chain attack on your own customers or staff.
Pipelines are also watched less closely than user accounts. A service principal signing in at 3am to change a resource group looks exactly like a normal deployment, unless someone knows what normal looks like.
How CI/CD pipelines get attacked
The OWASP Top 10 CI/CD Security Risks is a useful map. These are the attacks we see most often, with the OWASP risk each one maps to.
Poisoned pipeline execution
The pipeline definition lives in the repository, so anyone who can change the repository can often change what the pipeline runs. An attacker who opens a pull request, or compromises a developer's account, edits the build script to dump secrets or add a step. OWASP calls this poisoned pipeline execution (CICD-SEC-4). It is especially dangerous when pipelines run automatically on pull requests from forks.
Dependency and package poisoning
Builds pull hundreds of third-party packages. Attackers publish malicious packages with look-alike names (typosquatting), hijack legitimate ones, or plant code that runs the moment a package is installed or a test suite starts. This is dependency chain abuse (CICD-SEC-3). We have written about a poisoned package that ran as soon as Python started and a malicious package built to steal Azure tokens.
Stolen pipeline secrets
Secrets stored as pipeline variables, in configuration files or in build logs are easy to extract once an attacker can run a step. This is insufficient credential hygiene (CICD-SEC-6). Our analysis of a CI stealer that went after Entra federated credentials shows how quickly a pipeline secret becomes cloud access.
Compromised build servers and agents
The build server is itself an application with vulnerabilities. In December 2026 JetBrains disclosed CVE-2026-136858, a critical flaw in on-premises TeamCity that lets an unauthenticated attacker impersonate an authorised build agent and receive the builds, and secrets, meant for it. JetBrains reported no evidence of exploitation at disclosure. We cover it, and how to hunt for misuse of pipeline identities, in our threat research on the TeamCity flaw. Unpatched or misconfigured build systems fall under insecure system configuration (CICD-SEC-7).
Self-hosted runner abuse
Self-hosted agents are often long-lived virtual machines that keep state between jobs. A malicious job can leave something behind that the next job, perhaps one with production credentials, picks up. If the agent sits inside your network, it can also be a foothold for moving further in.
Tampered artifacts
If nothing checks that the artifact you deploy is the one your pipeline built, an attacker can swap it in the registry or in transit. That is improper artifact integrity validation (CICD-SEC-9).
Weak access control and logging
Overly broad permissions on repositories and pipelines (CICD-SEC-2 and CICD-SEC-5), unreviewed third-party integrations (CICD-SEC-8) and missing logs (CICD-SEC-10) don't cause a breach on their own. They decide how far an attacker gets and how long it goes unnoticed.
How to secure a CI/CD pipeline
The joint NSA and CISA guidance on defending CI/CD environments and the OWASP list point to the same handful of controls. In rough order of value:
- Remove stored secrets. Use workload identity federation so pipelines sign in to Entra ID with a short-lived token instead of a client secret. Azure Pipelines and GitHub Actions both support it, and Microsoft's guidance covers converting existing service connections. Where a secret is unavoidable, keep it in a vault, scope it tightly and rotate it. Our guide to secrets management covers the basics.
- Give each pipeline least privilege. One service connection per environment, with roles on the resource group it deploys to rather than the whole subscription. A test pipeline should not be able to touch production.
- Protect the pipeline definition. Require reviews on the main branch, protect the files that define pipelines, and don't run privileged pipelines automatically on pull requests from forks.
- Pin and vet dependencies. Use lock files and pinned versions, pull packages through an internal feed where you can, and scan for known-malicious and vulnerable packages before the build uses them.
- Make agents disposable. Prefer ephemeral agents that are built fresh for each job and destroyed afterwards. Keep self-hosted agents off flat internal networks and restrict what they can reach.
- Sign artifacts and record provenance. Sign what you build and verify the signature before deploying. The SLSA framework sets out levels for this, from simply recording how a package was built up to hardened, isolated builds whose signing keys are out of reach of build steps.
- Patch and harden the build platform. Treat build servers like any other internet-facing system. They are high-value, and they need patching just as fast as other critical servers. Restrict who and what can reach agent and admin endpoints.
- Log it and watch it. Send repository audit logs, pipeline run history and Entra service principal sign-ins to your SIEM. Alert on pipeline definitions changing outside review, secrets being read by unusual jobs, and pipeline identities signing in from somewhere new.
What good monitoring looks like
Most pipeline compromises surface through identity, not through the pipeline itself. The stolen credential is used somewhere else. That makes three signals worth collecting in Microsoft Sentinel:
- Service principal and managed identity sign-ins from IP addresses, regions or user agents the pipeline has never used before.
- Role assignments and federated credentials added to pipeline identities, which can give an attacker a lasting way back in.
- Repository and pipeline audit events: new workflows, changed branch protection, new self-hosted runners and new personal access tokens.
None of these is suspicious on its own. Each needs context, such as who made the change, whether it went through review, and what happened next. That is the work a security operations team does. It is also why developer machines, which hold the keys to all of this, deserve the same protection as your most sensitive servers. We have argued that developer workstations belong in Tier 0.
How to test your pipeline's security
Configuration reviews find the obvious gaps: broad service connections, secrets in variables, unprotected branches. An offensive security assessment goes further and asks what an attacker could do from a realistic starting point, such as a compromised developer account, a malicious pull request or a foothold on a build agent. Then it follows that path to see how far it leads. Scope it to the pipelines that deploy to production and the identities they use, and repeat it when the way you build changes.
Frequently asked questions
What is the biggest CI/CD security risk?
In most organisations it is credentials: long-lived secrets with broad permissions, stored where any pipeline step can read them. Replacing them with short-lived, tightly scoped identities removes the most valuable thing an attacker can take.
Is CI/CD security the same as DevSecOps?
They overlap but they're not the same. DevSecOps is about building security checks into the development process, such as code scanning and dependency checks in the pipeline. CI/CD security is about protecting the pipeline itself, so that the process those checks run in can't be turned against you.
Are cloud-hosted pipelines safer than self-hosted ones?
Often, for the build agents. Hosted agents are usually fresh for each job and patched by the provider. But the pipeline definition, the secrets and the permissions are still yours to secure. Self-hosted agents can be just as safe if they are ephemeral, isolated and patched.
What is poisoned pipeline execution?
An attack in which someone changes the commands a pipeline runs, usually by editing the pipeline file or a script it calls in the repository, so the pipeline runs their code with its own privileges and secrets.
What is SLSA?
SLSA (Supply-chain Levels for Software Artifacts) is a framework for proving how software was built. Its build levels range from recording provenance, to provenance signed by the build platform, to builds isolated from each other with signing keys kept away from build steps.
How do I stop my pipeline storing Azure secrets?
Convert your Azure service connections and GitHub Actions deployments to workload identity federation. The pipeline then gets a short-lived token from Entra ID for each run, and there is no client secret to steal or rotate.
Talk to us
If you want to know how far a compromised pipeline could reach in your environment, or want your pipeline identities watched alongside the rest of your Microsoft estate, book a demo with our team.