pnpm 12.26.0 shipped on 2 December 2026 with a three-line Security section. The short version: until this release, a package whose payload was "bin": {"sh": "./anything.js"} could become the interpreter for some other package's postinstall, because select_shell in the Rust executor spawned a bare sh and let the script's own PATH resolve it. 12.26.0 pins the shell through a cfg!-selected POSIX_SHELL constant, and pnpm doctor reports which shell your tree is actually using.
The shell was a PATH lookup
The release notes put it in one bullet: "Scripts now run with /bin/sh by default outside Windows, or /system/bin/sh on Android. A dependency that ships a bin named sh can no longer replace the shell that runs other packages' lifecycle scripts" (pnpm 12.26.0 release notes).
The change is one value. Commit 333c487, "fix(executor): run scripts with an absolute /bin/sh by default" (PR #18606, 1 December 2026), edits select_shell() in pnpm/crates/executor/src/shell.rs so that program: PathBuf::from("sh") becomes program: PathBuf::from(POSIX_SHELL), with POSIX_SHELL resolving to /system/bin/sh on Android and /bin/sh elsewhere. The args stayed ["-c"]. zkochan's commit message describes the old behaviour without euphemism: with no configured scriptShell, scripts "were started through a bare sh, and the spawn resolved it against the script's own PATH".
That PATH is documented, and it is the point. pnpm's pnpm run documentation states that in addition to the shell's pre-existing PATH, pnpm run includes node_modules/.bin in the PATH given to scripts, plus the workspace root's .bin in a monorepo. So the lookup for sh started in a directory whose contents are decided by your dependency graph.
The proof shipped with the fix. The same commit adds default_shell_ignores_a_dependency_bin_named_sh to crates/executor/src/lifecycle/tests.rs: it plants an executable sh in node_modules/.bin and asserts the script does not run through it. The existing unit test was renamed from posix_default_is_sh_minus_c to posix_default_is_absolute_sh_minus_c. Windows was never affected; the shell there still comes from ComSpec. Approval gates measuring the wrong object is a recurring shape in this tooling, and npm's own one has at least three states where it reads green while a build runs.
Who gets to be sh
Everything the ecosystem built in 2026 to control install-time execution gates the script: allowBuilds (which replaced onlyBuiltDependencies in v11), strictDepBuilds to fail CI when an unreviewed build script appears, minimumReleaseAge to keep fresh versions out for a day. Cooldowns and allow-lists are worth exactly as much as the code paths that consult them, which is why cargo's min-publish-age being ignored by cargo install mattered more than its changelog line suggested.
A package that ships only a bin named sh has no lifecycle script. There is nothing for allowBuilds to review, nothing for strictDepBuilds to fail on, and no build-script prompt. It needs one thing: to be installed next to a package you did approve. Then it receives that approved package's postinstall line on -c. The build settings page says packages absent from allowBuilds "are disallowed by default and are treated as unreviewed", and no pnpm doc claims bin-linking consults that list. The shipped fix implies it does not, because otherwise an unreviewed package could never have put sh on the path in the first place.
The live edge after upgrading is the override. pnpm's other settings page says a bare command name such as bash "is still looked up on PATH". A hand-written scriptShell: bash re-arms the exact lookup 333c487 removed, on a version that reports itself as patched.
One row I could not settle: which .bin directories are on PATH when a dependency's own install or postinstall runs under the default isolated node-linker, specifically whether that package's virtual-store node_modules/.bin, holding its transitive dependencies' bins, is included. No pnpm page states it, and the maintainers' test covers the project-level .bin only. The command that settles it: add a dependency shipping a bin named sh, give a second package a postinstall of command -v sh > /tmp/which-sh, approve only the second, install under 12.25.1, and read the file.
Two runs, one value changed
Version strings are not evidence. On Node's Brotli patch day in October I checked my own box with the decoder probe out of Node's test/parallel/test-zlib-invalid-input.js and read the error code (-17 patched, -9 unpatched) rather than node -v; an EOL Node 20 box answered errno=-9, which is the same reason the version string lies about php2shell and the Brotli RCE. Same discipline here. Build a fixture and run it twice.
shadow/package.json ships no script at all:
{
"name": "shadow",
"version": "1.0.0",
"bin": { "sh": "./sh.js" }
}
sh.js writes hijacked.txt and exits 0. victim/package.json carries "postinstall": "echo ran > ran.txt", and the root lists victim (only victim) in pnpm.allowBuilds. Then change one value, the packageManager pin:
corepack use pnpm@12.25.1
rm -rf node_modules hijacked.txt ran.txt
pnpm install --store-dir /tmp/store-a
ls hijacked.txt ran.txt
hijacked.txt
ls: cannot access 'ran.txt': No such file or directory
corepack use pnpm@12.26.0
rm -rf node_modules hijacked.txt ran.txt
pnpm install --store-dir /tmp/store-b
ls hijacked.txt ran.txt
ls: cannot access 'hijacked.txt': No such file or directory
ran.txt
The approved package's script ran either way. On 12.25.1 it ran inside a process that an unapproved dependency supplied.
The archive ended twice
The second Security bullet is a different defect in the same release, and it is a parser disagreement. Commit 6187bbe, "fix(tarball): end the archive at zero blocks around an undecodable header" (PR #18603, 1 December 2026), patches the vendored Rust tar reader in vendor/tar to agree with node-tar 7.5.22's Parser.
What I read out of that diff: node-tar builds each header inside a try. A block whose number field fails to decode throws, node-tar skips the block without clearing its zero-block state, and the next zero block terminates the archive. pnpm's reader cleared saw_null_block on every non-zero block, so it kept reading and extracted whatever followed. agreement::read_header now returns a three-variant HeaderRead (Header, ChecksumFailure, Undecodable), and archive.rs resets saw_null_block only for ChecksumFailure. The two new tests encode the distinction precisely: ends_at_two_zero_blocks_around_a_header_node_tar_cannot_decode and reads_on_after_zero_blocks_around_a_header_with_a_bad_checksum. A bad checksum is a damaged header worth stepping over. An undecodable one means the stream stopped making sense, and node-tar's answer is to stop with it.
pnpm has been working this same Rust-versus-node seam from the other end all year; the publish side produced four packlist fixes in six days.
What your scanner read instead
Here is the consequence nobody has connected publicly. One published tarball could yield two installed file sets: the short one for everything reading through node-tar (npm itself, and the JS tooling that most scanners, SBOM generators and manual "what is actually in this package" reviews are built on) and the long one for pnpm. A 24-hour cooldown and a scanner gate do not buy much when the scanner and the installer disagree about the file list. After 12.26.0 the agreement is enforced in code, one way.
That makes a diff a one-time audit, and it has a hard precondition: a fresh --store-dir. Content already extracted into the content-addressable store is not re-read, and the store has its own history of holding onto state you assumed was recomputed, as pnpm's umask fix in 12.16.0 showed.
The honest counterpoint: neither bullet carries a CVE, and both require a hostile package already resolved into your tree, which is a position that offers an attacker other options. What raises this above changelog trivia is that two of the controls teams actually bought into this year, approval lists and scanner review, were blind to it by construction. One gated scripts while the attack supplied an interpreter; the other read a different archive than the installer did.
What to change before your store warms up
- Upgrade to 12.26.0 and stop there if you are on defaults. The hardening is the default path, and nothing needs configuring to get it.
- Grep your configs for
scriptShelltoday. If the value is a bare name (bash,zsh,sh), make it absolute (/bin/bash). Per pnpm's settings docs, a bare name is still resolved on PATH, so the fix does not reach you. - Confirm by probe, not by inventory spreadsheet.
pnpm doctorhas carried a Script shell check since v12.23.0, resolving the symlink behind the shell:✓ Script shell: scripts run in /bin/sh (/bin/bash), package executables in /bin/sh (/bin/bash)(pnpm doctor docs). - Hunt for the name across checked-out repos:
find . -path '*/node_modules/.bin/sh'. Any hit is a package already claiming the interpreter slot, andstrictDepBuildswill never have mentioned it. - Treat
allowBuildsin your threat model as covering lifecycle scripts only. Bin-linking is a separate pipeline and does not consult the list. - Before your CI store repopulates, install one or two critical dependencies at the same version into a throwaway
--store-diron 12.26.0, anddiff -rqthe result against a 12.25.1 tree. Files that disappear are files npm never installed and your scanner never saw.
Comments
Be the first to comment.