Skip to content

feat(npm): verify SHA-256 of downloaded binary against checksums.txt #28

@btwshivam

Description

@btwshivam

npm/postinstall.js downloads the release tarball from GitHub Releases but never validates its digest:

$ grep -in 'checksum\|sha256\|hash' npm/postinstall.js
74:    console.log('optiqor: ready. Run `optiqor --version` to verify.');

only match is a log line. goreleaser already produces checksums.txt in every release. nothing in the install path uses it.

result: anyone who can intercept the download (mitm, hijacked release asset, compromised mirror) ships arbitrary binaries to every npm install -g @optiqor/cli user. this is the exact supply-chain risk the README pitches against ("All release artifacts are signed with Cosign").

scope:

  1. fetch checksums.txt from the same release tag
  2. hash the downloaded tarball: crypto.createHash('sha256').update(buf).digest('hex')
  3. compare against the entry in checksums.txt matching the archive filename
  4. on mismatch, delete the tarball and fail loud (process.exit(1))

bonus: cosign-verify checksums.txt itself. cosign is already in the goreleaser pipeline, so the public key + signature exist in the release. that closes the loop the README claims.

Metadata

Metadata

Labels

P1High priority — ship soonarea/npmnpm distribution and wrapperclaimedSomeone has claimed this via /assignenhancementNew feature or requestsecuritySecurity-related (exempt from stale bot)size/M51–200 lines

Type

No type
No fields configured for issues without a type.

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions