Skip to content

Commit 2f389d6

Browse files
authored
feat(release): auto-refresh embedded signing keys in the release PR (#12798)
* feat(release): auto-refresh embedded signing keys in the release PR The create-release-pr workflow previously failed when the embedded npm signing keys or Node.js release keys drifted from their canonical sources, requiring a manual update PR before a release could proceed. Now the workflow runs the update scripts in --update mode and commits the refreshed keys together with the version bumps, so the new trust roots are reviewed as part of the release PR diff. A synthesized changeset records the refresh in the changelogs of the affected packages. Also embeds the Node.js release team's new signing key 655F3B5C1FB3FA8D1A0CA6BDE4A7D232B936D2FD (Stewart X Addison), which the last release run reported as missing, and fixes the Rust renderer in update-node-release-keys.mjs so its output is lint-clean (angle-bracket URL for dylint's bare-url lint, raw-string hashes only when the key contains a quote for clippy's needless_raw_string_hashes) and matches the committed file byte-for-byte on a no-drift run. * fix(release): canonicalize npm key order and flag trust-root refreshes Review follow-ups: sort the merged npm signing keys by keyid so a reordering of npm's response cannot churn the generated file or synthesize a spurious changeset, and leave an explicit warning comment on the release PR whenever embedded trust roots were refreshed, so a key change cannot slip through buried in a large version-bump diff.
1 parent d539172 commit 2f389d6

7 files changed

Lines changed: 117 additions & 36 deletions

File tree

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
---
2+
"@pnpm/crypto.shasums-file": patch
3+
"pnpm": patch
4+
---
5+
6+
Added the Node.js release team's new signing key (Stewart X Addison, `655F3B5C1FB3FA8D1A0CA6BDE4A7D232B936D2FD`) to the embedded Node.js release keys, so runtimes whose `SHASUMS256.txt` is signed by the new releaser verify successfully.

‎.github/workflows/create-release-pr.yml‎

Lines changed: 60 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -50,19 +50,53 @@ jobs:
5050
git fetch origin "$TARGET"
5151
git checkout -B "release-pr/$TARGET" FETCH_HEAD
5252
53-
# Fail the release if the npm registry signing keys embedded in
54-
# @pnpm/deps.security.signatures have drifted from what npm advertises. pnpm
55-
# verifies package-manager binaries (pacquet, the version-switch pnpm) against
56-
# these keys, so a stale set could break verification after a key rotation.
57-
- name: Check embedded npm signing keys are up to date
58-
run: node pnpm11/deps/security/signatures/scripts/update-npm-signing-keys.mjs
59-
60-
# Fail the release if the embedded Node.js release keys (used to verify the
61-
# signature of a downloaded runtime's SHASUMS256.txt) have drifted from the
62-
# canonical nodejs/release-keys list, so a new release signer cannot silently
63-
# break Node.js runtime verification.
64-
- name: Check embedded Node.js release keys are up to date
65-
run: node pnpm11/crypto/shasums-file/scripts/update-node-release-keys.mjs
53+
# Refresh the npm registry signing keys embedded in
54+
# @pnpm/deps.security.signatures from what npm advertises. pnpm verifies
55+
# package-manager binaries (pacquet, the version-switch pnpm) against these
56+
# keys, so a stale set could break verification after a key rotation. Any
57+
# drift is committed below along with the version bumps, so the new trust
58+
# roots are reviewed as part of the release PR diff.
59+
- name: Update embedded npm signing keys
60+
run: node pnpm11/deps/security/signatures/scripts/update-npm-signing-keys.mjs --update
61+
62+
# Refresh the embedded Node.js release keys (used to verify the signature of
63+
# a downloaded runtime's SHASUMS256.txt) from the canonical
64+
# nodejs/release-keys list, so a new release signer cannot break Node.js
65+
# runtime verification. Reviewed in the release PR diff like the npm keys.
66+
- name: Update embedded Node.js release keys
67+
run: node pnpm11/crypto/shasums-file/scripts/update-node-release-keys.mjs --update
68+
69+
# A refreshed trust root must show up in the changelogs, so synthesize a
70+
# changeset for whichever key sets drifted before `pnpm bump` consumes the
71+
# pending changesets. The `drifted` output drives an explicit review signal
72+
# on the PR, so a trust-root change cannot hide in a large version-bump diff.
73+
- name: Add changesets for refreshed keys
74+
id: keys
75+
run: |
76+
drifted=""
77+
if ! git diff --quiet -- pnpm11/deps/security/signatures/src/npmSigningKeys.ts; then
78+
drifted="npm registry signing keys"
79+
cat > .changeset/release-refresh-npm-signing-keys.md <<'EOF'
80+
---
81+
"@pnpm/deps.security.signatures": patch
82+
"pnpm": patch
83+
---
84+
85+
Updated the embedded npm registry signing keys to the set currently advertised by npm.
86+
EOF
87+
fi
88+
if ! git diff --quiet -- pnpm11/crypto/shasums-file/src/nodeReleaseKeys.ts; then
89+
drifted="${drifted:+$drifted and }Node.js release keys"
90+
cat > .changeset/release-refresh-node-release-keys.md <<'EOF'
91+
---
92+
"@pnpm/crypto.shasums-file": patch
93+
"pnpm": patch
94+
---
95+
96+
Updated the embedded Node.js release keys to the current canonical `nodejs/release-keys` list.
97+
EOF
98+
fi
99+
echo "drifted=$drifted" >> "$GITHUB_OUTPUT"
66100
67101
# Consumes the pending changesets: bumps versions, writes changelogs, updates
68102
# the ledger, and syncs manifests. A no-op (no pending changesets) leaves the
@@ -117,3 +151,16 @@ jobs:
117151
--base "$TARGET" \
118152
--head "$BRANCH"
119153
fi
154+
155+
# Embedded trust roots changed in this release, so leave a hard-to-miss
156+
# comment: the refreshed keys need deliberate review, not a scroll-past
157+
# among the version bumps and changelogs.
158+
- name: Flag refreshed trust roots on the PR
159+
if: steps.changes.outputs.changed == 'true' && steps.keys.outputs.drifted != ''
160+
env:
161+
GH_TOKEN: ${{ secrets.UPDATE_LOCKFILE_TOKEN }}
162+
TARGET: ${{ github.event.inputs.target }}
163+
DRIFTED: ${{ steps.keys.outputs.drifted }}
164+
run: |
165+
PR=$(gh pr list --head "release-pr/$TARGET" --state open --json number --jq '.[0].number')
166+
gh pr comment "$PR" --body "⚠️ This release refreshes embedded trust roots: **${DRIFTED}**. Review those key diffs deliberately before merging — they gate signature verification of Node.js runtimes and package-manager binaries."

‎pacquet/crates/crypto-shasums-file/src/node_release_keys.rs‎

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2117,6 +2117,23 @@ sWjTVgUCaGA63AIbDAAKCRAgsaOQsWjTVu8oAP9Bc+QY+9FikX3YvMgWAqiDlVOy
21172117
o0y6UIZGBMSQlF80wAD/d34LqtVIVe9oe5NO3xA75+6Ew8tGeAjUq/ovagr5dAU=
21182118
=JsVv
21192119
-----END PGP PUBLIC KEY BLOCK-----
2120+
",
2121+
},
2122+
NodeReleaseKey {
2123+
fingerprint: "655F3B5C1FB3FA8D1A0CA6BDE4A7D232B936D2FD",
2124+
armored_key: r"-----BEGIN PGP PUBLIC KEY BLOCK-----
2125+
2126+
mDMEakIjcxYJKwYBBAHaRw8BAQdAYRFWvBCAd9dDjKTePuAvvzAWxhvojAXco0m4
2127+
2AMh/MC0H1N0ZXdhcnQgWCBBZGRpc29uIDxzeGFAaWJtLmNvbT6ImQQTFgoAQRYh
2128+
BGVfO1wfs/qNGgymveSn0jK5NtL9BQJqQiNzAhsDBQkDwmcABQsJCAcCAiICBhUK
2129+
CQgLAgQWAgMBAh4HAheAAAoJEOSn0jK5NtL9FOEBAMpIjknm4fnEQvTmIlzy0kDu
2130+
VplF4HR78+lBef2i4590AP9i82wtP4pH1/vynoSBMkCauFIPmF1c9MYLFF0f53zq
2131+
Arg4BGpCI3MSCisGAQQBl1UBBQEBB0AVa1WJ4P8ir/M7NaCGrX7PDs0QU9qzpzme
2132+
a5TZ44b/YgMBCAeIfgQYFgoAJhYhBGVfO1wfs/qNGgymveSn0jK5NtL9BQJqQiNz
2133+
AhsMBQkDwmcAAAoJEOSn0jK5NtL9EzYA/Arr4hbKLaU6OUjAVbH7HGLEl0HSvxE8
2134+
5lEgWfuNbqOtAQCF9UT0wQEfiIj2R358Ce62zV43w2yaD8Xu0M/S+hz8AQ==
2135+
=DcLq
2136+
-----END PGP PUBLIC KEY BLOCK-----
21202137
",
21212138
},
21222139
];

‎pnpm11/crypto/shasums-file/scripts/update-node-release-keys.mjs‎

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3,12 +3,13 @@
33
// signature of SHASUMS256.txt) from the canonical nodejs/release-keys repo into
44
// src/nodeReleaseKeys.ts and pacquet's matching Rust key module.
55
//
6-
// node update-node-release-keys.mjs # check (CI / release gate)
6+
// node update-node-release-keys.mjs # check
77
// node update-node-release-keys.mjs --update # rewrite the embedded keys
88
//
9-
// `--check` fails when the authoritative keys.list contains a fingerprint that
10-
// is not embedded, so a newly added release signer cannot silently break Node
11-
// runtime verification.
9+
// The create-release-pr workflow runs `--update`, so any drift from the
10+
// authoritative keys.list is committed into the release PR and reviewed there —
11+
// a newly added release signer cannot silently break Node runtime verification.
12+
// Check mode reports the drift without writing.
1213
import fs from 'node:fs'
1314
import path from 'node:path'
1415
import { fileURLToPath } from 'node:url'
@@ -97,10 +98,13 @@ ${entries}
9798
}
9899

99100
function renderRust (keys) {
101+
// Hashed delimiters only when the key itself contains a quote, or clippy's
102+
// needless_raw_string_hashes rejects the generated file.
103+
const rustRawString = (s) => s.includes('"') ? `r#"${s}"#` : `r"${s}"`
100104
const entries = keys.map(({ fingerprint, armored }) =>
101-
` NodeReleaseKey {\n fingerprint: "${fingerprint}",\n armored_key: r#"${armored}\n"#,\n },`).join('\n')
105+
` NodeReleaseKey {\n fingerprint: "${fingerprint}",\n armored_key: ${rustRawString(`${armored}\n`)},\n },`).join('\n')
102106
return `// GENERATED - the Node.js release team's OpenPGP public keys, mirrored from
103-
// https://github.com/nodejs/release-keys (keys.list + keys/<fingerprint>.asc).
107+
// <https://github.com/nodejs/release-keys> (keys.list + keys/<fingerprint>.asc).
104108
//
105109
// Used to verify the signature of a Node.js release's SHASUMS256.txt before
106110
// trusting its hashes. Refresh with:

‎pnpm11/crypto/shasums-file/src/nodeReleaseKeys.ts‎

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -119,4 +119,8 @@ export const NODE_RELEASE_KEYS = [
119119
fingerprint: '5BE8A3F6C8A5C01D106C0AD820B1A390B168D356',
120120
armoredKey: "-----BEGIN PGP PUBLIC KEY BLOCK-----\n\nmDMEaGA63BYJKwYBBAHaRw8BAQdAo/yU+MutacFmmn0CEX495goNrBxR24235XLM\ncvHYjfq0L0FudG9pbmUgZHUgSGFtZWwgPGR1aGFtZWxhbnRvaW5lMTk5NUBnbWFp\nbC5jb20+iI4EExYKADYWIQR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0jK5NtL9FOEBAMpIjknm4fnEQvTmIlzy0kDu\nVplF4HR78+lBef2i4590AP9i82wtP4pH1/vynoSBMkCauFIPmF1c9MYLFF0f53zq\nArg4BGpCI3MSCisGAQQBl1UBBQEBB0AVa1WJ4P8ir/M7NaCGrX7PDs0QU9qzpzme\na5TZ44b/YgMBCAeIfgQYFgoAJhYhBGVfO1wfs/qNGgymveSn0jK5NtL9BQJqQiNz\nAhsMBQkDwmcAAAoJEOSn0jK5NtL9EzYA/Arr4hbKLaU6OUjAVbH7HGLEl0HSvxE8\n5lEgWfuNbqOtAQCF9UT0wQEfiIj2R358Ce62zV43w2yaD8Xu0M/S+hz8AQ==\n=DcLq\n-----END PGP PUBLIC KEY BLOCK-----\n",
125+
},
122126
] as const satisfies ReadonlyArray<{ fingerprint: string, armoredKey: string }>

‎pnpm11/deps/security/signatures/scripts/update-npm-signing-keys.mjs‎

Lines changed: 12 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -2,14 +2,15 @@
22
// Keeps the embedded npm registry signing keys (src/npmSigningKeys.ts) in sync
33
// with https://registry.npmjs.org/-/npm/v1/keys.
44
//
5-
// node update-npm-signing-keys.mjs # check (CI / release gate)
5+
// node update-npm-signing-keys.mjs # check
66
// node update-npm-signing-keys.mjs --update # rewrite the embedded keys
77
//
8-
// `--check` fails when npm advertises a signing key that is not embedded
9-
// verbatim, so a key rotation cannot silently break (or weaken) pnpm's
10-
// signature verification. `--update` writes the union of npm's keys and any
11-
// embedded keys npm no longer lists (older keys are kept so packages published
12-
// before a rotation still verify).
8+
// The create-release-pr workflow runs `--update`, so a key rotation is
9+
// committed into the release PR and reviewed there rather than silently
10+
// breaking (or weakening) pnpm's signature verification. `--update` writes the
11+
// union of npm's keys and any embedded keys npm no longer lists (older keys are
12+
// kept so packages published before a rotation still verify). Check mode
13+
// reports the drift without writing.
1314
import fs from 'node:fs'
1415
import path from 'node:path'
1516
import { fileURLToPath } from 'node:url'
@@ -37,11 +38,13 @@ async function main () {
3738
}
3839

3940
// Union: every npm key, plus embedded keys npm no longer lists (kept for
40-
// verifying packages published before a rotation).
41+
// verifying packages published before a rotation). Sorted so a reordering of
42+
// npm's response cannot churn the generated file.
4143
const merged = [...npmKeys]
4244
for (const e of embedded) {
4345
if (!merged.some((m) => m.keyid === e.keyid)) merged.push(e)
4446
}
47+
merged.sort((a, b) => a.keyid.localeCompare(b.keyid))
4548
fs.writeFileSync(KEYS_FILE, render(merged))
4649
console.log(missing.length === 0
4750
? '✓ Embedded npm signing keys already current; rewrote file.'
@@ -87,8 +90,8 @@ function render (keys) {
8790
// ${KEYS_URL}
8891
//
8992
// Refresh with: node deps/security/signatures/scripts/update-npm-signing-keys.mjs --update
90-
// The release workflow runs \`--check\` and fails if these drift from npm, so a
91-
// rotated key cannot silently break (or weaken) signature verification.
93+
// The create-release-pr workflow refreshes these automatically, so a rotated
94+
// key cannot silently break (or weaken) signature verification.
9295
export const NPM_SIGNING_KEYS = ${body} as const satisfies ReadonlyArray<{
9396
expires: string | null
9497
keyid: string

‎pnpm11/deps/security/signatures/src/npmSigningKeys.ts‎

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -3,22 +3,22 @@
33
// https://registry.npmjs.org/-/npm/v1/keys
44
//
55
// Refresh with: node deps/security/signatures/scripts/update-npm-signing-keys.mjs --update
6-
// The release workflow runs `--check` and fails if these drift from npm, so a
7-
// rotated key cannot silently break (or weaken) signature verification.
6+
// The create-release-pr workflow refreshes these automatically, so a rotated
7+
// key cannot silently break (or weaken) signature verification.
88
export const NPM_SIGNING_KEYS = [
99
{
10-
"expires": "2025-01-29T00:00:00.000Z",
11-
"keyid": "SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA",
10+
"expires": null,
11+
"keyid": "SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U",
1212
"keytype": "ecdsa-sha2-nistp256",
1313
"scheme": "ecdsa-sha2-nistp256",
14-
"key": "MFkwEwYHKoZIzj0CAQYIKoZIzj0DAQcDQgAE1Olb3zMAFFxXKHiIkQO5cJ3Yhl5i6UPp+IhuteBJbuHcA5UogKo0EWtlWwW6KSaKoTNEYL7JlCQiVnkhBktUgg=="
14+
"key": "MFkwEwYHKoZIzj0CAQYIKoZIzj0DAQcDQgAEY6Ya7W++7aUPzvMTrezH6Ycx3c+HOKYCcNGybJZSCJq/fd7Qa8uuAKtdIkUQtQiEKERhAmE5lMMJhP8OkDOa2g=="
1515
},
1616
{
17-
"expires": null,
18-
"keyid": "SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U",
17+
"expires": "2025-01-29T00:00:00.000Z",
18+
"keyid": "SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA",
1919
"keytype": "ecdsa-sha2-nistp256",
2020
"scheme": "ecdsa-sha2-nistp256",
21-
"key": "MFkwEwYHKoZIzj0CAQYIKoZIzj0DAQcDQgAEY6Ya7W++7aUPzvMTrezH6Ycx3c+HOKYCcNGybJZSCJq/fd7Qa8uuAKtdIkUQtQiEKERhAmE5lMMJhP8OkDOa2g=="
21+
"key": "MFkwEwYHKoZIzj0CAQYIKoZIzj0DAQcDQgAE1Olb3zMAFFxXKHiIkQO5cJ3Yhl5i6UPp+IhuteBJbuHcA5UogKo0EWtlWwW6KSaKoTNEYL7JlCQiVnkhBktUgg=="
2222
}
2323
] as const satisfies ReadonlyArray<{
2424
expires: string | null

0 commit comments

Comments
 (0)