Join our Newsletter — 33% off our NHI Course
Cyber Security

npm

← Back to Glossary
By NHI Mgmt Group Updated September 9, 2026 Domain: Cyber Security

npm is the default package manager for JavaScript projects. It is used to install, update, and manage dependencies through a public registry and a command line interface. In security terms, npm is both a productivity layer and a supply chain attack surface because packages can execute code during installation.

Expanded Definition

npm is the package manager and registry workflow most JavaScript teams use to fetch, version, publish, and update dependencies. Its practical boundary is broader than simple installation: it also governs dependency resolution, lifecycle scripts, lockfiles, and the trust relationship between a project and third-party code. That makes npm a development utility first, but also a supply chain control point.

The common misunderstanding is to treat npm as if it were only a convenience tool. In reality, the security posture of an npm-based project depends on how dependency sources are chosen, how versions are pinned, and how much install-time code execution is permitted. Package names, transitive dependencies, and maintainer trust all matter. The public registry model is efficient, but it also means organisations inherit risk from code they do not author.

For authoritative ecosystem guidance, the npm documentation is the best starting point for understanding how the tool behaves in practice.

Examples and Use Cases

  • A frontend team uses npm to install React, build tooling, and testing libraries from the public registry.
  • A CI pipeline runs npm install during build time, which means package scripts may execute before the application is deployed.
  • A platform engineer relies on lockfiles to keep dependency versions stable across developer laptops and release automation.
  • A security reviewer checks whether a package is a direct dependency or a transitive dependency hidden several layers deep.
  • A release manager audits package publishing permissions because a compromised maintainer account can alter what downstream projects receive.

The tradeoff is straightforward: the more automation and convenience a team wants from npm, the more it must control dependency provenance, version integrity, and install-time execution. That tradeoff is especially visible in large JavaScript estates where small library choices can fan out into many products.

Security Implications

npm is a supply chain attack surface because dependency trust extends beyond the code a team writes itself. Misunderstanding that boundary can expose organisations to typosquatting, dependency confusion, malicious maintainer updates, and lifecycle-script abuse. When installation is allowed to execute arbitrary code, the build process itself becomes part of the attack surface.

Operationally, the failure mode is often subtle. A compromised package may look legitimate, resolve correctly, and still introduce credential theft, backdoor logic, or data exfiltration during install or runtime. The blast radius can expand quickly because one package can be reused across many repositories and CI jobs. In practice, the signal is not always obvious in the application code; sometimes the real issue is a trusted dependency chain that has become too broad or too dynamic.

For teams managing many projects, a single weak dependency policy can create repeated exposure across products, environments, and release pipelines.

Domain and Governance Relevance

In software supply chain governance, npm matters because it sits at the boundary between developer productivity and third-party trust. That makes ownership decisions important: teams need clarity on who approves dependencies, who can publish packages, and what checks govern upgrades. The term is not primarily an identity concept, but it does affect access control and accountability around package publishing and registry trust.

Where machine identities enter the picture is through automated build and release systems. CI runners, deployment bots, and other non-human actors often invoke npm on behalf of the organisation, so package trust decisions can affect non-human execution paths even when the underlying subject remains software supply chain management. That is a meaningful governance link, but the core issue is still dependency assurance rather than identity management.

From a practitioner perspective, npm should be treated as a controlled intake point for code, not as a neutral utility. The governance question is whether your process can distinguish safe dependency change from silent trust expansion.

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 set the governance and control requirements practitioners need to meet.

FrameworkControl / ReferenceRelevance
CIS Controls v815 — Service Provider ManagementCovers third-party dependency and supply-chain governance risks.
2 — Inventory and Control of Software Assetsnpm dependencies need inventory and change visibility across projects.
16 — Application Software Securitynpm is used to deliver application code and scripts that must be secured.
Recommendation — Apply CIS Control 15 to vet and monitor package and registry dependencies. Maintain software inventory to track npm packages and dependency drift. Use CIS Control 16 to govern dependency intake, build scripts, and release hygiene.
MITRE ATT&CKT1195 — Supply Chain CompromiseMalicious npm packages and maintainer abuse fit supply-chain compromise patterns.
T1059 — Command and Scripting Interpreternpm lifecycle scripts can execute code during install and build.
Recommendation — Map suspicious package activity to T1195 and hunt for poisoned dependency chains. Monitor npm install-time script execution for unexpected command activity.

Deepen Your Knowledge

Sign up to our weekly newsletter — get 33% off our NHI Foundation Level Course

    NHIMG Editorial Note
    Reviewed and updated by the NHIMG editorial team on September 9, 2026.
    NHI Mgmt Group — the #1 independent authority on Non-Human Identity, IAM, and Agentic AI security. nhimg.org