Skip to content

fix(security): verify SHA-256 checksum on OpenShell binary download#697

Open
ericksoa wants to merge 1 commit intomainfrom
fix/openshell-checksum-verify
Open

fix(security): verify SHA-256 checksum on OpenShell binary download#697
ericksoa wants to merge 1 commit intomainfrom
fix/openshell-checksum-verify

Conversation

@ericksoa
Copy link
Contributor

@ericksoa ericksoa commented Mar 23, 2026

Summary

Both scripts/install.sh and scripts/install-openshell.sh download the OpenShell binary via curl/gh and install it (often as root) without any integrity verification. OpenShell releases include openshell-checksums-sha256.txt alongside the tarballs — verified present in v0.0.10 through v0.0.13.

Both files now:

  1. Download openshell-checksums-sha256.txt alongside the tarball (both gh and curl paths)
  2. Verify via shasum -a 256 -c before extraction
  3. Fail with a clear error message if verification fails

Test plan

  • 2 regression tests verify both scripts reference openshell-checksums-sha256.txt and shasum -a 256 -c
  • All existing tests pass (305/305)
  • Verified checksum file exists in all recent OpenShell releases (v0.0.10–v0.0.13)
  • Manual: nemoclaw onboard installs OpenShell with checksum verification
  • Manual: tamper with downloaded tarball → verify installation fails with clear error

Summary by CodeRabbit

  • New Features

    • Enhanced security: Added SHA-256 checksum verification for downloaded installation packages. Files are now automatically verified against checksums before extraction, with installation aborted if verification fails.
  • Tests

    • Added regression tests to validate that checksum verification logic is correctly implemented in installation scripts.

@coderabbitai
Copy link

coderabbitai bot commented Mar 23, 2026

📝 Walkthrough

Walkthrough

Two installation scripts now download and verify SHA-256 checksums before extracting OpenShell archives, using shasum -a 256 -c to validate integrity. Regression tests were added to ensure this checksum verification logic remains present in both scripts.

Changes

Cohort / File(s) Summary
Checksum Verification
scripts/install-openshell.sh, scripts/install.sh
Added SHA-256 checksum verification logic: downloads openshell-checksums-sha256.txt, extracts the expected checksum via grep, and validates the archive using shasum -a 256 -c. Script fails explicitly if verification does not succeed before proceeding to extraction.
Regression Tests
test/runner.test.js
Added two new test cases that verify the presence of checksum-verification logic in both installation scripts by asserting references to openshell-checksums-sha256.txt and the shasum -a 256 -c command.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

Poem

🐰 A checksum here, a checksum there,
Safe downloads floating through the air!
Our scripts now verify with care,
No tampered files anywhere!

🚥 Pre-merge checks | ✅ 3
✅ Passed checks (3 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title 'fix(security): verify SHA-256 checksum on OpenShell binary download' directly and clearly describes the main change: adding SHA-256 checksum verification to the OpenShell binary download process, which is the core security improvement across both install scripts.
Docstring Coverage ✅ Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch fix/openshell-checksum-verify

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🧹 Nitpick comments (3)
scripts/install-openshell.sh (2)

82-98: Checksum verification correctly implemented with proper cleanup.

This script has the EXIT trap at line 80, ensuring $tmpdir is cleaned up regardless of success or failure. The checksum verification logic is consistent with scripts/install.sh.

Same minor note about grep precision applies here:

♻️ Optional: Use fixed-string grep for precision
-  (cd "$tmpdir" && grep "$ASSET" "$CHECKSUM_FILE" | shasum -a 256 -c -) \
+  (cd "$tmpdir" && grep -F "$ASSET" "$CHECKSUM_FILE" | shasum -a 256 -c -) \
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@scripts/install-openshell.sh` around lines 82 - 98, The checksum verification
uses grep "$ASSET" "$CHECKSUM_FILE" which can mis-match substrings; update the
verification command to use a fixed-string or exact-match grep (e.g., use grep
-F or grep -x) so CHECKSUM_FILE is searched precisely for the ASSET entry before
piping to shasum -a 256 -c -; modify the line that runs (cd "$tmpdir" && grep
"$ASSET" "$CHECKSUM_FILE" | shasum -a 256 -c -) to reference the chosen grep
option and ensure variables GH_TOKEN, ASSET, CHECKSUM_FILE and tmpdir remain
unchanged.

96-97: Consider handling missing checksum entry explicitly.

If grep "$ASSET" finds no match (asset not listed in checksum file), the pipeline will fail with "SHA-256 checksum verification failed." This is technically correct, but the error message could be misleading—the failure isn't a mismatch but a missing entry.

♻️ Optional: More informative error handling
 info "Verifying SHA-256 checksum..."
-(cd "$tmpdir" && grep "$ASSET" "$CHECKSUM_FILE" | shasum -a 256 -c -) \
-  || fail "SHA-256 checksum verification failed for $ASSET"
+(cd "$tmpdir" && {
+  checksum_line=$(grep -F "$ASSET" "$CHECKSUM_FILE") \
+    || fail "Asset $ASSET not found in $CHECKSUM_FILE"
+  echo "$checksum_line" | shasum -a 256 -c -
+}) || fail "SHA-256 checksum verification failed for $ASSET"

This is optional since the current behavior is safe (fails closed), just less descriptive.

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@scripts/install-openshell.sh` around lines 96 - 97, The failure message is
ambiguous when the checksum file lacks an entry for ASSET; before piping into
shasum, test for a matching line in CHECKSUM_FILE (e.g., use grep -q -- "$ASSET"
"$CHECKSUM_FILE" or capture the grep output into a variable), and if no match
call fail with a clear message like "No checksum entry for $ASSET in
$CHECKSUM_FILE"; otherwise feed the matching line to shasum -a 256 -c - and keep
the existing failure path for actual checksum mismatches.
scripts/install.sh (1)

339-356: Good security improvement with checksum verification.

The implementation correctly downloads and verifies the SHA-256 checksum before extraction. A few observations:

  1. Missing tmpdir cleanup on failure: Unlike install-openshell.sh which has trap 'rm -rf "$tmpdir"' EXIT (line 80), this script does not set up a trap. If checksum verification fails, $tmpdir is left behind.

  2. Grep pattern could be more precise: grep "$ASSET" could match multiple lines if a filename is a substring of another (e.g., openshell-x86_64 matching both openshell-x86_64-apple-darwin.tar.gz and a hypothetical openshell-x86_64-v2-apple-darwin.tar.gz). Consider anchoring the pattern.

♻️ Suggested improvements
   tmpdir="$(mktemp -d)"
+  trap 'rm -rf "$tmpdir"' EXIT
   CHECKSUM_FILE="openshell-checksums-sha256.txt"

For more precise grep matching (optional):

-  (cd "$tmpdir" && grep "$ASSET" "$CHECKSUM_FILE" | shasum -a 256 -c -) \
+  (cd "$tmpdir" && grep -F "$ASSET" "$CHECKSUM_FILE" | shasum -a 256 -c -) \

Using -F treats the pattern as a fixed string rather than a regex, which is safer and slightly faster.

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@scripts/install.sh` around lines 339 - 356, The script currently downloads
checksums into $tmpdir but doesn't register a cleanup trap (leaving tmpdir if
verification fails) and uses grep "$ASSET" which can match substrings; add a
trap like the one in install-openshell.sh (trap 'rm -rf "$tmpdir"' EXIT)
immediately after creating tmpdir to ensure removal on exit/failure, and make
the verification grep precise by using fixed/anchored matching (e.g., use grep
-F or anchor the pattern to the exact filename when reading CHECKSUM_FILE) in
the (cd "$tmpdir" && grep ... "$CHECKSUM_FILE" | shasum -a 256 -c -) step so
only the exact ASSET entry is checked.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Nitpick comments:
In `@scripts/install-openshell.sh`:
- Around line 82-98: The checksum verification uses grep "$ASSET"
"$CHECKSUM_FILE" which can mis-match substrings; update the verification command
to use a fixed-string or exact-match grep (e.g., use grep -F or grep -x) so
CHECKSUM_FILE is searched precisely for the ASSET entry before piping to shasum
-a 256 -c -; modify the line that runs (cd "$tmpdir" && grep "$ASSET"
"$CHECKSUM_FILE" | shasum -a 256 -c -) to reference the chosen grep option and
ensure variables GH_TOKEN, ASSET, CHECKSUM_FILE and tmpdir remain unchanged.
- Around line 96-97: The failure message is ambiguous when the checksum file
lacks an entry for ASSET; before piping into shasum, test for a matching line in
CHECKSUM_FILE (e.g., use grep -q -- "$ASSET" "$CHECKSUM_FILE" or capture the
grep output into a variable), and if no match call fail with a clear message
like "No checksum entry for $ASSET in $CHECKSUM_FILE"; otherwise feed the
matching line to shasum -a 256 -c - and keep the existing failure path for
actual checksum mismatches.

In `@scripts/install.sh`:
- Around line 339-356: The script currently downloads checksums into $tmpdir but
doesn't register a cleanup trap (leaving tmpdir if verification fails) and uses
grep "$ASSET" which can match substrings; add a trap like the one in
install-openshell.sh (trap 'rm -rf "$tmpdir"' EXIT) immediately after creating
tmpdir to ensure removal on exit/failure, and make the verification grep precise
by using fixed/anchored matching (e.g., use grep -F or anchor the pattern to the
exact filename when reading CHECKSUM_FILE) in the (cd "$tmpdir" && grep ...
"$CHECKSUM_FILE" | shasum -a 256 -c -) step so only the exact ASSET entry is
checked.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: aed8a69f-7e86-4cd5-94b6-bd88862a8fe3

📥 Commits

Reviewing files that changed from the base of the PR and between c55a309 and 4233787.

📒 Files selected for processing (3)
  • scripts/install-openshell.sh
  • scripts/install.sh
  • test/runner.test.js

@ericksoa ericksoa self-assigned this Mar 23, 2026
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