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)
Links to this issue
Commits related to this issue
- Fix pnpm test Due to https://github.com/nodejs/corepack/issues/612 we had to pin `pnpm` to 10.0.0 in `sdk/nodejs/tests/runtime/install-package-tests.ts` — committed to pulumi/pulumi by julienp 2 years ago
- fix(ci): pin pnpm to 10.0.0 see https://github.com/nodejs/corepack/issues/612 — committed to lblod/ember-rdfa-editor by abeforgit 2 years ago
- fix(ci): pin pnpm to 10.0.0 see https://github.com/nodejs/corepack/issues/612 — committed to lblod/ember-rdfa-editor by abeforgit 2 years ago
- ci(release): force install of latest corepack due to https://github.com/nodejs/corepack/issues/612 — committed to form8ion/.github by travi 2 years ago
- Make mx-tester have consistent use of yarn. (#710) CI was broken because of this shite https://github.com/nodejs/corepack/issues/612 — committed to the-draupnir-project/Draupnir by Gnuxie 2 years ago
- ci(corepack): install the latest corepack version so new npm signing key is available related to https://github.com/nodejs/corepack/issues/612 — committed to semantic-release/semantic-release by travi 2 years ago
- pnpm 9.15.5 see https://github.com/nodejs/corepack/issues/612 — committed to lumphammer/gumshoe-fvtt by n3dst4 2 years ago
- Upgrade pnpm and apply https://github.com/nodejs/corepack/issues/612 workaround — committed to stephane-klein/sklein-pkm-engine by stephane-klein 2 years ago
- ci: skip corepack signature verification Resolves https://github.com/nodejs/corepack/issues/612 temporality — committed to vue-macros/vue-macros by sxzz 2 years ago
- Add explicit pnpm version to avoid corepack crash https://github.com/nodejs/corepack/issues/612 — committed to GTBitsOfGood/juno by UZ9 2 years ago
- Add explicit pnpm version to avoid corepack crash (#153) https://github.com/nodejs/corepack/issues/612 — committed to GTBitsOfGood/juno by UZ9 2 years ago
- fix: temporarily disable package signature checks because of nodejs/corepack#612 — committed to crux-bphc/arena-app by skoriop 2 years ago
- fix: upgrade corepack to get updated npm registry keys This version of corepack uses the updated npm registry keys, allowing it to verify signatures of downloaded package managers. See: https://gith... — committed to valian-ca/github-workflows by johnmartel 2 years ago
- ci(corepack): workaround key issue See https://github.com/nodejs/corepack/issues/612 — committed to maevsi/vibetype by dargmuesli 2 years ago
- ci(corepack): workaround key issue (#1743) See https://github.com/nodejs/corepack/issues/612 — committed to maevsi/vibetype by dargmuesli 2 years ago
- chore: CI にて最新バージョンの corepack を使用するようにする refs: https://github.com/nodejs/corepack/issues/612 — committed to kufu/smarthr-ui by s-sasaki-0529 2 years ago
- chore: CIでは最新版のcorepackを使用する 最新版手前のバージョンの corepack に不具合があり、pnpm install ができなくなっているため refs: https://github.com/nodejs/corepack/issues/612 — committed to kufu/smarthr-ui by s-sasaki-0529 2 years ago
- Downgrade pnpm to fix deployment bug https://github.com/nodejs/corepack/issues/612 — committed to pinyinlylabs/pinyinly by bradleyayers 2 years ago
- fix: https://github.com/nodejs/corepack/issues/612 — committed to blueset/i18n-fails by blueset 2 years ago
- fix: https://github.com/nodejs/corepack/issues/612 — committed to blueset/i18n-fails by blueset 2 years ago
We’re pinned to
9.15.4and seeing this on CI, so it’s not limited to10.1.0The 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:or
While using the
latest-10tag is not working right now, a pinned version can help to get your CI running 🐌Running
npm i -g corepack@latest && corepack enablein the CI environment fixed the issue for mePlease don’t fix this issue until it has 100 thumbs ups, we’re livestreaming this at my company and I’d be loosing bets 🎬🎲
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=0env 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 oldcorepack(prior to0.31.0) is to pin fresh keys manually viaor
corepackwill favorCOREPACK_INTEGRITY_KEYSover builtin keys supplied in theconfig.json: https://github.com/nodejs/corepack/blob/a7cb9f603c32c4153d7c2e4af16d8af8b6b12863/sources/npmRegistryUtils.ts#L41-L43I think there’s an issue here where you could have pinned
corepack@0.30.0andpnpm@9.15.4(viapackage.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:
In a Dockerfile:
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:
Local PNPM (or Yarn) version: If you recently updated a version in your
packageManagerfield ofpackage.json, probably it failed. It can be solved with this command too, running it in your terminal: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.0fixed it for me.@MitchDG04
Correct. corepack@0.31.0 includes the updated set of keys from https://registry.npmjs.org/-/npm/v1/keys
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:
I was then able to execute the following successfully:
I’ve sent a message there linking this and that issue 👍
@tskimmett
This was not caused by end-user error.
Try this as a workaround:
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:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzAkey (which was used to sign tarballs up until last week) and theSHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7Ukey (which is being used going forward) are both in that endpoint, which should allow folks to verify signatures again.I would recommend against
curlthe 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:
COREPACK_INTEGRITY_KEYSto0to 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.COREPACK_INTEGRITY_KEYSto{"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
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:
however that cannot be used in every situation.
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, sincesudois needed to do this in CircleCI docker images but doesn’t come installedAs 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:
I ended up installing
pnpm@10.0.0globally (can be done with their one-liner /npm install --global pnpm@10.0.0/ mise / etc.). New v10 hasmanage-package-manager-versionsenabled by default, which substitutescorepack. When inside a project directory, globally installed pnpm v10 checkspackage.json→packageManagerand 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
pnpmdownloads with one, viacorepack 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)
In GitHub Actions I used the following:
which works for any version of Node.js.
I can confirm that the same issue happens for us as well in our GitLab Pipeline:
@MikeMcC399
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
So does that mean you can’t use
npm install -g corepack@0.31.0either?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!
latestwon’t work for us as this our production build. But thanks for taking the time, really appreciate it! 🙏We’ll stick with
prepare --activateuntil we can bump the version tov.0.31.0@BeyondEvil
Did you try changing to:
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.0you can also use the package manager name with a hash. The following will work with Corepack0.27.0-0.30.0(and with0.31.0but not necessary for this version):Edit: This doesn’t help so much in a CI workflow, where there is no cache established 🙁
@sapphi-red
@sapphi-red
I can reproduce this issue on Windows 11 and Ubuntu
24.04.1LTS withhas no issue, so you might change your subject to be specifically
10.1.0instead of the generic “Newly published versions”.Also, this should probably be reported to https://github.com/pnpm/pnpm/issues cc: @zkochan