Skip to content

fix: add SHA-256 checksum verification for binary downloads (S6)#10

Merged
beonde merged 1 commit intomainfrom
fix/binary-checksum-verification
Mar 29, 2026
Merged

fix: add SHA-256 checksum verification for binary downloads (S6)#10
beonde merged 1 commit intomainfrom
fix/binary-checksum-verification

Conversation

@beonde
Copy link
Copy Markdown
Member

@beonde beonde commented Mar 29, 2026

Board Report Finding: S6

Severity: P1 - Supply chain gap in public-facing GitHub Action
Finding: The GitHub Action downloads capiscio-core binary from GitHub Releases with no SHA-256 verification.

Changes

Added checksum verification mirroring the pattern from capiscio-node (PR #40) and capiscio-python (PR #16).

New: src/checksum.ts

  • fetchText() - HTTPS GET with redirect following
  • computeSHA256() - Stream-based SHA-256 hashing
  • verifyChecksum() - Full verification flow
  • parseChecksums() - Checksum file parser (exported for testing)

Flow

  1. Download binary via @actions/tool-cache
  2. Fetch checksums.txt from same GitHub Release
  3. Compute SHA-256 of downloaded file using stream hashing
  4. On mismatch: delete file, throw error with expected vs actual hash
  5. On checksums.txt unavailable: check CAPISCIO_REQUIRE_CHECKSUM env var
  6. Only chmod + rename AFTER successful verification

Also

  • Updated CAPISCIO_VERSION from 2.4.0 to 2.6.0
  • 7 new tests (all pass)
  • Rebuilt dist/index.js (deployed artifact)

Verification

npm install && npm test  # 14/14 tests pass
npm run build            # dist/index.js rebuilt

Add checksum verification when downloading capiscio-core binary from
GitHub Releases. Mirrors pattern from capiscio-node and capiscio-python.

- New src/checksum.ts module: fetchText, computeSHA256, verifyChecksum,
  parseChecksums (exported for testing)
- Stream-based SHA-256 hashing via fs.createReadStream (not readFileSync)
- On mismatch: delete file, throw with expected vs actual hash
- On checksums.txt unavailable: check CAPISCIO_REQUIRE_CHECKSUM env var
  - If true: delete and throw (fail-closed)
  - If false: core.warning() and continue (graceful degradation)
- chmod + rename only AFTER successful verification
- Updated CAPISCIO_VERSION from 2.4.0 to 2.6.0
- 7 new tests for checksum parsing, hashing, and edge cases
- Rebuilt dist/index.js (deployed artifact)

Board report finding: S6 (P1 - Supply chain gap in public GitHub Action)
@beonde beonde merged commit 320d544 into main Mar 29, 2026
1 check passed
@beonde beonde deleted the fix/binary-checksum-verification branch March 29, 2026 14:56
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant