GitHub Disables npm Install Scripts by Default in v12 to Prevent JavaScript Supply Chain Attacks

GitHub Disables npm Install Scripts by Default in v12 to Prevent JavaScript Supply Chain Attacks

Executive Summary

Publication Date: June 2026

GitHub has announced a pivotal security enhancement for the npm package ecosystem: starting with npm v12, install scripts such as preinstall, install, and postinstall will be disabled by default. This strategic move is a direct response to a surge in supply chain attacks that have exploited automatic script execution during package installation. By aligning npm with other package managers like Yarn, pnpm, and Bun, which already block install scripts by default, GitHub is taking a significant step to reduce the attack surface for developers and organizations relying on open source JavaScript packages. This report provides a comprehensive analysis of the technical, practical, and security implications of this change, its impact on the broader software supply chain, and what it means for organizations from a cyber risk perspective.

Technical Details and Core Functionality

With the release of npm v12, install scripts will not execute unless explicitly permitted in the project configuration. This includes native node-gyp builds and prepare scripts from git, file, and link dependencies. The new default setting, allowScripts: off, ensures that npm install will no longer automatically execute preinstall, install, or postinstall scripts from dependencies. Even packages with a binding.gyp file and no explicit install script are blocked, as npm previously ran an implicit node-gyp rebuild for such cases. Prepare scripts from git, file, and link dependencies are similarly blocked unless specifically allowed by the developer or project maintainer.

This change fundamentally shifts the npm ecosystem from a model of implicit trust—where any dependency could execute code during installation—to one of explicit trust, where only approved scripts are permitted to run. Developers must now explicitly allow scripts in their project configuration, creating a clear and auditable record of which dependencies are permitted to execute code during installation.

Key Innovations and Differentiators

While not a novel invention, this change represents the adoption of a security best practice already present in other package managers. The true innovation lies in the shift of npm’s control philosophy: execution of install scripts is no longer assumed, but must be explicitly approved, recorded, and reviewed. This approach removes a long-standing risk vector where malicious actors could hide harmful code in install scripts that would execute automatically when a developer or CI/CD pipeline installed a package.

By requiring explicit approval, npm v12 increases transparency and accountability in the dependency management process. This change also brings npm in line with recommendations from the OpenSSF Securing Software Repositories Working Group, which advocates for secure-by-default behaviors in package management tools.

Security Implications and Potential Risks

Disabling install scripts by default closes one of the most dangerous doors for supply chain attacks in the npm ecosystem. Attackers have historically leveraged postinstall scripts to execute arbitrary code on developer machines, exfiltrate sensitive data, propagate malware, or trigger worm-like attacks. High-profile incidents such as the Shai-Hulud worm, the Nx attack, and the long-standing event-stream compromise all exploited this automatic execution path.

However, this change does not eliminate all supply chain risks. Attackers may pivot to other methods, including embedding malicious code that runs at application runtime, compromising maintainer accounts, exploiting dependency confusion, typo-squatting, poisoning GitHub Actions workflows, or leveraging malicious transitive dependencies. The new default setting removes a major automatic execution path, but organizations must remain vigilant and continue to monitor for other forms of compromise.

Supply Chain and Third-Party Dependencies

The vast and interconnected nature of the npm ecosystem means that even indirect dependencies could previously execute scripts on developer machines without explicit approval. By blocking install scripts by default, npm v12 significantly reduces the risk of unintentional code execution from transitive dependencies. Nevertheless, organizations must continue to vet their dependencies, monitor for suspicious updates, and enforce strong security practices throughout their software supply chain.

Security Controls and Compliance Requirements

In addition to disabling install scripts by default, GitHub is introducing stricter authentication requirements, granular tokens with limited lifetimes, and trusted publishing mechanisms to further secure the npm ecosystem. These measures are designed to address token abuse, self-replicating malware, and other forms of supply chain compromise. For example, local publishing will require two-factor authentication (2FA), granular tokens will have a maximum lifetime of seven days, and trusted publishing will leverage provenance attestations and OIDC-based workflows.

These changes align with emerging regulatory requirements such as the EU Cyber Resilience Act and industry best practices for securing software repositories. By adopting these controls, organizations can enhance their compliance posture and reduce the risk of supply chain attacks.

Industry Adoption and Integration Challenges

The npm ecosystem has long relied on install scripts for legitimate purposes, including compiling native modules, downloading platform-specific binaries, generating files, and completing setup steps. The new default will require some projects to update their workflows and explicitly allow necessary scripts, which may cause short-term friction and compatibility challenges. However, this transition is essential for long-term security and aligns with the broader industry trend toward secure-by-default behaviors.

Projects that depend on install scripts must now document and approve these scripts in their configuration, ensuring that only trusted code is executed during installation. This change may require collaboration between developers, security teams, and project maintainers to update build processes and dependency management practices.

Vendor Security Practices and Track Record

GitHub has demonstrated a strong commitment to improving the security of the npm ecosystem in response to recent high-profile attacks. The company has removed compromised packages, blocked uploads with known indicators of compromise, and invested in trusted publishing and 2FA enforcement. GitHub’s approach emphasizes transparency, gradual rollout, and collaboration with the open source community to minimize disruption while maximizing security benefits.

The response to the Shai-Hulud attack in September 2025 exemplifies GitHub’s proactive stance. By quickly removing compromised packages and coordinating with maintainers, GitHub helped prevent further propagation of the worm and protected the broader ecosystem from ongoing attacks.

Technical Specifications and Requirements

With npm v12 and above, install scripts are disabled by default through the allowScripts: off setting. Developers must explicitly allow scripts for them to execute during installation. Additional security measures include trusted publishing, 2FA enforcement for package maintainers, granular tokens with short lifetimes, and support for provenance attestations and OIDC-based publishing. These technical controls provide a robust foundation for securing the npm supply chain and reducing the risk of automated attacks.

Security Best Practices

Security experts recommend disabling post-install scripts globally by setting npm’s ignore-scripts configuration, thereby preventing the execution of potentially harmful code during package installation. Organizations should also enforce strong authentication for maintainers, monitor for suspicious package updates, and use tools to assess the health and provenance of their dependencies. By adopting these best practices, organizations can further mitigate the risk of supply chain attacks and ensure the integrity of their software development processes.

Cyber Perspective

From a cyber risk perspective, the decision by GitHub to disable npm install scripts by default is a significant advancement in reducing the attack surface for software supply chain attacks in the JavaScript ecosystem. By requiring explicit approval for install scripts, organizations gain greater visibility and control over what code is executed during dependency installation. This not only helps prevent automated malware propagation but also creates an auditable record for compliance and incident response.

Attackers, however, are likely to adapt by targeting other weak points, such as runtime code execution, compromised maintainer accounts, or exploiting CI/CD pipelines. Defenders must continue to monitor for suspicious package updates, enforce strong authentication for maintainers, and use tools for dependency health and provenance verification. The market will likely see increased adoption of secure-by-default practices across other ecosystems and a growing demand for third-party risk management solutions that can continuously monitor and assess the security posture of open source dependencies.

About Rescana

Rescana provides advanced Third-Party Risk Management (TPRM) solutions designed to help organizations navigate the evolving landscape of software supply chain security. Our platform continuously monitors your third-party dependencies, assesses vendor security practices, and delivers actionable insights to reduce risk. Whether you are adapting to new security defaults or managing a complex ecosystem of open source and commercial software, Rescana empowers you to make informed decisions, ensure compliance, and protect your business from emerging threats.

We are happy to answer any questions at ops@rescana.com.