An upgrade installs Deno only when its sha256 matches (#908)

upgrade.sh downloaded Deno on every device whose Deno was older than the pinned
version and installed it without a check, so a forged TLS certificate (as the eMudhra
key compromise allowed) could replace the runtime yt-dlp uses.  The zip is now checked
against the same sha256 the install scripts pin; a mismatch skips the Deno install and
the upgrade continues.  A test requires every Deno download in the repo to be checked.

Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
lrnselfreliance 2026-10-30 20:48:12 -06:00 • committed by GitHub
parent dc3a8bb313
commit 70e915f610
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 23 additions and 0 deletions

View file

@ -186,8 +186,10 @@ upgrade_deno() {
ARCH=$(uname -m)
if [ "$ARCH" = "aarch64" ]; then
DENO_ARCH="aarch64-unknown-linux-gnu"
DENO_SHA256="d4589cc1ffcbf1995c92a0127d932aaf832ac70cfdcc6d5b7bf38043cf303575"
elif [ "$ARCH" = "x86_64" ]; then
DENO_ARCH="x86_64-unknown-linux-gnu"
DENO_SHA256="30455b845ffa6082209c3590269c910ad3b7efdf28c9879afd4006c47ae54197"
else
echo "Unsupported architecture for Deno: $ARCH"
return 1
@ -204,6 +206,8 @@ upgrade_deno() {
echo "Installing Deno ${DENO_VERSION} for ${ARCH}..."
curl -fsSL "https://github.com/denoland/deno/releases/download/${DENO_VERSION}/deno-${DENO_ARCH}.zip" -o /tmp/deno.zip
# `set -e` does not apply inside a function called with `||`, so a mismatch must return explicitly.
echo "${DENO_SHA256} /tmp/deno.zip" | sha256sum -c - || { rm -f /tmp/deno.zip; return 1; }
unzip -o /tmp/deno.zip -d /usr/local/bin/
chmod +x /usr/local/bin/deno
rm /tmp/deno.zip

View file

@ -28,3 +28,22 @@ def test_certifi_distrusts_root(label):
def test_deno_uses_system_trust_store(path, setting):
"""Deno's bundled roots only change with a Deno upgrade; the system store is patched by apt."""
assert setting in (PROJECT_DIR / path).read_text().splitlines()
DENO_DOWNLOAD = 'github.com/denoland/deno/releases/download/'
DENO_INSTALLER_DIRECTORIES = ('scripts', 'docker', 'debian-live-config', 'pi-gen')
def test_deno_downloads_are_checksummed():
"""Each script that downloads Deno checks the zip's sha256 before installing it, so the installed runtime does
not depend on TLS alone (a compromised CA can forge a certificate for github.com)."""
installers = {}
for directory in DENO_INSTALLER_DIRECTORIES:
for path in (PROJECT_DIR / directory).rglob('*'):
if path.is_file() and DENO_DOWNLOAD in (text := path.read_text(errors='ignore')):
installers[str(path.relative_to(PROJECT_DIR))] = text
assert len(installers) >= 6, 'expected the install scripts, Dockerfiles, and image builds'
unchecked = [path for path, text in installers.items()
if text.count(DENO_DOWNLOAD) > text.count('sha256sum -c')]
assert not unchecked, f'Deno is downloaded without a sha256 check in: {unchecked}'