corepack: Newly published versions of package managers distributed from npm cannot be installed due to key id mismatch

This is probably related to #611.

When I try to install pnpm 10.1.0, I get the following error:

C:\Program Files\nodejs\node_modules\corepack\dist\lib\corepack.cjs:21535
  if (key == null || signature == null) throw new Error(`Cannot find matching keyid: ${JSON.stringify({ signatures, keys })}`);
                                              ^

Error: Cannot find matching keyid: {"signatures":[{"keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U","sig":"MEUCIQDlkgmNyZjT7KUY8AO6jH7Gs3fyiXG8nbTnuLbd8fOS2AIgXyJ6SaYhumMFzUYQAZPJGhsnlaD5N0X2MZsbG+eS/Xo="}],"keys":[{"expires":null,"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","keytype":"ecdsa-sha2-nistp256","scheme":"ecdsa-sha2-nistp256","key":"MFkwEwYHKoZIzj0CAQYIKoZIzj0DAQcDQgAE1Olb3zMAFFxXKHiIkQO5cJ3Yhl5i6UPp+IhuteBJbuHcA5UogKo0EWtlWwW6KSaKoTNEYL7JlCQiVnkhBktUgg=="}]}
    at verifySignature (C:\Program Files\nodejs\node_modules\corepack\dist\lib\corepack.cjs:21535:47)
    at installVersion (C:\Program Files\nodejs\node_modules\corepack\dist\lib\corepack.cjs:21882:7)
    at process.processTicksAndRejections (node:internal/process/task_queues:105:5)
    at async Engine.ensurePackageManager (C:\Program Files\nodejs\node_modules\corepack\dist\lib\corepack.cjs:22316:32)
    at async Engine.executePackageManagerRequest (C:\Program Files\nodejs\node_modules\corepack\dist\lib\corepack.cjs:22416:25)
    at async Object.runMain (C:\Program Files\nodejs\node_modules\corepack\dist\lib\corepack.cjs:23102:5)        

Node.js v22.13.0

I checked https://registry.npmjs.org/pnpm/10.1.0 and it contains

{
  "signatures": [
    {
      "keyid": "SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U",
      "sig": "MEUCIQDlkgmNyZjT7KUY8AO6jH7Gs3fyiXG8nbTnuLbd8fOS2AIgXyJ6SaYhumMFzUYQAZPJGhsnlaD5N0X2MZsbG+eS/Xo="
    }
  ]
}

which has the same key id distributed at https://registry.npmjs.org/-/npm/v1/keys. On the other hand, pnpm@10.0.0 (https://registry.npmjs.org/pnpm/10.0.0) has:

{
  "signatures": [
    {
      "sig": "MEUCIBhQnfDt9V8tw3FnrqHdMokyqJJtYX7HhR5NxvfggwP/AiEAiQQ74inA/JVI5IHN0piTLb2LhSUPJAkYYsGgM8DTrCI=",
      "keyid": "SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"
    }
  ]
}

which has the same key id in config.json. https://github.com/nodejs/corepack/blob/9dfbe180036d5e5b00c5c074dda5b44ce7a2c7be/config.json#L169

About this issue

  • Original URL
  • State: closed
  • Created 2 years ago
  • Reactions: 201
  • Comments: 64 (25 by maintainers)

Commits related to this issue

Most upvoted comments

We’re pinned to 9.15.4 and seeing this on CI, so it’s not limited to 10.1.0

The root cause of this issue also affects attempting to install pnpm@9.15.5 released Feb 2, 2025, since this release was also signed with the new npm registry key (SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U).

The same principle for the workaround can be used as for pnpm@10.1.0:

SHA_SUM=$(npm view pnpm@9.15.5 dist.shasum)
corepack install -g pnpm@9.15.5+sha1.$SHA_SUM
corepack use pnpm@9.15.5+sha1.$SHA_SUM

or

npm install -g corepack@latest

While using the latest-10 tag is not working right now, a pinned version can help to get your CI running 🐌

corepack prepare pnpm@10.0.0 --activate

Running npm i -g corepack@latest && corepack enable in the CI environment fixed the issue for me

Please don’t fix this issue until it has 100 thumbs ups, we’re livestreaming this at my company and I’d be loosing bets 🎬🎲

For those who are facing this issue like me, you can add COREPACK_INTEGRITY_KEYS=0 env var to skip the signature check.

Whilst this may work around the issue and is tempting, if there is an undisclosed vulnerability behind all of this as you speculate, then ignoring the key integrity might result in running evil code.

For those who are facing this issue like me, you can add COREPACK_INTEGRITY_KEYS=0 env var to skip the signature check.

Perhaps it would be good to lock this thread to contributors? Any solutions to the problem as it exists now have already been added to this thread, and further comments just add noise that serves no purpose as long as Corepack is not upgraded in actively supported versions of Node.js.

Aight guys it has 100 plus thumbs ups now. Lets fix this so @dargmuesli gets his monies.

One way to avoid setting COREPACK_INTEGRITY_KEYS=0, but be able to use the old corepack (prior to 0.31.0) is to pin fresh keys manually via

export COREPACK_INTEGRITY_KEYS="$(curl https://registry.npmjs.org/-/npm/v1/keys | jq -c '{npm: .keys}')"

or

export COREPACK_INTEGRITY_KEYS='{"npm":[{"expires":"2025-01-29T00:00:00.000Z","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","keytype":"ecdsa-sha2-nistp256","scheme":"ecdsa-sha2-nistp256","key":"MFkwEwYHKoZIzj0CAQYIKoZIzj0DAQcDQgAE1Olb3zMAFFxXKHiIkQO5cJ3Yhl5i6UPp+IhuteBJbuHcA5UogKo0EWtlWwW6KSaKoTNEYL7JlCQiVnkhBktUgg=="},{"expires":null,"keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U","keytype":"ecdsa-sha2-nistp256","scheme":"ecdsa-sha2-nistp256","key":"MFkwEwYHKoZIzj0CAQYIKoZIzj0DAQcDQgAEY6Ya7W++7aUPzvMTrezH6Ycx3c+HOKYCcNGybJZSCJq/fd7Qa8uuAKtdIkUQtQiEKERhAmE5lMMJhP8OkDOa2g=="}]}'

corepack will favor COREPACK_INTEGRITY_KEYS over builtin keys supplied in the config.json: https://github.com/nodejs/corepack/blob/a7cb9f603c32c4153d7c2e4af16d8af8b6b12863/sources/npmRegistryUtils.ts#L41-L43

I think there’s an issue here where you could have pinned corepack@0.30.0 and pnpm@9.15.4 (via package.json#/packageManager) to improve reproducibility, but Corepack still tries to fetch latest (pnpm@9.15.5) and errors out on the new key.

This can be worked around by setting COREPACK_DEFAULT_TO_LATEST=0, but I’m unsure about that proliferating given the sparse README and some of the discussion in #134. Should fetching latest gracefully fail in this scenario for forward compatibility?

This might be a dumb question, but who screwed up here? Was this just a case of all of us not correctly configuring our CI pipelines and being vulnerable to some latent “behavior” of corepack/npm, or was something actively changed to “cause” this? I ask not to place blame, but to better understand what happened for future reference.

Probably this solution will be more cautious than disabling the integrity check of the keys. Simply instruct to install manually the latest version of corepack using npm:

# Disable corepack integrity keys until this is solved: https://github.com/nodejs/corepack/issues/612
npm i -g corepack@latest

In a Dockerfile:

# Disable corepack integrity keys until this is solved: https://github.com/nodejs/corepack/issues/612
RUN npm i -g corepack@latest

GitHub Actions Runner using Setup Node.

Github Workflow runs using PNPM action are not affected.

If you are installing PNPM manually, run this before setup-node:

# Action workflow job.step:
- name: Enable Corepack
   run: |
     corepack enable
     corepack prepare pnpm@latest-9 --activate

Local PNPM (or Yarn) version: If you recently updated a version in your packageManager field of package.json, probably it failed. It can be solved with this command too, running it in your terminal:

npm i -g corepack@latest

I experienced the same key id mismatch issue with pnpm v8.x, specifically 8.10.2

Upgrading corepack manually via npm install -g corepack@0.31.0 fixed it for me.

@MitchDG04

yeah i read the posts but i did not get why corepack 0.31.0 is not affected, it has the new keys?

Correct. corepack@0.31.0 includes the updated set of keys from https://registry.npmjs.org/-/npm/v1/keys

Image

We no longer support Node.js 21.x because it’s EOL, we still support Node.js 18.x and 20.x because they are not. Dropping support just means we are no longer testing on that version, and we won’t accept bug reports for that version, but there’s no reason Corepack 0.31.0 would break with Node.js 21.x. There won’t be a 0.30.1 version, please don’t use an EOL version of Node.js and upgrade to latest Corepack if you can.

@sapphi-red

There has been a new release corepack@0.31.0 with updated npm keys.

After a manual install:

npm install -g corepack@latest

I was then able to execute the following successfully:

corepack use pnpm@10.1.0
  • I don’t know the reason for the two different keys and probably it should be raised to https://www.npmjs.com/support for clarification / remediation.

I’ve sent a message there linking this and that issue 👍

@tskimmett

This might be a dumb question, but who screwed up here? Was this just a case of all of us not correctly configuring our CI pipelines and being vulnerable to some latent “behavior” of corepack/npm, or was something actively changed to “cause” this? I ask not to place blame, but to better understand what happened for future reference.

This was not caused by end-user error.

Try this as a workaround:

SHA_SUM=$(npm view pnpm@10.1.0 dist.shasum)
corepack install -g pnpm@10.1.0+sha1.$SHA_SUM

https://registry.npmjs.org/-/npm/v1/keys should now be returning two keys. During key rotation the old one was omitted by mistake and has since been re-added. CDN caching will of course take a little time to catch up but both the SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA key (which was used to sign tarballs up until last week) and the SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U key (which is being used going forward) are both in that endpoint, which should allow folks to verify signatures again.

I would recommend against curl the registry keys or the shasum; though it can unblock you, you have to understand you are trusting HTTPS when doing that, and you might as well disable signature verification at this point (the signature verification is a redundant security mechanism that only makes sense to do if you are not fetching the keys via HTTPS).

Ideally the workaround would be to use latest version of Corepack. However, if that’s not an option, you can either:

  • If you trust HTTPS, set COREPACK_INTEGRITY_KEYS to 0 to skip the signature verification. Corepack will still verifies the integrity of the download by comparing the shasum with the one found in the registry package metadata.
  • If you don’t trust HTTPS, set COREPACK_INTEGRITY_KEYS to {"npm":[{"expires":"2025-01-29T00:00:00.000Z","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","keytype":"ecdsa-sha2-nistp256","scheme":"ecdsa-sha2-nistp256","key":"MFkwEwYHKoZIzj0CAQYIKoZIzj0DAQcDQgAE1Olb3zMAFFxXKHiIkQO5cJ3Yhl5i6UPp+IhuteBJbuHcA5UogKo0EWtlWwW6KSaKoTNEYL7JlCQiVnkhBktUgg=="},{"expires":null,"keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U","keytype":"ecdsa-sha2-nistp256","scheme":"ecdsa-sha2-nistp256","key":"MFkwEwYHKoZIzj0CAQYIKoZIzj0DAQcDQgAEY6Ya7W++7aUPzvMTrezH6Ycx3c+HOKYCcNGybJZSCJq/fd7Qa8uuAKtdIkUQtQiEKERhAmE5lMMJhP8OkDOa2g=="}]}.

@MitchDG04

so what solution was used to fix the issue?

There is not one solution that fits every environment. You’ll have to read through the posts in this thread to find different suggestions. At this time there is not a summary of what to do.

One solution is to update Corepack:

npm install -g corepack@latest

however that cannot be used in every situation.

One way to avoid setting COREPACK_INTEGRITY_KEYS=0, but be able to use the old corepack (prior to 0.31.0) is to pin fresh keys manually

Thanks for this @auvred ~ seems like the best option if you don’t want to disable the signature check AND if you don’t want to sudo npm i -g corepack, since sudo is needed to do this in CircleCI docker images but doesn’t come installed

As mentioned by @DaveEvans-Thalamos in https://github.com/nodejs/corepack/issues/612#issuecomment-2615158927 ⬆, the keys can be ignored as a workaround, for example in a bash shell:

COREPACK_INTEGRITY_KEYS=0 corepack use pnpm@10.1.0

I ended up installing pnpm@10.0.0 globally (can be done with their one-liner / npm install --global pnpm@10.0.0 / mise / etc.). New v10 has manage-package-manager-versions enabled by default, which substitutes corepack. When inside a project directory, globally installed pnpm v10 checks package.json → packageManager and automatically substitutes itself with the exact version specified.

So unless you rely on corepack to manage Yarn as well, it is no longer needed. The only exception I see is CI when you can avoid two pnpm downloads with one, via corepack enable.

@FelixBlaisThon

Is there a way to explicitly target corepack 0.31.0 (the one with the key fix) without bumping to ode 23 (which is not LTS yet)

I am on Node v22.11.0

In GitHub Actions I used the following:

      - name: Set alternate npm integrity keys
        run: |
          echo COREPACK_INTEGRITY_KEYS="$(curl https://registry.npmjs.org/-/npm/v1/keys | jq -c '{npm: .keys}')" >> $GITHUB_ENV

which works for any version of Node.js.

I can confirm that the same issue happens for us as well in our GitLab Pipeline:

$ corepack enable && corepack prepare --activate
Preparing pnpm@10.1.0 for immediate activation...
Internal Error: Cannot find matching keyid: {"signatures":[{"keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U","sig":"MEUCIQDlkgmNyZjT7KUY8AO6jH7Gs3fyiXG8nbTnuLbd8fOS2AIgXyJ6SaYhumMFzUYQAZPJGhsnlaD5N0X2MZsbG+eS/Xo="}],"keys":[{"expires":null,"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","keytype":"ecdsa-sha2-nistp256","scheme":"ecdsa-sha2-nistp256","key":"MFkwEwYHKoZIzj0CAQYIKoZIzj0DAQcDQgAE1Olb3zMAFFxXKHiIkQO5cJ3Yhl5i6UPp+IhuteBJbuHcA5UogKo0EWtlWwW6KSaKoTNEYL7JlCQiVnkhBktUgg=="}]}
    at verifySignature (/usr/lib/node_modules/corepack/dist/lib/corepack.cjs:21535:47)
    at installVersion (/usr/lib/node_modules/corepack/dist/lib/corepack.cjs:21882:7)
    at process.processTicksAndRejections (node:internal/process/task_queues:105:5)
    at async Engine.ensurePackageManager (/usr/lib/node_modules/corepack/dist/lib/corepack.cjs:22316:32)
    at async PrepareCommand.execute (/usr/lib/node_modules/corepack/dist/lib/corepack.cjs:23025:27)
    at async PrepareCommand.validateAndExecute (/usr/lib/node_modules/corepack/dist/lib/corepack.cjs:19835:22)
    at async _Cli.run (/usr/lib/node_modules/corepack/dist/lib/corepack.cjs:20772:18)
    at async Object.runMain (/usr/lib/node_modules/corepack/dist/lib/corepack.cjs:23097:19)

@MikeMcC399

In GitHub Actions I used the following:

  - name: Set alternate npm integrity keys
    run: |
      echo COREPACK_INTEGRITY_KEYS="$(curl https://registry.npmjs.org/-/npm/v1/keys | jq -c '{npm: .keys}')" >> $GITHUB_ENV

which works for any version of Node.js.

It works! Thanks a lot! 👍

JavaScript GitHub Actions are also impacted where Corepack is used inside an action. It’s not possible to update Corepack inside the action. It needs Node.js to distribute a new version of Corepack and GitHub Actions needs to set this version corresponding to the runs.using parameter.

@BeyondEvil

latest won’t work for us as this our production build.

So does that mean you can’t use npm install -g corepack@0.31.0 either?

But thanks for taking the time, really appreciate it! 🙏

You’re very welcome! I’m just trying to work out how to use Corepack for my own purposes and seem to have got caught up in events here!

@BeyondEvil

Did you try changing to:

RUN npm install -g corepack@latest RUN corepack enable && corepack prepare --activate Sorry, I’m not familiar in-depth with the deprecated commands, but I believe that they should still work even if the local documentation has been dropped for them.

latest won’t work for us as this our production build. But thanks for taking the time, really appreciate it! 🙏

We’ll stick with prepare --activate until we can bump the version to v.0.31.0

@BeyondEvil

Did you try changing to:

RUN npm install -g corepack@latest
RUN corepack enable && corepack prepare --activate

Sorry, I’m not familiar in-depth with the deprecated commands, but I believe that they should still work even if the local documentation has been dropped for them.

If you are unable to update to corepack@0.31.0 you can also use the package manager name with a hash. The following will work with Corepack 0.27.0 - 0.30.0 (and with 0.31.0 but not necessary for this version):

corepack install -g pnpm@9.15.5+sha1.cb1f6372ef64e2ba352f2f46325adead1c99ff8f
corepack install -g pnpm@10.1.0+sha1.ab7948c89104fdd3fc88b5b391fa4b73fd800631
corepack install -g npm@11.1.0+sha1.dba08f7d0f5301ebedaf968b4f74b2282f97a750

Edit: This doesn’t help so much in a CI workflow, where there is no cache established 🙁

@sapphi-red

I assume the signatures are generated by npm registry and pnpm has no control over it. I’ll change the issue name to specifically 10.1.0, but I believe any versions that are published from now on will be affected, as I think it’s caused by npm registry’s key rotation. I wonder if the npm registry had to rotate the key immediately (and not in a gradual manner) due to some vulnerability discovery.

@sapphi-red

I can reproduce this issue on Windows 11 and Ubuntu 24.04.1 LTS with

corepack use pnpm@10.1.0

Cannot find matching keyid


corepack use pnpm@10.0.0

has no issue, so you might change your subject to be specifically 10.1.0 instead of the generic “Newly published versions”.

Also, this should probably be reported to https://github.com/pnpm/pnpm/issues cc: @zkochan