When unsafe code enters CI/CD workflows, it can trigger builds, propagate into releases, and carry the defect or malware into production at speed. The article warns that a bad commit can compromise infrastructure before teams notice. Blocking risky merges and builds early prevents that chain from reaching staging or live environments.
How Unsafe Code Spreads Through CI/CD
When vulnerable code or malicious packages enter CI/CD, the pipeline stops being a neutral delivery mechanism and becomes an execution path. Builds, tests, signing steps, dependency resolution, and artifact publishing can all execute untrusted logic if guardrails are weak. That means a single bad commit or poisoned package can move from source control into staging and production with the full authority of the delivery system behind it.
The core problem is speed plus trust. CI/CD systems are designed to automate repeatable change, so they often have privileged access to repositories, registries, signing keys, deployment targets, and secrets. Once malicious code reaches that environment, it can exfiltrate credentials, alter build outputs, or embed persistence into shipped artifacts. The Shai Hulud npm malware campaign shows how supply-chain abuse in CI/CD-adjacent workflows can expose secrets at scale.
In practice, teams usually discover the issue after the pipeline has already produced trusted output, not when the unsafe dependency first appeared.
Where the Real Failure Usually Happens
CI/CD compromise rarely depends on one dramatic bug. It more often comes from weak provenance checks, overly broad pipeline permissions, unpinned dependencies, or build steps that execute third-party code without review. A malicious package does not need to target the final application directly if it can run during install, test, or packaging and then use the pipeline’s own permissions to do the damage.
Common failure points include:
- Dependency updates that are accepted automatically without provenance or signature verification.
- Build runners that can read secrets needed only for deployment, not for compilation.
- Workflow definitions that allow arbitrary pull request changes to trigger privileged jobs.
- Artifact promotion paths that trust anything built by the pipeline, even if the input was untrusted.
That is why supply-chain controls such as SLSA matter here: the question is not only whether the code compiles, but whether the build output can be trusted back to a known source and process. A useful operational benchmark is whether your pipeline can prove what it built, from which inputs, and under which controls. The OpenSSF ecosystem is also relevant because it frames this as a software supply-chain integrity problem, not just a developer hygiene issue.
These controls tend to break down when teams give build jobs broad secret access and treat dependency updates as low-risk maintenance work.
How Teams Should Respond to Edge Cases
Tighter pipeline control often increases friction for developers, so organisations must balance release speed against trust assurance. That tradeoff becomes more visible in fast-moving teams, monorepos, and ecosystems with heavy dependency churn, where fully manual review of every package update is unrealistic.
The practical answer is to differentiate between low-risk and high-risk paths. Internal code changes, third-party dependencies, reusable actions, and deployment workflows should not receive the same trust level. High-risk paths need stronger review, isolated runners, short-lived credentials, and artifact verification before promotion. Where teams use package ecosystems with frequent dependency updates, the safest pattern is to treat every external package as potentially executable content until it has passed policy checks.
Two edge cases deserve special handling. First, trusted maintainer accounts can still be compromised, so approval alone is not enough if the workflow can execute new code automatically. Second, even a legitimate package can become dangerous if it gains post-install hooks or build-time behavior that was not present during initial adoption. The Reviewdog GitHub Action supply chain attack is a useful reminder that workflow trust and package trust are not the same thing.
In practice, the hardest failures appear when organisations assume “open source” means “safe enough for privileged automation.”
Risk and Threat Considerations
CI/CD exposure creates both supply-chain risk and direct compromise risk. The immediate danger is that unsafe code or malicious packages can inherit the pipeline’s trust, allowing attackers to reach secrets, signing material, deployment targets, and downstream environments before detection. Once that trust boundary is crossed, the pipeline itself can become the attacker’s delivery channel.
Failure mechanism: Malicious code executes during build or install steps, abuses overly broad runner permissions, or steals secrets from the workflow environment. From there, the attacker can modify artifacts, poison releases, or reuse credentials to move into staging, production, or related repositories.
Impact: Compromised builds, leaked credentials, tampered releases, and accelerated production exposure. In severe cases, one unsafe dependency can turn a software delivery control into an enterprise-wide compromise path.
Standards & Framework Alignment
This section maps relevant standards and security frameworks to the operational risks and controls described in this guidance.
MITRE ATT&CK and OWASP Non-Human Identity Top 10 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 | CIS 15 — Service Provider Management | CI/CD supply-chain trust depends on controlling third-party code sources and dependencies. |
| CIS 4 — Secure Configuration of Enterprise Assets and Software | Pipeline runners and workflow settings must be hardened to prevent unsafe code execution. | |
| CIS 16 — Application Software Security | The issue is software delivery integrity, including build-time validation and release trust. | |
| Recommendation — Vet third-party packages and workflow actions before allowing them into release pipelines. Harden CI/CD runners and workflow settings to limit arbitrary code execution and secret exposure. Apply secure build and release checks to verify inputs, outputs, and artifact integrity. | ||
| NIST CSF 2.0 | GV.SC — Supply Chain Risk Management | The question is fundamentally about supply-chain compromise entering software delivery. |
| PR.DS — Data Security | CI/CD failures often expose secrets and sensitive build data during malicious execution. | |
| PR.PS — Platform Security | Pipeline runners and build platforms need isolation and integrity safeguards. | |
| Recommendation — Establish supply-chain controls for dependencies, build inputs, and artifact provenance. Protect secrets in pipelines and restrict where build-time data can be accessed. Isolate and harden CI/CD platforms so untrusted code cannot freely execute or persist. | ||
| MITRE ATT&CK | T1195 — Supply Chain Compromise | Malicious packages entering CI/CD are a direct supply-chain compromise path. |
| T1552 — Unsecured Credentials | A primary consequence of compromised CI/CD is theft of secrets from workflows. | |
| T1059 — Command and Scripting Interpreter | Build steps that execute untrusted code often rely on interpreters during compromise. | |
| Recommendation — Map suspicious package and workflow activity to T1195 and investigate compromised dependencies. Hunt for exposed secrets in pipeline logs, runners, and build artifacts. Monitor pipeline jobs for unexpected interpreter activity and scripted execution chains. | ||
| OWASP Non-Human Identity Top 10 | NHI-01 — Secrets and Credential Exposure | CI/CD workflows commonly expose secrets that malicious packages can steal or reuse. |
| Recommendation — Move pipeline secrets out of long-lived exposure paths and rotate any credentials touched by suspicious jobs. | ||
Practitioner Guidance
What to prioritise: Put provenance, dependency control, and runner isolation ahead of developer convenience for any workflow that can publish, sign, or deploy. If a job can touch production-facing assets, treat it as a privileged path rather than a normal test step.
What to verify: Confirm which workflows can read secrets, which package sources are trusted, and which jobs can promote artifacts without human review. The key question is whether untrusted input can reach an execution step with release authority.
Decision rule: If a package, action, or commit can execute during the pipeline, assume it can also exfiltrate anything the job can see. Restrict those jobs first, then decide whether the automation is still worth the trust it requires.
Practitioner takeaway: The control objective is not to eliminate automation, but to ensure that automation never gets more trust, privilege, or secret access than the specific build step actually needs.
Related resources from NHI Mgmt Group
- What breaks when malicious npm packages execute during CI/CD installs?
- What breaks when AI agents are allowed to act inside privileged CI/CD workflows?
- What breaks when CI/CD workflows can run untrusted code with privileged tokens?
- What breaks when malicious workflows can read repository secrets in CI/CD pipelines?
Deepen Your Knowledge
Reviewed and updated by the NHIMG editorial team on September 16, 2026.
NHI Mgmt Group — the #1 independent authority on Non-Human Identity, IAM, and Agentic AI security. nhimg.org