Skip to content

Commit ba2d91f

Browse files
fix(install): make checksum verification mandatory
verify_checksum() previously warned and continued when sha256sum was unavailable or the checksums file couldn't be downloaded. An attacker who can manipulate the download could serve a binary without the checksum file and have it silently installed. Fail the installation if: - sha256sum/shasum is not available - checksums file cannot be downloaded - filename not found in checksums file Closes #590 Signed-off-by: latenighthackathon <latenighthackathon@users.noreply.github.com>
1 parent 0ac1fbd commit ba2d91f

File tree

1 file changed

+7
-10
lines changed

1 file changed

+7
-10
lines changed

install.sh

Lines changed: 7 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -183,17 +183,15 @@ verify_checksum() {
183183
_vc_expected="$(grep "$_vc_filename" "$_vc_checksums" | awk '{print $1}')"
184184

185185
if [ -z "$_vc_expected" ]; then
186-
warn "no checksum found for $_vc_filename, skipping verification"
187-
return 0
186+
error "no checksum found for $_vc_filename in checksums file"
188187
fi
189188

190189
if has_cmd shasum; then
191190
echo "$_vc_expected $_vc_archive" | shasum -a 256 -c --quiet 2>/dev/null
192191
elif has_cmd sha256sum; then
193192
echo "$_vc_expected $_vc_archive" | sha256sum -c --quiet 2>/dev/null
194193
else
195-
warn "sha256sum/shasum not found, skipping checksum verification"
196-
return 0
194+
error "sha256sum or shasum is required to verify checksums"
197195
fi
198196
}
199197

@@ -256,12 +254,11 @@ main() {
256254

257255
# Verify checksum
258256
info "verifying checksum..."
259-
if download "$_checksums_url" "${_tmpdir}/checksums.txt"; then
260-
if ! verify_checksum "${_tmpdir}/${_filename}" "${_tmpdir}/checksums.txt" "$_filename"; then
261-
error "checksum verification failed for ${_filename}"
262-
fi
263-
else
264-
warn "could not download checksums file, skipping verification"
257+
if ! download "$_checksums_url" "${_tmpdir}/checksums.txt"; then
258+
error "could not download checksums file from ${_checksums_url}"
259+
fi
260+
if ! verify_checksum "${_tmpdir}/${_filename}" "${_tmpdir}/checksums.txt" "$_filename"; then
261+
error "checksum verification failed for ${_filename}"
265262
fi
266263

267264
# Extract

0 commit comments

Comments
 (0)