TL;DR: The most dangerous period for npm supply chain attacks is the short window between publication and independent review, according to Semgrep, and pinning versions, disabling install-time scripts, and delaying automated updates can materially reduce exposure. The core lesson is that perfect pre-install analysis is unrealistic, so controlling execution timing matters more than trusting every new package immediately.
At a glance
What this is: Semgrep argues that npm supply chain malware is most dangerous immediately after publication, before researchers and vendors can verify whether a package is safe.
Why it matters: This matters because dependency trust, install-time execution, and update timing all affect how quickly malicious code can reach development pipelines and downstream workloads.
Context
The core security problem is not package installation itself, but the trust gap between publication and verification. In npm ecosystems, developers often pull in third-party code before anyone has independently reviewed whether it is malicious, which turns speed into an exposure multiplier. For identity and access teams, the parallel is familiar: the shorter the uncontrolled access window, the less opportunity an attacker has to abuse it.
Supply chain attacks exploit that delay by hiding malicious behaviour inside apparently normal dependency workflows. npm install-time scripts, rapid automated updates, and insufficient scrutiny of newly published code all widen the window in which unverified code can execute. This is a software supply chain governance problem first, and an identity-adjacent problem second, because execution rights are being granted before trust is established.
Key questions
Q: What should teams do first when a new npm package has not yet been reviewed?
A: Treat the package as untrusted until it has passed a human or automated review, then pin the version rather than installing it immediately. The first control is to remove urgency from adoption, because the highest risk is the period before the ecosystem has had time to verify the release.
Q: Why do freshly published dependency releases create so much supply chain risk?
A: Fresh releases are dangerous because attackers benefit from the gap between publication and independent verification. During that window, teams often install code before they know whether it contains malware, so exposure is highest when defenders know least.
Q: What are the signs that install-time script execution is creating unnecessary risk?
A: Risk is elevated when packages rely on preinstall or postinstall hooks, when build agents execute new dependencies automatically, or when teams cannot explain why a package needs code execution during installation. Those conditions mean the trust decision is happening too early.
Q: Should teams delay automated dependency updates or merge them immediately?
A: Teams should usually delay automated updates long enough for the wider ecosystem to spot malicious releases, especially for widely used packages. Immediate merging is only justified when the update is a verified security fix and the change has been reviewed for supply chain risk.
Technical breakdown
Why npm install-time execution is the dangerous moment
npm packages can execute code during installation through lifecycle hooks such as preinstall and postinstall. That means the security decision is often made before a developer has meaningfully inspected the payload, especially when the package is new or the code is hard to read. Malicious packages can abuse this behaviour to run immediately on a workstation or build agent, even if the final application never explicitly calls the malicious function. The core risk is not just dependency risk, but execution before verification. Practical implication: treat install-time execution as a separate control point from runtime trust.
Practical implication: Disable install-time scripts where possible, and require explicit review before allowing packages to execute during installation.
Why human review still matters alongside AI-assisted analysis
The article shows that large language models can help with some readable or obfuscated samples, but they remain inconsistent across minified code, binaries, and adversarial payloads. That makes AI a useful triage aid, not a trust oracle. Security review still has to account for context window limits, false positives, false negatives, and prompt-injection-style manipulation. In practice, the analysis workflow has to combine machine assistance with human judgement, especially when a package is newly published or unusually structured. Practical implication: use AI to accelerate screening, but do not let it become the sole approval control.
Practical implication: Route suspicious packages through human review whenever code is unreadable, minified, binary, or otherwise outside automated confidence thresholds.
How delaying updates shrinks the malware window
The article’s central timing argument is that the first hours or days after publication are the highest-risk period, before researchers, vendors, or registries have had time to identify malicious content. Delaying automated dependency updates gives defenders a chance to benefit from that community response before the package lands in production builds. This is a classic exposure-window control: it does not eliminate risk, but it reduces the chance that your environment becomes an early victim of a fresh malicious release. Practical implication: use staged update timing as part of dependency governance, not as an afterthought.
Practical implication: Introduce a deliberate delay for automated dependency merges so the ecosystem can flag malicious releases before they reach your build chain.
Threat narrative
Attacker objective: The attacker wants to execute malicious code before defenders can verify the package, turning the publication window into a malware delivery opportunity.
- Entry begins when an attacker publishes a malicious npm package or compromises an existing dependency with hidden payloads.
- Credential or execution abuse occurs when install-time scripts or automated update flows run the package before independent verification has occurred.
- Impact follows when the malicious code executes inside developer systems or build pipelines, expanding the blast radius across downstream dependencies and releases.
Breaches seen in the wild
- Shai Hulud npm malware campaign: Shai Hulud campaign: npm malware exposed secrets on GitHub.
- Miasma and Hades Supply Chain Worms: Self-propagating supply chain worms Miasma and Hades compromise npm, PyPI, and Azure credential stores.
Read and download The State of NHI & AI Agent Breach Report 2026, covering 200+ breaches impacting Non-Human Identities including AI Agents.
NHI Mgmt Group analysis
Exposure-window control is the real governance problem in dependency security. The article shows that the risk is concentrated in the brief period between publication and independent review, when teams are effectively trusting code before trust has been established. That is a governance failure, not a tooling failure. Security programmes should treat timing as a control surface, especially where build pipelines can execute dependencies automatically.
Install-time execution is a privilege grant, not a harmless convenience. Lifecycle scripts turn package installation into code execution, which means dependency intake is also an authorization decision. In identity terms, this resembles giving a new principal immediate runtime capability before its behaviour has been evaluated. Practitioners should therefore model package installation as an access event, not just a software event.
Human review remains the control that AI cannot replace. The article’s experiments are useful, but they also show why automated analysis cannot be the sole trust gate for new packages. Minified code, binaries, and adversarial payloads all create blind spots that need analyst judgement. The security lesson is that AI can accelerate inspection, but it cannot certify intent with enough reliability to remove human oversight.
Short-lived, narrowly scoped tokens reduce downstream blast radius. When maintainers handle multiple libraries, token sprawl becomes part of the supply chain risk surface because stolen or long-lived credentials can be reused across releases. That makes token lifetime and scope a governance issue as much as a secrets issue. Practitioners should align package publishing credentials with the same lifecycle discipline they would apply to any high-value non-human identity.
Dependency governance is moving toward delayed trust, not immediate adoption. The article validates a broader market shift away from always-install latest behaviour and toward staged acceptance of third-party code. That direction aligns with how mature security programmes already handle privileged access: verify first, then grant, then monitor. The practitioners who will benefit most are the ones who make delay, review, and revocation normal parts of software intake.
From our research library:
- 92% of organisations expose NHIs to third parties, raising concerns about supply chain security, according to the Ultimate Guide to NHIs.
What this signals
Delayed trust is becoming a practical control model for software supply chains. Teams that treat publication as the start of a verification window, not the end of a release process, reduce the chance that malicious code enters build systems before defenders can respond.
NHI thinking applies here because publishing credentials and package-maintenance tokens are non-human identities. If those credentials are long-lived or broadly scoped, one compromised token can turn a single package release into a wider supply chain event. The governance lesson is to manage publishing access like any other privileged machine identity.
92% of organisations expose NHIs to third parties, according to the Ultimate Guide to NHIs. That figure reinforces why third-party dependency trust and token governance belong in the same risk conversation, especially when package ecosystems are involved.
For practitioners
- Pin dependency versions Hold known-safe versions until they have been independently reviewed, rather than automatically adopting every newly published release.
- Disable install-time scripts by default Use --ignore-scripts or equivalent package-manager controls to prevent lifecycle hooks from executing unreviewed code during installation.
- Delay automated dependency merges Introduce a 24 to 48 hour delay before merging automated update pull requests so malicious packages can be identified and removed.
- Use short-lived publishing tokens Issue granular package-maintenance tokens that expire quickly so a compromised credential cannot be reused across multiple libraries or releases.
Key takeaways
- The article frames npm supply chain risk as a timing problem, where malware is most dangerous before independent review catches up.
- Install-time scripts, rapid updates, and blind trust in fresh packages all widen the attack window that adversaries exploit.
- Delayed merges, version pinning, script suppression, and short-lived publishing tokens reduce exposure without pretending the risk disappears.
Key terms
- Exposure Window: The period in which a credential, session, or privilege grant can be exploited before it is revoked or expires. Shorter windows help, but they do not solve the deeper question of whether the access remains justified for the full time it is active.
- Install-Time Execution: Install-time execution is code that runs while dependencies are being installed rather than when an application is launched. In supply chain attacks, this matters because the install phase often has access to the richest secrets in developer and CI environments, making it a high-value privilege boundary.
- Dependency Pinning: Dependency pinning means fixing a project to specific package versions instead of always pulling the newest release. It reduces surprise upgrades and gives security teams time to evaluate whether a new package version is trustworthy before it enters production.
- Short-Lived Publishing Token: A package-maintenance credential that expires quickly and is scoped narrowly to reduce damage if it is stolen. In software supply chains, short-lived tokens limit how far a compromised publishing identity can be reused across projects.
Deepen your knowledge
NHI Foundation Level course, the industry's only accredited NHI security programme, covers NHI governance, machine identity security, and secrets management. It is a practical fit for practitioners who need to connect identity controls to broader supply chain risk.
Published by the NHIMG editorial team on August 2, 2026.
Updated on October 13, 2026.
NHI Mgmt Group, the independent authority on Non-Human Identity, IAM, and Agentic AI security. nhimg.org