Once the malicious component enters CI/CD, the pipeline can execute it, package it, and ship it as part of the released artifact. That means the attacker no longer needs direct access to production systems. The build process itself becomes the delivery mechanism, so compromise can persist until someone detects the altered dependency, script, or image and removes it from the chain.
Why a Compromised Build Input Becomes a Release Problem
A compromised dependency or install script is dangerous because CI/CD systems are designed to trust and execute build inputs so software can be assembled automatically. When that trust is abused, the pipeline can turn a single poisoned component into a released artifact, signed package, container image, or deployment bundle. The issue is not just execution during build time; it is that the malicious logic can be reproduced every time the pipeline runs until the source of trust is corrected. In practice, this turns supply-chain compromise into a repeatable delivery channel rather than a one-off intrusion.
That is why build integrity is a security boundary, not a convenience issue. The control problem is broader than patching dependencies: teams also need provenance, review discipline for install scripts, and tight control over what the build system is allowed to fetch and run. Guidance from the NIST SP 800-53 Rev 5 Security and Privacy Controls is useful here because the relevant concern is not just code quality, but preserving integrity across acquisition, build, and release paths. In practice, many teams discover the problem only after the pipeline has already propagated the tainted dependency into multiple artifacts.
How the Compromise Moves Through a CI/CD Pipeline
Once a malicious dependency or install script reaches a build, the pipeline may execute it in several different ways. Package managers can run install hooks, build tooling can invoke prebuild or postinstall steps, container builds can copy poisoned files into images, and release jobs can publish whatever the build produced. The attacker does not need to stay present after the malicious input is introduced, because the automation repeats the action at scale.
The practical risk depends on where the pipeline has trust and reach. A low-privilege build job can still matter if it has access to source code, internal package mirrors, signing keys, artifact repositories, deployment credentials, or secrets injected during build. Even when the compromise is “only” in the build stage, the output may be trusted downstream by deployment systems, scanners, and consumers. That is what makes supply-chain compromise so effective: the malicious component is not merely executed, it is legitimised by the normal release process.
- Install-time execution can trigger before a human reviewer sees the final artifact.
- Reproducible builds do not help if the same compromised input is always fetched.
- Artifact signing can amplify the problem if the pipeline signs tampered output.
- Cached dependencies can preserve the poisoned input after the upstream source is cleaned.
Build systems also tend to hide the blast radius. A single compromised dependency may affect many services if shared base images, templates, or lockfiles are reused. The guidance breaks down when build steps are uncontrolled, mutable, or allowed to pull live dependencies without verification.
Where the Usual Defences Break Down
Tighter build control often increases friction, requiring organisations to balance automation speed against trust reduction. The standard answer is not that every install script is unsafe, but that trust assumptions become brittle when teams rely on opaque third-party code or on build-time execution they have not explicitly constrained.
Common edge cases include private package mirrors that are not actually curated, pinned versions that still allow compromised maintainers to publish malicious updates, and container builds that appear isolated but inherit credentials or network reach from the runner. There is also a practical difference between a dependency that ships bad code and an install script that executes during setup: the latter can create a faster and less visible path into the build, because it runs as part of the normal install flow. The industry generally agrees that provenance, pinning, and review reduce exposure, but there is no consensus that any single measure is sufficient on its own.
The most overlooked case is when the pipeline itself becomes the persistence layer. If the compromise is embedded in a shared template, base image, or package lockfile, teams may keep rebuilding the same weakness long after the initial event. Organisations that depend on external package ecosystems should treat supply-chain trust as an ongoing validation problem, not a one-time approval step.
Risk and Threat Considerations
The material risk is supply-chain execution inside a trusted automation path. A compromised dependency or install script can convert build-time trust into code execution, artifact poisoning, and downstream distribution of tampered software. The exposure matters because the pipeline often has broader reach than the application itself, including signing capability, internal network access, and privileged access to release systems.
Failure mechanism: The attacker abuses normal package retrieval or install-time hooks so malicious code runs during the build, then relies on the pipeline to package and publish the altered output. This is a recognised supply-chain mechanism, not a one-off anomaly.
Impact: The released artifact may be compromised before production ever sees it, which can spread malicious logic to many environments, preserve persistence across rebuilds, and undermine trust in signed or “official” releases.
Standards & Framework Alignment
This section maps relevant standards and security frameworks to the operational risks and controls described in this guidance.
MITRE ATT&CK address the attack and risk surface, while CIS Controls v8 and NIST CSF 2.0 set the governance and control requirements practitioners need to meet.
| Framework | Control / Reference | Relevance |
|---|---|---|
| CIS Controls v8 | 16.11 — Perform Dependency Management and Software Integrity Verification | Covers supply-chain integrity for dependencies entering the build. |
| Recommendation — Verify dependency integrity and block untrusted packages from reaching release builds. | ||
| NIST CSF 2.0 | PR.DS-6 — Integrity Monitoring | Applies to detecting tampering in build inputs and artifacts. |
| PR.IP-2 — Secure Development Life Cycle | Fits secure build and release practices that reduce pipeline compromise. | |
| Recommendation — Monitor build inputs and artifacts for integrity drift and unauthorised modification. Embed build provenance checks and release approvals into the development lifecycle. | ||
| MITRE ATT&CK | T1195 — Supply Chain Compromise | Directly models compromised dependencies or scripts entering the build chain. |
| T1059 — Command and Scripting Interpreter | Install scripts can execute attacker-controlled logic during the build. | |
| Recommendation — Map build-pipeline compromise to T1195 and hunt for poisoned dependency activity. Restrict scripted install paths and flag unexpected interpreter use in CI/CD jobs. | ||
Practitioner Guidance
What to prioritise: Treat dependency provenance and install-time execution as separate controls. Pinning versions is helpful, but it does not stop malicious behaviour hidden inside a legitimate package or script, so teams need a decision point for when build-time execution is allowed at all.
What to verify: Confirm that the build job cannot freely reach signing keys, production credentials, or long-lived secrets unless those are strictly required. If the pipeline can both execute untrusted input and access high-value credentials, the build stage is already a privileged trust boundary.
Common mistake: Assuming the risk ends when the malicious package is detected and removed upstream. If cached layers, lockfiles, or copied artifacts still contain the compromised component, the pipeline can continue to regenerate the same bad output until those artefacts are rebuilt from clean inputs.
Practitioner takeaway: The key judgement is whether the build system is merely compiling code or also acting as a trusted executor of unvetted supply-chain inputs, because that distinction determines how far a single compromise can spread.
Related resources from NHI Mgmt Group
- What happens when a malicious package reaches CI/CD without dependency malware controls?
- What happens when a compromised npm package is merged into CI/CD through automated dependency updates?
- What should teams do after a compromised dependency reaches a build or runtime host?
- Who is accountable when a compromised package reaches CI/CD pipelines?