Subscribe to the Non-Human & AI Identity Journal

What do organisations get wrong about npm supply chain attacks?

They often focus on package provenance while underestimating runtime behaviour and local secret exposure. A malicious dependency is dangerous because it executes inside a trusted identity context and can read whatever that context already stores. Governance has to cover execution, storage, and revocation together.

Why Security Teams Misread npm Supply Chain Risk

Organisations often treat npm compromise as a package provenance problem, but the real risk is that malicious code runs inside an already trusted execution context. Once a dependency is installed or updated, it can inspect environment variables, local files, build artefacts, cached tokens, and developer credentials that were never meant to be part of package trust. That is why supply chain controls must extend beyond signatures and version pinning. The pattern is visible across incidents such as the Shai Hulud npm malware campaign and the Nx Package Attack, where execution and secret exposure were the real blast-radius multipliers.

Security teams also underestimate how quickly exposed credentials are used. NHIMG research on compromised NHIs shows that when AWS credentials are exposed publicly, attackers attempt access within an average of 17 minutes, sometimes in as little as 9 minutes, which turns a brief lapse into an active intrusion window. That is why runtime telemetry and revocation matter as much as package review. Current guidance suggests aligning npm governance with OWASP Non-Human Identity Top 10 thinking, not just software bill of materials checklists. In practice, many teams discover the exposure only after a dependency has already harvested secrets from a build agent or developer workstation.

How npm Attacks Actually Work in the Environment

Malicious npm packages usually succeed because they inherit the permissions, network reach, and secret access of the process that installs or executes them. A compromised dependency does not need to break crypto or bypass a perimeter if it can simply read what is already local. That is why runtime behaviour is the control point. The right question is not only “is this package legitimate?” but “what can this code touch once it runs?”

In practice, teams should assume that package scripts, post-install hooks, and transitive dependencies can execute before detection tools finish scanning. This makes CISA cyber threat advisories and NIST-style least-privilege guidance relevant, but not sufficient on their own. Stronger control comes from reducing what is present at runtime:

  • Use short-lived, task-scoped credentials instead of long-lived tokens in developer and build environments.
  • Separate package installation from secret-bearing stages so install-time code cannot reach production secrets.
  • Store credentials in central secret managers and inject only the minimum set required for the job.
  • Monitor for unusual outbound connections, token reads, and archive access during install and test phases.

NHIMG’s analysis of the State of Secrets in AppSec shows the broader governance gap: organisations often believe their secrets practices are stronger than they are, while leaked-secret remediation still takes weeks. The lesson for npm is simple. If a package can execute with broad local access, provenance alone does not reduce the blast radius. These controls tend to break down in monorepos and shared CI runners because one compromised install path can reach many projects and many secrets at once.

Where the Standard Playbook Breaks Down

Tighter package controls often increase build friction, so organisations have to balance developer velocity against runtime containment. That tradeoff becomes more visible in environments that depend on auto-updating dependencies, shared runners, or heavily cached workspaces. Best practice is evolving, but there is no universal standard for this yet: code signing, lockfiles, and allowlists help, yet they do not stop a malicious dependency from using the privileges already available in the session.

This is where practitioners should think in NHI terms. npm pipelines need identity-aware execution boundaries, not just package trust. The Mastra npm Supply Chain Attack and Miasma and Hades Supply Chain Worms show why self-propagating behaviour changes the risk model: one poisoned package can become a lateral-movement bridge. External guidance from the ENISA Threat Landscape and the Anthropic report on AI-orchestrated cyber espionage reinforces the same operational point: autonomous or automated actors exploit whatever is available at execution time, not what policy intended on paper.

For that reason, organisations should treat npm governance as a combined problem of execution control, secret containment, and rapid revocation. The playbook fails when build systems reuse persistent credentials across many repos, because a single compromised dependency can turn one install into an environment-wide secret disclosure.

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, OWASP Agentic AI Top 10 and CSA MAESTRO address the attack and risk surface, while NIST AI RMF and NIST CSF 2.0 set the governance and control requirements practitioners need to meet.

Framework Control / Reference Relevance
OWASP Non-Human Identity Top 10 NHI-03 Addresses secret rotation and exposure after malicious package execution.
OWASP Agentic AI Top 10 A1 Malicious packages act inside trusted execution contexts and abuse runtime authority.
CSA MAESTRO G5 Supply chain compromise needs runtime governance across trusted execution paths.
NIST AI RMF GOVERN Governance must cover execution, storage, and revocation as one risk system.
NIST CSF 2.0 PR.AC-4 Least privilege is essential when dependencies inherit local identity context.

Reduce install-time privileges and separate build identities from secret-bearing production identities.