Skip to content

chore: upgrade to NPM v12 - #1121

Open
coderbyheart wants to merge 1 commit into
sagafrom
npm-v12
Open

chore: upgrade to NPM v12#1121
coderbyheart wants to merge 1 commit into
sagafrom
npm-v12

Conversation

@coderbyheart

@coderbyheart coderbyheart commented Aug 5, 2026

Copy link
Copy Markdown
Member

Require npm >=12.0.2 <13 for this project (Node.js stays at >=22.2.0). It is enforced via
check-node-version on npm install and npm ci.

Why

npm v12 turns three code-execution paths off by default — most notably the
unauthorized execution of install scripts, which is the primary vector for
supply-chain attacks via compromised dependencies
(GitHub changelog):

  • allowScripts now defaults to off, so npm install no longer executes
    preinstall, install or postinstall scripts from dependencies unless they
    are explicitly allowed in package.json. This also covers prepare scripts
    from git, file and link dependencies.
  • --allow-git now defaults to none, which closes a code-execution path
    where a git dependency's .npmrc could override the git executable, even with
    --ignore-scripts.
  • --allow-remote now defaults to none, blocking dependencies from remote
    URLs such as HTTPS tarballs.

Pinning engines.npm to >=12.0.2 <13 and failing the install when it is not
met means these protections cannot be silently bypassed by running an older npm
locally or in CI.

How

  • engines.npm is set to >=12.0.2 <13. engines.node is left untouched.
  • check-node-version --package runs from the prepare script, which npm
    executes on npm install and npm ci.
  • CI installs the npm version declared in engines.npm through the new
    .github/actions/install-npm composite action, added after each
    actions/setup-node step.

The check is skipped during npm publish and npm pack, because semantic-release bundles its own npm (@semantic-release/npm depends on npm@^11.6.2) and runs the publish with that version rather than the one installed in CI.

Require npm >=12.0.2 <13, enforced via check-node-version on npm install and
npm ci. CI installs the version from engines.npm via the new
.github/actions/install-npm composite action.

The motivation is that npm v12 turns three code-execution paths off by
default, most notably the unauthorized execution of install scripts:

- allowScripts now defaults to off, so npm install no longer executes
  preinstall, install or postinstall scripts from dependencies unless they
  are explicitly allowed in package.json. This also covers prepare scripts
  from git, file and link dependencies.
- --allow-git now defaults to none, which closes a code-execution path where
  a git dependency's .npmrc could override the git executable, even with
  --ignore-scripts.
- --allow-remote now defaults to none, blocking dependencies from remote
  URLs such as HTTPS tarballs.

See
https://github.blog/changelog/2026-06-09-upcoming-breaking-changes-for-npm-v12/

The check is skipped during npm publish and npm pack, because
semantic-release bundles its own npm (@semantic-release/npm depends on
npm@^11.6.2) and runs the publish with that version rather than the one
installed in CI.

The Node.js requirement is left unchanged.
@socket-security

Copy link
Copy Markdown

@socket-security

Copy link
Copy Markdown

Warning

Review the following alerts detected in dependencies.

According to your organization's Security Policy, it is recommended to resolve "Warn" alerts. Learn more about Socket for GitHub.

Action Severity Alert  (click "▶" to expand/collapse)
Warn High
Obfuscated code: npm aws-cdk-lib is 90.0% likely obfuscated

Confidence: 0.90

Location: Package overview

From: package-lock.jsonnpm/@bifravst/http-api-mock@2.1.465npm/aws-cdk-lib@2.260.0

ℹ Read more on: This package | This alert | What is obfuscated code?

Next steps: Take a moment to review the security alert above. Review the linked package source code to understand the potential risk. Ensure the package is not malicious before proceeding. If you're unsure how to proceed, reach out to your security team or ask the Socket team for help at support@socket.dev.

Suggestion: Packages should not obfuscate their code. Consider not using packages with obfuscated code.

Mark the package as acceptable risk. To ignore this alert only in this pull request, reply with the comment @SocketSecurity ignore npm/aws-cdk-lib@2.260.0. You can also ignore all packages with @SocketSecurity ignore-all. To ignore an alert for all future pull requests, use Socket's Dashboard to change the triage state of this alert.

Warn High
Obfuscated code: npm execa is 90.0% likely obfuscated

Confidence: 0.90

Location: Package overview

From: package-lock.jsonnpm/@swc/cli@0.8.1npm/execa@9.6.1

ℹ Read more on: This package | This alert | What is obfuscated code?

Next steps: Take a moment to review the security alert above. Review the linked package source code to understand the potential risk. Ensure the package is not malicious before proceeding. If you're unsure how to proceed, reach out to your security team or ask the Socket team for help at support@socket.dev.

Suggestion: Packages should not obfuscate their code. Consider not using packages with obfuscated code.

Mark the package as acceptable risk. To ignore this alert only in this pull request, reply with the comment @SocketSecurity ignore npm/execa@9.6.1. You can also ignore all packages with @SocketSecurity ignore-all. To ignore an alert for all future pull requests, use Socket's Dashboard to change the triage state of this alert.

Warn High
Obfuscated code: npm strtok3 is 90.0% likely obfuscated

Confidence: 0.90

Location: Package overview

From: package-lock.jsonnpm/@swc/cli@0.8.1npm/strtok3@10.3.5

ℹ Read more on: This package | This alert | What is obfuscated code?

Next steps: Take a moment to review the security alert above. Review the linked package source code to understand the potential risk. Ensure the package is not malicious before proceeding. If you're unsure how to proceed, reach out to your security team or ask the Socket team for help at support@socket.dev.

Suggestion: Packages should not obfuscate their code. Consider not using packages with obfuscated code.

Mark the package as acceptable risk. To ignore this alert only in this pull request, reply with the comment @SocketSecurity ignore npm/strtok3@10.3.5. You can also ignore all packages with @SocketSecurity ignore-all. To ignore an alert for all future pull requests, use Socket's Dashboard to change the triage state of this alert.

View full report

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant