fix(knife): GPG-verify Node.js SHASUMS256.txt.asc before committing checksums - #2147
Conversation
…checksums Signed-off-by: rishuranjan <rishuranjan6@gmail.com>
|
Caution The consumer version of Gemini Code Assist on GitHub has been sunset. All code review activity has officially ceased. |
|
I've submitted this pull request and would appreciate a review when you have some bandwidth. Please let me know if any changes or additional context are needed. Thank you for your time and consideration. |
|
Hi @loosebazooka @nlopezgi @bobcallaway Gentle ping on #2147. The PR adds GPG verification of SHASUMS256.txt.asc before committing Node.js checksums, closing a supply chain attack vector in the nightly update-node-archives workflow. Happy to address any feedback. Thanks! |
|
I am not a node person but did a quick check. I feel the |
|
Hi @lathama Thanks for the review! You're right - fetching from a keyserver at runtime breaks in restricted network environments, and using execSync for shell commands is fragile. Better approach: bundle the Node.js release team's public keys directly in the repo as a committed file (sourced from https://github.com/nodejs/node#release-keys) and replace the gpg shell call with the openpgp npm package for pure Node.js verification - no system dependencies, no network calls at build time. These are public keys, not secrets - they're already published openly by the Node.js team and are safe to commit. Think of them like a list of trusted signatures you keep on file to check documents against. The only maintenance consideration is that Node.js occasionally adds new release signers. When that happens the keys file needs a one-line update via PR, which is better than fetching keys silently at runtime - changes go through review and are tracked in git history. Does this direction sound good to you, or do you have a different approach in mind? |
Problem
knife.d/update_node_archives.jscomputes SHA-256 checksums by downloadingeach Node.js tarball directly and hashing it locally. The resulting hashes are
committed to
private/extensions/node.bzland later used by Bazel to verifydownloads.
If the nodejs.org CDN, a reverse proxy, or DNS resolution is compromised at the
time the nightly
update-node-archivesworkflow runs, an attacker can serve amalicious tarball. The script will compute and commit the correct SHA-256 of the
malicious file — Bazel will then accept it on every subsequent build, silently
backdooring all
gcr.io/distroless/nodejs*images.Solution
Node.js publishes a GPG-signed
SHASUMS256.txt.ascalongside every release,signed by the Node.js release team's keys (documented at
https://github.com/nodejs/node#release-keys). Verifying this signature before
trusting any checksum establishes a chain of custody back to the Node.js release
team and eliminates the attack vector above.
This PR:
keyring at startup (with fallback to a secondary keyserver).
SHASUMS256.txtandSHASUMS256.txt.ascfor each Node.js version.gpg --verify— the script hard-fails if the signature does notvalidate, preventing any bad hashes from being committed.
SHASUMS256.txtto extract per-architecture SHA-256values, replacing the previous approach of hashing downloaded tarballs.
finallyblock.The nightly workflow already runs on
ubuntu-latest, which hasgpgpre-installed. No runner or workflow changes are required.
Security impact
Testing
Verified locally that:
by the previous tarball-hash approach.
creation.