The package installation step becomes a code execution boundary rather than a dependency retrieval step. Attackers can trigger scripts before normal inspection finishes, which means malicious code can harvest secrets or alter workflows before defenders notice. The practical failure is trusting install-time behavior from packages that have not been validated for execution.
What breaks first when install-time scripts are trusted in CI/CD?
The first thing that breaks is the assumption that package installation is a passive supply step. Once lifecycle hooks can execute during install, the pipeline is no longer just retrieving dependencies, it is executing code from unreviewed packages inside the build trust boundary. That changes the security model for the entire build because scripts can run before normal review, policy checks, or artifact validation complete.
That matters in CI/CD because install steps often have access to source, build metadata, caches, and secrets. If a package can run arbitrary code at install time, then any compromise of the package or its dependency chain can become a direct path into the pipeline. The practical result is that a dependency update can behave like a hidden deployment action rather than a simple version change.
This is why install-time execution is often treated as a software supply chain problem, not just a package manager convenience. Strong provenance and artifact integrity controls help, and a build provenance model such as SLSA is useful because it forces teams to distinguish trusted source, trusted build steps, and trusted outputs. For broader guidance on dependency and pipeline abuse, the CI/CD pipeline exploitation case study shows how pipeline trust can be turned into direct server or secret exposure.
How lifecycle hooks turn dependency installs into an execution boundary
Lifecycle hooks such as preinstall, install, and postinstall are dangerous because they run automatically and often with the same effective access that the build job has. In a well-controlled pipeline, a package should be evaluated as content first and executed only after trust decisions are explicit. When hooks are allowed to run unreviewed, that separation disappears.
The security failure is not merely that the code is malicious. The deeper failure is that the install process itself becomes a privileged execution path. That means an attacker can use a dependency to reach environment variables, tokens, workspace files, or downstream build steps before anyone has a chance to inspect the package behavior. Related supply chain incidents, including the Shai Hulud npm malware campaign, demonstrate how install-time code can be used to expose secrets during routine dependency handling.
Once this boundary shifts, the blast radius is larger than the affected package. Hook execution can also influence build outputs, poison caches, alter generated assets, or silently prepare later stages for compromise. If the pipeline reuses credentials or has access to deployment tooling, the same hook can become a stepping stone from package install to environment takeover.
Why secrets and workflow integrity are the usual failure points
CI/CD systems are attractive targets because they frequently hold high-value secrets in the very place where untrusted code is being processed. A lifecycle hook does not need to be sophisticated to be damaging. It only needs enough execution to read environment variables, call out to an endpoint, or change files in the workspace before the build completes.
That is why secret theft and workflow tampering are the two most common consequences to watch for. A package install can exfiltrate credentials, inject altered build logic, or modify artifacts in ways that are hard to distinguish from normal job behavior. The Nx s1ngularity attack 2025 is a strong example of how build tooling abuse can quickly turn into broad credential loss, while ArtiPACKED 2024 shows how CI artifacts and runtime tokens can become an unintended leakage channel.
The policy implication is simple: if a package can execute during install, then the install step must be treated as an execution zone with explicit trust controls, not as a neutral download phase. For teams that want a direct mapping to hardened dependency behavior, ua-parser-js npm hijack 2021 remains a useful reminder that ordinary package trust can be weaponized very quickly.
Risk and Threat Considerations
Unreviewed lifecycle hooks create a supply chain execution path that attackers can abuse before defenders detect anything unusual. In CI/CD, that means the adversary is not waiting for a deployment bug, they are using the installation moment itself to reach secrets, alter output, or persist through poisoned build behavior.
Failure mechanism: The pipeline treats package installation as trusted setup, so hook code inherits build privileges and runs before review, inspection, or validation can stop it.
Impact: Secrets can be harvested, build outputs can be altered, and a compromised dependency can influence later stages of the delivery chain with very little visibility.
Standards & Framework Alignment
This section maps relevant standards and security frameworks to the operational risks and controls described in this guidance.
OWASP Non-Human Identity Top 10 addresses the attack and risk surface, while SLSA, NIST SP 800-53 Rev 5, CIS Controls v8 and OWASP ASVS set the governance and control requirements practitioners need to meet.
| Framework | Control / Reference | Relevance |
|---|---|---|
| SLSA | Supply-chain Levels for Software Artifacts | Install hooks make build trust and artifact provenance central to supply-chain integrity. |
| Recommendation — Strengthen build provenance and separate trusted source, build steps, and outputs. | ||
| NIST SP 800-53 Rev 5 | SA-11 — Developer Testing and Evaluation | Unreviewed install-time code is a software supply-chain integrity issue requiring trusted evaluation. |
| Recommendation — Evaluate and gate code paths before they can run in the build environment. | ||
| CIS Controls v8 | CIS-16 — Application Software Security | Package-install scripts are application delivery risk and require hardened software supply-chain practices. |
| Recommendation — Restrict untrusted install behavior and validate software before execution. | ||
| OWASP ASVS | V15 — Secure Coding and Architecture | CI/CD hook abuse is a secure architecture and trust-boundary failure in software delivery. |
| Recommendation — Design build flows so dependency retrieval is separated from code execution. | ||
| OWASP Non-Human Identity Top 10 | NHI-02 — Secret Leakage | Install hooks commonly target CI secrets, turning build execution into secret exfiltration. |
| Recommendation — Prevent install-time code from accessing secrets unless absolutely required. | ||
Practitioner Guidance
What to verify: Confirm whether your package manager and CI templates allow lifecycle scripts by default, and separate dependency fetching from execution wherever possible. The key question is whether install-time behavior is truly required for the build to succeed.
Decision rule: If a dependency can install successfully without running scripts, disable automatic hooks for untrusted packages and require an explicit exception for anything that still needs execution. If a package must run code, treat it like a build step that deserves review, isolation, and secret minimisation.
Common mistake: Teams often focus on scanning package contents after install, but by then the hook has already had an opportunity to act. Review needs to happen before execution, or the control arrives too late.
Practitioner takeaway: The real control objective is not “safe dependencies,” it is “no unreviewed code execution in the install path unless the pipeline is designed to contain it.”
Related resources from NHI Mgmt Group
- What breaks when CI/CD workflows trust tags, auto-run hooks, or startup scripts without strong integrity controls?
- What breaks when npm install hooks run inside containerised CI environments?
- What breaks when CI/CD workflows are allowed to run unpinned third-party actions?
- What breaks when malicious npm packages execute during CI/CD installs?