fix: add SHA-256 checksum verification to release download (security)#285
Open
xiaolai wants to merge 1 commit into
Open
fix: add SHA-256 checksum verification to release download (security)#285xiaolai wants to merge 1 commit into
xiaolai wants to merge 1 commit into
Conversation
downloadRelease() previously wrote the fetched ZIP to disk with no integrity check. A compromised release asset would be silently installed. Added an optional expectedSha256 parameter: when provided, the buffer is hashed with node:crypto before writing, and a mismatch throws an error. Added findChecksumAsset() to look for a companion checksum file in the release assets (e.g. release.zip.sha256, checksums.sha256, SHA256SUMS) and extract the hex digest. init.ts now calls findChecksumAsset() before downloading and passes the result to downloadRelease() — if the release includes a checksum file the download is verified; if not, the current behaviour is preserved with no regression. Co-Authored-By: Claude Code <noreply@anthropic.com>
This was referenced Apr 26, 2026
mrgoonie
requested changes
Jun 22, 2026
mrgoonie
left a comment
Contributor
There was a problem hiding this comment.
Summary: Optional release checksum verification is a useful security direction, but this PR is not merge-ready because it duplicates another open checksum PR and fails open when checksum retrieval fails.
Risk level: Medium
Mandatory gates:
- Duplicate/prior implementation: overlap found — PR #288 implements the same SHA-256 release download verification path in the same two files, and PR #315 includes broader release/download hardening.
- Project standards: issue found — GitHub download/install failures should be explicit; checksum verification must not silently downgrade after selecting a checksum asset.
- Strategic necessity: clear value — release-asset integrity verification reduces supply-chain risk for GitHub release installs.
- CI/checks: missing/not reported for this PR.
Findings:
- Important: This materially duplicates PR #288. Both PRs change
cli/src/commands/init.tsandcli/src/utils/github.tsto add optional SHA-256 verification for release ZIP downloads. Please consolidate around one checksum design rather than keeping parallel implementations open. - Important:
findChecksumAsset()returnsnullwhen a checksum asset exists but cannot be fetched or parsed (if (!response.ok) return null;and no parse-failure error). BecausedownloadRelease()only verifies whenexpectedSha256is truthy, the install silently proceeds without verification after a selected checksum path fails. That is a dangerous fail-open security posture. If a checksum asset is selected, fetch/parse mismatch should fail closed with a clearGitHubDownloadErroror equivalent. - Suggestion: add a small test for checksum success, checksum mismatch, and checksum asset fetch/parse failure so the fail-closed behavior stays locked.
Verdict: REQUEST_CHANGES
Contributor
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Security Fix (Medium severity)
cli/src/utils/github.ts—downloadRelease()fetches a ZIP from GitHub releases and writes it to disk, theninit.tsextracts and copies the contents into the user's project. No integrity check was performed, so a compromised or corrupted release asset would be silently installed.Fix
cli/src/utils/github.tsexpectedSha256parameter todownloadRelease(). When provided, the downloaded buffer is hashed with Node's built-innode:cryptobefore writing to disk. A mismatch throws aGitHubDownloadErrorwith both expected and actual hashes for easy diagnosis.findChecksumAsset(release, assetName)— looks for a companion checksum file in the GitHub release assets (<assetName>.sha256,checksums.sha256,SHA256SUMS) and extracts the hex digest.cli/src/commands/init.tsfindChecksumAsset()before downloading.downloadRelease().Backwards compatibility: if the release does not include a checksum file,
findChecksumAssetreturnsnullanddownloadReleaseproceeds as before — no regression for existing releases.