Tutorials

pnpm 11 Lockfile Vulnerability: How to Secure Your CI Pipeline

A modified pnpm lockfile can redirect a dependency installation to an attacker-controlled archive under specific conditions. The fix is already available, but CI pipelines using older pnpm 11 versions remain exposed.

A pull request changes pnpm-lock.yaml. The dependency versions look familiar, package.json hasn’t changed, and CI runs its usual installation command:

pnpm install --frozen-lockfile

The lockfile is consistent with the project configuration. Installation proceeds.

But what if one of the locked packages no longer points to the archive published by its legitimate maintainer?

On November 28, 2026, pnpm maintainers published security advisory GHSA-vhr2-359g-qgjm, rated High.

The vulnerability affects certain pnpm 11 releases and allows a specially crafted lockfile to bypass verification of where a dependency archive comes from.

Under the conditions described in the advisory, an attacker who can modify pnpm-lock.yaml may cause CI to download an attacker-controlled package archive and execute its lifecycle scripts.

The attacker does not need to publish that archive to the npm registry.

The good news is that the fix already exists.

The affected verification logic was corrected in pnpm 11.28.5, released on October 6, 2026. November 28 marks the public disclosure of the vulnerability, not the release of a new patch.

Which pnpm versions are affected?

The official advisory identifies the following range:

pnpm version Status
Earlier than 11.5.3 Not included in this advisory’s affected range
11.5.3–11.28.4 Vulnerable
11.28.5 and newer in the 11.x line Patched
pnpm 12 Not affected by this particular vulnerability

Check your installed version:

pnpm --version

For example, if the output is:

11.25.0

that version falls within the affected range.

But the version installed in your terminal is not necessarily the one used by CI.

Check package.json as well:

{
  "packageManager": "[email protected]"
}

A project can declare a particular pnpm version through packageManager, while GitHub Actions or a local developer machine uses a different executable.

Both need attention.

The practical recommendation is to upgrade to a patched release and ensure that CI uses it consistently.

You do not need to migrate to pnpm 12 solely to address this advisory.

How a lockfile bypasses package verification

Normally, pnpm uses information from the registry to verify that a dependency resolves to an expected package archive.

This matters because an archive’s integrity hash alone does not establish who supplied it.

An attacker who controls an archive can calculate its hash and insert that value into a modified lockfile.

The hash may then correctly describe the malicious archive, even though the archive does not belong to the legitimate package.

The additional verification is supposed to prevent this type of substitution.

The newly disclosed vulnerability concerns a structure called variations.

pnpm uses variation resolutions for certain platform-specific package arrangements.

In the affected releases, two parts of the verification process handled this structure differently.

The first check, isRegistryShapedResolution, accepted a variations wrapper containing supported inner resolution shapes.

The second check, responsible for validating registry tarball URLs, examined the outer resolution’s type.

Because the outer object had type: variations, the verifier treated it as a resolution type that did not require the ordinary registry-tarball check.

It did not inspect the archive URLs inside the variants.

That created a gap: a resolution could pass structural validation without having its underlying package archive checked against the expected registry source.

The vulnerable behavior was in pnpm’s interpretation of the lockfile, not in JavaScript’s package installation format itself.

Why allowBuilds matters

The attack described in the advisory has another requirement.

The project must permit lifecycle scripts for the package being impersonated.

pnpm 11 uses an allowBuilds configuration to control which dependencies may execute installation scripts.

For example, a pnpm-workspace.yaml file might contain:

allowBuilds:
  esbuild: true
  core-js: false

This allows build scripts for esbuild while disallowing them for core-js.

Such approvals can be necessary for dependencies that require installation-time preparation.

They are not inherently suspicious.

But if a vulnerable pnpm version mistakenly accepts an attacker-controlled archive under the identity of an approved package, the approval can apply to code that was never published by that package’s legitimate maintainer.

The malicious archive can then execute a lifecycle script, such as postinstall, with the privileges available to the installation process.

That is the dangerous connection between the lockfile verification bug and allowBuilds.

It is also why this advisory should not be described as a vulnerability that automatically executes arbitrary code whenever any lockfile changes.

The version, lockfile structure, permitted build scripts, and installation conditions all matter.

Why —frozen-lockfile does not protect against this

The name sounds reassuring:

pnpm install --frozen-lockfile

And the option is useful.

It prevents pnpm from updating the lockfile during installation and fails when the lockfile needs changes to remain consistent with the project manifest.

For reproducible CI builds, that is desirable.

But a frozen lockfile is not necessarily a trustworthy lockfile.

If an attacker has already modified pnpm-lock.yaml, freezing it simply instructs pnpm to use that committed dependency resolution without rewriting it.

The security checks still need to determine whether its contents are legitimate.

In affected pnpm versions, the variations verification gap could let a malicious archive pass those checks.

Consequently, --frozen-lockfile should remain part of the CI workflow, but it is not a substitute for upgrading pnpm.

Update pnpm in GitHub Actions

A straightforward correction is to explicitly select a patched version.

For example, the following workflow uses pnpm 11.28.13, which is newer than the minimum fixed version:

name: CI

on:
  push:
    branches: [main]
  pull_request:

permissions:
  contents: read

jobs:
  test:
    runs-on: ubuntu-latest

    steps:
      - uses: actions/checkout@v4

      - uses: pnpm/action-setup@v4
        with:
          version: 11.28.13

      - uses: actions/setup-node@v4
        with:
          node-version: "22"
          cache: "pnpm"

      - name: Verify pnpm version
        run: pnpm --version

      - name: Install dependencies
        run: pnpm install --frozen-lockfile

      - name: Run tests
        run: pnpm test

The important part is the explicit pnpm version.

GitHub Actions should not accidentally use an older executable because it happens to be available in the environment.

The version check also makes it easier to inspect the toolchain used in a particular run.

If package.json contains an older packageManager value, update that declaration too:

{
  "packageManager": "[email protected]"
}

Keep the rest of the existing package.json unchanged.

Check that the local development environment, CI workflow, and repository configuration agree on the intended version.

The workflow above is a general example. Larger projects may need additional steps for builds, type checking, or platform-specific tests.

For stricter supply-chain controls, GitHub Actions can also be pinned to reviewed commit SHAs rather than moving version tags.

Protect CI from untrusted pull requests

Upgrading pnpm fixes the specific lockfile verification vulnerability.

It does not eliminate every risk associated with running untrusted code in CI.

A pull request can contain changes to source files, scripts, build configuration, and dependencies.

Those changes may be executed during a CI run.

GitHub normally restricts secrets and token permissions for workflows triggered by pull requests from forks.

That restriction is significant. It means an ordinary fork pull request does not automatically receive production credentials.

However, the restrictions can be weakened by workflow configuration.

In particular, pull_request_target runs with the security context of the base repository.

Checking out and executing untrusted pull request code inside a privileged pull_request_target workflow can expose credentials or permit other unwanted actions.

For CI that processes external contributions, use a separate, minimally privileged test environment.

Keep deployment credentials and production secrets out of jobs that install dependencies or execute code from untrusted pull requests.

Do not let a successful test workflow automatically grant an unreviewed pull request access to publishing credentials.

Even without production secrets, malicious code executed on a runner can inspect available files, interfere with the build, or manipulate generated artifacts.

The pnpm vulnerability is one particular path to that situation.

Should you disable lifecycle scripts?

One possible defense is to prevent dependency installation scripts from running.

For example:

pnpm install --frozen-lockfile --ignore-scripts

This prevents the installation from executing dependency lifecycle scripts.

It can reduce exposure when working with an untrusted dependency graph.

But some packages legitimately require installation steps to prepare native binaries or other build artifacts.

Disabling scripts can therefore cause otherwise valid projects to fail.

It also does not make arbitrary source code or subsequent build commands safe to execute.

For this advisory, upgrading pnpm is the direct fix.

Restricting lifecycle scripts can provide additional protection where the project permits it.

The two measures address different concerns and should not be treated as interchangeable.

Review lockfile changes, not just package.json

A final lesson concerns code review.

Developers often inspect package.json carefully while treating pnpm-lock.yaml as an automatically generated file.

In most cases, that makes sense. Lockfiles contain a large amount of repetitive dependency metadata.

But this advisory demonstrates that lockfile contents can influence where code is downloaded from.

When a pull request modifies the lockfile, unexpected changes deserve attention.

For example, investigate unfamiliar archive URLs, unusual resolution structures, and dependency changes that do not correspond to the intended package updates.

The presence of variations alone does not prove that a lockfile is malicious. It is a legitimate structure used by pnpm.

The problem described in GHSA-vhr2-359g-qgjm was that certain values inside it could escape verification in affected versions.

A reviewer should not need to reconstruct every dependency manually. The package manager is responsible for validating what it installs.

But code review still matters, particularly when changes introduce new executable dependencies or modify dependency build permissions.

The correction in pnpm 11.28.5 closes the reported verification gap.

Projects that already use patched versions do not need a second fix for this particular advisory.

Projects still using 11.5.3 through 11.28.4 should update their package manager before processing untrusted lockfiles.

The vulnerability became public on November 28, but the patch has been available since October 6.

That distinction matters because the immediate task is not to wait for a fix.

It is to verify which pnpm executable your local environment and CI actually use, and replace vulnerable versions that may still be running.

External Sources used for this article

Related Articles

View all →