In Response to Supply Chain Attacks, NPM Version 12 Will No Longer Execute Scripts by Default

NPM v12 to Disable Automatic Script Execution, Boosting Supply Chain Security

MEDIUM
June 14, 2026
July 10, 2026
4m read
Supply Chain AttackSecurity OperationsPatch Management

Related Entities(initial)

Threat Actors

TeamPCP

Organizations

Products & Tech

Full Report(when first published)

Executive Summary

GitHub has announced a landmark security improvement for the NPM ecosystem. The forthcoming NPM version 12, slated for release in July, will disable the automatic execution of install scripts from dependencies by default. This fundamental change to npm install behavior is a direct countermeasure to the escalating wave of software supply chain attacks that have exploited this feature. Threat actors like TeamPCP and the operators of the Shai-Hulud worm have previously abused this trust mechanism to distribute malware to thousands of developers. By shifting from an implicit-trust to an explicit-allow model, GitHub aims to break a primary infection vector and force developers to make conscious security decisions about their project dependencies.

Threat Overview

The core threat addressed by this change is the abuse of NPM lifecycle scripts. These scripts (preinstall, install, postinstall) are powerful tools that can run arbitrary shell commands on a developer's machine. For years, the default behavior of NPM has been to automatically execute these scripts for all dependencies, including transitive ones.

Threat actors have exploited this by:

  1. Compromising popular packages: Gaining publishing rights to a widely used package through credential theft or social engineering.
  2. Typosquatting: Publishing malicious packages with names similar to popular ones.
  3. Injecting malicious scripts: Adding malicious commands to the install scripts of the compromised or typosquatted packages.

When a developer runs npm install, the malicious script executes automatically, leading to system compromise, credential theft, or the installation of persistent malware. The self-replicating Shai-Hulud worm specifically leveraged this mechanism to spread through the NPM ecosystem.

Technical Analysis

The change in NPM v12 fundamentally alters the trust model of the package manager.

  • Old Behavior (NPM < 12): npm install implicitly trusts all dependencies and executes their lifecycle scripts. This facilitates T1195.002 - Compromise Software Supply Chain.
  • New Behavior (NPM >= 12): npm install will, by default, not execute these scripts. A developer must explicitly enable script execution, likely via a command-line flag (e.g., --run-scripts) or a configuration setting in package.json.

This forces a security checkpoint into the development workflow. Instead of silently running potentially malicious code, NPM will now require a deliberate action from the developer. This directly mitigates the initial execution vector (T1204.002 - Malicious File) used in these supply chain attacks.

Impact Assessment

This change will have a significant positive impact on the security of the entire JavaScript/TypeScript ecosystem.

  • For Developers: It reduces the risk of accidental compromise from a simple npm install. However, it may introduce friction, as developers will now need to vet and explicitly allow scripts for legitimate packages that rely on them for compilation or setup.
  • For Organizations: This is a major step forward in securing the software development lifecycle (SDLC). It reduces the corporate attack surface exposed through developer workstations and CI/CD pipelines.
  • For Threat Actors: It closes a major, low-effort infection vector. Attackers will now have to rely on more complex social engineering to convince developers to enable script execution, raising the bar for successful attacks.

Detection & Response

While this is a preventative measure, organizations can prepare by:

  1. Auditing Dependencies: Use tools like npm audit or third-party Software Composition Analysis (SCA) tools to identify dependencies that use install scripts. D3FEND's File Analysis can be applied to package contents before installation.
  2. Monitoring CI/CD: In CI/CD pipelines, monitor for the use of flags that re-enable script execution. Log and alert on these events to ensure they are intentional. This aligns with D3FEND's Process Analysis.
  3. Developer Training: Educate developers about the new default and the security risks of blindly enabling scripts. They should be taught to inspect the package.json and associated scripts of new dependencies before trusting them.

Mitigation

The change in NPM v12 is itself a mitigation. To prepare and enhance this mitigation:

  1. Adopt NPM v12 Promptly: Organizations should plan to upgrade their developer environments and CI/CD pipelines to NPM v12 as soon as it is released and stable.
  2. Use --ignore-scripts Today: Developers can get the benefit of this protection today by using the npm install --ignore-scripts flag. This can be set as a default in the .npmrc configuration file: ignore-scripts=true. This is a direct application of D3FEND's Application Configuration Hardening.
  3. Vet Dependencies: Implement a process for vetting new open-source dependencies before they are introduced into a project. This should include checking the package's reputation, maintenance status, and inspecting its code and install scripts.

Timeline of Events

1
June 14, 2026
This article was published

Article Updates

July 10, 2026

NPM v12 released, disabling install scripts by default. Developers must now use `--scripts-enabled`. New guidance provided.

MITRE ATT&CK Mitigations

The change in NPM v12 effectively disables the feature of automatic script execution by default, mitigating the risk.

Mapped D3FEND Techniques:

Manually configuring NPM (e.g., via .npmrc) to ignore scripts is a proactive software configuration mitigation that developers can apply even before NPM v12.

Mapped D3FEND Techniques:

Training developers on the risks of supply chain attacks and the importance of vetting dependencies is a crucial non-technical mitigation.

D3FEND Defensive Countermeasures

In the context of the NPM supply chain, Application Configuration Hardening is the most direct and effective defense. Before NPM v12 becomes standard, security teams should mandate that all developer workstations and CI/CD build agents are configured to disable automatic script execution. This can be achieved by creating or modifying the .npmrc file in user home directories or project roots to include the line ignore-scripts=true. This simple configuration change immediately neutralizes the primary threat vector of malicious install scripts. For projects that legitimately require build scripts, developers should be trained to run them manually and in a controlled manner (e.g., npm run build) after a security review, rather than allowing them to execute automatically during npm install. This shifts the security posture from a vulnerable 'default allow' to a secure 'default deny' model.

Sources & References(when first published)

Article Author

Jason Gomes

Jason Gomes

• Cybersecurity Practitioner

Cybersecurity professional with over 10 years of specialized experience in security operations, threat intelligence, incident response, and security automation. Expertise spans SOAR/XSOAR orchestration, threat intelligence platforms, SIEM/UEBA analytics, and building cyber fusion centers. Background includes technical enablement, solution architecture for enterprise and government clients, and implementing security automation workflows across IR, TIP, and SOC use cases.

Threat Intelligence & AnalysisSecurity Orchestration (SOAR/XSOAR)Incident Response & Digital ForensicsSecurity Operations Center (SOC)SIEM & Security AnalyticsCyber Fusion & Threat SharingSecurity Automation & IntegrationManaged Detection & Response (MDR)

Tags

NPMSupply Chain AttackShai-HuludTeamPCPGitHubDevSecOpsSoftware Development

📢 Share This Article

Help others stay informed about cybersecurity threats

🎯 MITRE ATT&CK Mapped

Every tactic, technique, and sub-technique used in this threat has been identified and mapped to the MITRE ATT&CK framework for consistent, actionable threat language.

🧠 Enriched & Analyzed

Observables and indicators of compromise (IOCs) have been extracted and cataloged. Risk has been assessed and correlated with known threat actors and historical campaigns.

🛡️ Actionable Guidance

Detection rules, incident response steps, and D3FEND-aligned mitigation strategies are included so your team can act on this intelligence immediately.

🔗 STIX Visualizer

Structured threat data is packaged as a STIX 2.1 bundle and can be visualized as an interactive graph — relationships between actors, malware, techniques, and indicators.

Sigma Generator

Sigma detection rules are derived from the threat techniques in this article and can be converted for deployment across any major SIEM or EDR platform.