fix: add SHA-256 checksum verification to GitHub release downloads#288
Open
xiaolai wants to merge 1 commit intonextlevelbuilder:mainfrom
Open
fix: add SHA-256 checksum verification to GitHub release downloads#288xiaolai wants to merge 1 commit intonextlevelbuilder:mainfrom
xiaolai wants to merge 1 commit intonextlevelbuilder:mainfrom
Conversation
downloadRelease() previously wrote the downloaded ZIP to disk without any integrity check. A compromised release asset would be silently installed into user projects. Changes: - Add getChecksumUrl() helper that looks for a companion `.sha256` or `checksums.txt` asset in the release - Add optional checksumUrl parameter to downloadRelease(); if a checksum URL is provided and the fetch succeeds, compute SHA-256 of the downloaded buffer and compare before writing to disk - Add GitHubChecksumError class for mismatch failures - Update init.ts to look up and pass the checksum URL when present This is forward-compatible: if no checksum asset is uploaded the behavior is unchanged. Maintainers can enable full verification by uploading a `<asset-name>.sha256` companion file to each release. 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)
cli/src/utils/github.ts—downloadRelease()fetches a ZIP from GitHub releases and writes it directly to disk without any integrity check.init.tsthen extracts and installs the contents into the user's project. A compromised release asset (e.g. from a hijacked GitHub token or a compromised release pipeline) would be silently installed with no way for the user to detect the tamper.Fix: This PR adds opt-in SHA-256 verification using a companion checksum asset pattern:
getChecksumUrl(release, assetName)— looks for a<asset-name>.sha256orchecksums.txtasset in the GitHub releasedownloadRelease(url, dest, checksumUrl?)— ifchecksumUrlis provided and the fetch succeeds, computesSHA-256of the downloaded buffer and compares against the expected hash before writing to disk; throwsGitHubChecksumErroron mismatchinit.tsnow callsgetChecksumUrl(release, assetName)and passes the result todownloadReleaseThis is backward-compatible: if no companion checksum asset is uploaded, the behavior is identical to the current code. To enable full verification, upload a
release.zip.sha256(orchecksums.txt) companion file to each GitHub release — the CLI will then automatically verify before installation.