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 <[email protected]>
This was referenced Apr 26, 2026
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.