fix(install): verify release archive checksum before install#38
Open
hobostay wants to merge 1 commit into
Open
fix(install): verify release archive checksum before install#38hobostay wants to merge 1 commit into
hobostay wants to merge 1 commit into
Conversation
The first-run installers (install.sh, install.ps1) downloaded and extracted the bsk release archive with no integrity check, even though the in-app `bsk update` path treats a sha256 checksum as mandatory (update.rs bails with "does not include a sha256 checksum; cannot safely auto-update"). The release version.json already carries a per-asset sha256 (render-version-json.mjs renders with --dist), so the installers can verify the same way. Both installers now fetch version.json once (pinned and latest), read `assets[<platform>].sha256`, and verify the downloaded archive's sha256 before extracting: - install.sh: POSIX sed to parse the field (no jq dependency), and sha256sum/shasum to compute the digest. - install.ps1: Invoke-RestMethod + Get-FileHash. A checksum mismatch is fatal (fail-closed, matching `bsk update`). A missing manifest/checksum, or the absence of a sha256 tool, only skips verification with a warning, so the first-run bootstrap still works on minimal/offline machines. Validation: `sh -n` / `bash -n`; functional test of the sed extraction against a realistic version.json and of compute_sha256 against sha256sum. The installers are not exercised by CI (no shell harness). Co-Authored-By: Claude <noreply@anthropic.com>
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.
Problem
The first-run installers (
install.sh,install.ps1) downloaded and extracted thebskrelease archive with no integrity check, even though the in-appbsk updatepath treats a sha256 checksum as mandatory:A compromised release artifact, CDN, or cache delivers a trojaned
bskbinary and the installer installs it as-is. The releaseversion.jsonalready carries a per-assetsha256(scripts/render-version-json.mjsrenders it with--dist), so the installers can verify exactly the waybsk updatedoes.Change
Both installers now fetch
version.jsononce (for both pinnedBSK_VERSIONand latest), readassets[<platform>].sha256, and verify the downloaded archive's sha256 before extracting:install.sh— POSIXsedparses the per-platform field (nojqdependency, matching the existingsed-based version parse);sha256sum/shasum -a 256computes the digest.install.ps1—Invoke-RestMethodparses the JSON andGet-FileHash -Algorithm SHA256computes the digest; comparison is case-insensitive (-ieq).Failure handling:
bsk update).This preserves install behavior while closing the integrity gap the updater already enforces.
Validation
The installers are not exercised by CI (no shell/PowerShell test harness), so validated manually:
sh -n/bash -noninstall.sh(clean).extract_asset_sha256against a realistic pretty-printedversion.json(correct per-platform hash; empty → skip for an absent platform) and ofcompute_sha256againstsha256sum(matching digest).install.ps1reviewed for PS 5.1 compatibility (Get-FileHash, dynamic member access$manifest.assets.$platformKey.sha256,-ieq).version.jsonschema is unchanged (only consumed), so thenode-scriptsCI job is unaffected.🤖 Generated with Claude Code