Skip to content

ServerKit is a lightweight, modern server control panel for managing web applications, databases, and services on your VPS or dedicated server. Built with Python/Flask backend and React frontend.

Refuse release tarballs without a checksum

Juan Denise6e94dd23a36
diff --git a/install.sh b/install.sh
index ea446374..ffea1c6a 100644
--- a/install.sh
+++ b/install.sh
@@ -1264,8 +1264,15 @@ fetch_release() {
halt "Checksum verification failed for release tarball."
fi
good "Checksum verified"
+ elif [ "${SERVERKIT_ALLOW_UNVERIFIED:-0}" = "1" ]; then
+ warn "No checksums.txt — installing UNVERIFIED (SERVERKIT_ALLOW_UNVERIFIED=1)"
else
- warn "Could not download checksums.txt — skipping verification"
+ # Every release publishes checksums.txt; without it the tarball
+ # cannot be trusted, so build from source instead.
+ warn "Could not download checksums.txt — not installing an unverified release; falling back to source."
+ rm -f "$tarball"
+ INSTALL_FROM_RELEASE=0
+ return 1
fi
fi
diff --git a/scripts/test/test_install.sh b/scripts/test/test_install.sh
index c99dcd11..419ce388 100644
--- a/scripts/test/test_install.sh
+++ b/scripts/test/test_install.sh
@@ -1060,6 +1060,36 @@ else
bad "fetch_release tag-fallback wrong: state [$res]: $(tr '\n' ';' < "$t/fetch.out" 2>/dev/null)"
fi
+# T31b — a missing checksums.txt used to be "skipping verification" and the
+# unverified tarball was installed. It must fall back to source instead,
+# removing the download, unless SERVERKIT_ALLOW_UNVERIFIED=1.
+cat > "$t/bin/curl" <<EOF
+#!/usr/bin/env bash
+out=""; url=""
+while [ \$# -gt 0 ]; do
+ case "\$1" in -o) out="\$2"; shift 2 ;; -*) shift ;; *) url="\$1"; shift ;; esac
+done
+case "\$url" in
+ *checksums.txt) exit 22 ;;
+ *.tar.gz) printf 'bytes' > "\$out" ;;
+ *) exit 22 ;;
+esac
+EOF
+chmod +x "$t/bin/curl"
+res="$( set -Eeuo pipefail; PATH="$t/bin:$PATH"
+ SERVERKIT_OFFLINE_TARBALL=""; SERVERKIT_VERSION="v9.9.9"; INSTALL_FROM_RELEASE=1
+ SERVERKIT_MIRROR_URL="http://mirror.invalid"; DL_ARCH=amd64
+ resolve_release_tag() { echo v9.9.9; }
+ rc=0; fetch_release >"$t/fetch.out" 2>&1 || rc=$?
+ left=no; [ -e /tmp/serverkit-v9.9.9-linux-amd64.tar.gz ] && left=yes
+ printf '%s|%s|%s' "$rc" "$INSTALL_FROM_RELEASE" "$left" )"
+if [ "$res" = "1|0|no" ] && grep -q 'not installing an unverified release' "$t/fetch.out"; then
+ ok "fetch_release falls back to source when checksums.txt is missing (no unverified install)"
+else
+ bad "fetch_release with no checksums.txt: state [$res]: $(tr '\n' ';' < "$t/fetch.out" 2>/dev/null)"
+fi
+rm -f /tmp/serverkit-v9.9.9-linux-amd64.tar.gz
+
# --------------------------------------------------------------------------
# T32 — I16: failures inside fetch_release's unpack/copy (corrupt download,
# disk full) must take the clean fallback-to-source path — return nonzero so
diff --git a/scripts/test/test_update.sh b/scripts/test/test_update.sh
index 99ae3765..6d95cb87 100644
--- a/scripts/test/test_update.sh
+++ b/scripts/test/test_update.sh
@@ -1028,6 +1028,48 @@ EOF
fi
fi
+# --------------------------------------------------------------------------
+# T20c — a missing checksums.txt used to be "skipping verification" and the
+# unverified tarball replaced the running panel. It must refuse unless the
+# operator opts out explicitly (SERVERKIT_ALLOW_UNVERIFIED=1).
+# --------------------------------------------------------------------------
+t="$WORK/t20c"; mkdir -p "$t/bin"
+printf 'fake-release-bytes\n' > "$t/tarball"
+cat > "$t/bin/curl" <<EOF
+#!/usr/bin/env bash
+out=""; url=""
+while [ \$# -gt 0 ]; do
+ case "\$1" in -o) out="\$2"; shift 2 ;; -*) shift ;; *) url="\$1"; shift ;; esac
+done
+case "\$url" in
+ *checksums.txt) exit 22 ;;
+ *) cp "$t/tarball" "\$out" ;;
+esac
+EOF
+chmod +x "$t/bin/curl"
+_t20c() {
+ (
+ set -Eeuo pipefail
+ export PATH="$t/bin:$PATH"
+ SERVERKIT_OFFLINE_TARBALL=""; SERVERKIT_MIRROR_URL="http://mirror.invalid"
+ SERVERKIT_ALLOW_UNVERIFIED="${1:-0}"
+ download_release v9.9.9
+ ) 2>"$t/stderr.txt"
+}
+if out="$(_t20c 0)"; then
+ bad "download_release accepted a release with no checksums.txt: [$out]"
+elif grep -q 'refusing an unverified release' "$t/stderr.txt"; then
+ ok "download_release refuses a release whose checksums.txt is missing"
+else
+ bad "download_release failed without saying why: $(cat "$t/stderr.txt")"
+fi
+if out="$(_t20c 1)" && [ -f "$out" ] && grep -q 'UNVERIFIED' "$t/stderr.txt"; then
+ ok "SERVERKIT_ALLOW_UNVERIFIED=1 installs it, loudly"
+ rm -rf "$(dirname "$out")"
+else
+ bad "SERVERKIT_ALLOW_UNVERIFIED=1 did not allow the unverified release"
+fi
+
# --------------------------------------------------------------------------
# T20b — deploy_release removes its download and unpack dirs. It used to leave
# the ~70 MB tarball's mktemp dir behind on every update (a 25 GB box had 11
diff --git a/scripts/update.sh b/scripts/update.sh
index 67c78e6c..98911744 100644
--- a/scripts/update.sh
+++ b/scripts/update.sh
@@ -866,8 +866,13 @@ download_release() {
halt "Checksum verification failed for release tarball."
fi
good "Checksum verified" >&2
+ elif [ "${SERVERKIT_ALLOW_UNVERIFIED:-0}" = "1" ]; then
+ warn "No checksums.txt — installing UNVERIFIED (SERVERKIT_ALLOW_UNVERIFIED=1)" >&2
else
- warn "Could not download checksums.txt — skipping verification" >&2
+ # Every release publishes checksums.txt; its absence means a broken
+ # mirror or a tampered download, and this replaces the running panel.
+ rm -rf "$tmp_dir"
+ halt "Could not download checksums.txt from ${base_url} — refusing an unverified release. Set SERVERKIT_ALLOW_UNVERIFIED=1 to override."
fi
echo "$output"