fix: verify bun installer SHA-256 before executing (#2463)#2473
Merged
Conversation
Why: The curl|bash pattern for bun installation was an unverified supply chain dependency. Now the installer is downloaded to a temp file and its SHA-256 hash is verified against a known-good value before execution. Falls back gracefully if sha256sum/shasum is unavailable. Agent: security-auditor Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
louisgv
approved these changes
Mar 11, 2026
Member
louisgv
left a comment
There was a problem hiding this comment.
Security Review
Verdict: APPROVED
Commit: c4a3717
Summary
This PR adds SHA-256 verification to the bun installer before execution, significantly improving supply chain security by defending against compromised CDN or DNS hijack attacks.
Security Improvements
- HIGH: Supply chain attack mitigation (lines 310-329) — downloads installer to temp file, verifies hash, aborts on mismatch
- MEDIUM: Portable SHA-256 implementation (lines 35-44) — supports both Linux/macOS hash tools
Findings
- MEDIUM-ACCEPTED: Fallback to unverified execution if sha256 tools unavailable (lines 313-314) — acceptable for backwards compatibility, clearly warned
- LOW-SAFE: Temp file cleanup handled properly on both success/error paths
- LOW-ACCEPTABLE: Hardcoded hash requires manual update when bumping bun version — documented in comment
Tests
bash -n: PASS (no syntax errors)bun test: N/A (no TypeScript changes)- curl|bash: OK (no relative paths, no $0 reliance)
- macOS bash 3.x compat: OK (no echo -e, no source <(), proper quoting)
- Injection safety: OK (all variables properly quoted, no user input in commands)
Compliance
- No
astype assertions (shell script only) - No ESM/require issues (shell script only)
- Follows curl|bash compatibility rules
- Follows macOS bash 3.x compatibility rules
-- security/pr-reviewer
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.
Why: Issue #2463 flags the
curl|bashbun install pattern as a supply chain risk. This PR replaces the pipe-to-bash pattern with a download-verify-execute approach.Fixes #2463
Changes
BUN_INSTALL_VERSIONandBUN_INSTALLER_SHA256constants at the top ofinstall.shsha256_file()helper (works on Linux withsha256sumand macOS withshasum -a 256)curl ... | bashwith download-to-tempfile, SHA-256 verification, thenbash <tempfile>BUN_INSTALL_VERSIONvariable in manual install instructions (DRY)Security Analysis
The bun installer (
https://bun.sh/install?version=1.3.9) is a third-party script that downloads and installs the bun binary. Previously, this was piped directly from curl to bash with no verification.Risk: If bun.sh is compromised or DNS is hijacked, an attacker could serve a modified installer that executes arbitrary code.
Mitigations added:
?version=1.3.9), now extracted to a named constant--proto '=https'), prevents HTTP downgrade attacksLimitations:
BUN_INSTALL_VERSIONsha256sumnorshasumis available, verification is skipped with a warning (extremely rare — both macOS and Linux ship one of these)Compatibility
bash -nsyntax check passesshasum -a 256on macOS (bash 3.x compatible)echo -e, nosource <(...), noset -u, no bash 4+ features-- refactor/security-auditor