From b8050fb11d63709acd14ab83cbbf315429f27de1 Mon Sep 17 00:00:00 2001 From: Yossi Eliaz Date: Wed, 29 Apr 2026 12:31:57 +0300 Subject: [PATCH] fix(docker): require single primary key before Docker apt GPG pin Count `pub` records in gpg --with-colons output and abort unless exactly one primary key is present, so we cannot verify only the first fingerprint while apt imports every certificate from the armored file. Subkeys use `sub`, so the official Docker signing key remains a single pub. Fixes #74234 Made-with: Cursor --- Dockerfile | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/Dockerfile b/Dockerfile index 68856898568..97185755de9 100644 --- a/Dockerfile +++ b/Dockerfile @@ -238,9 +238,16 @@ RUN --mount=type=cache,id=openclaw-bookworm-apt-cache,target=/var/cache/apt,shar ca-certificates curl gnupg && \ install -m 0755 -d /etc/apt/keyrings && \ # Verify Docker apt signing key fingerprint before trusting it as a root key. + # Require exactly one primary key (`pub` in --with-colons; subkeys use `sub`) so we + # never pin the first fingerprint while apt trusts extra keys from the same file. # Update OPENCLAW_DOCKER_GPG_FINGERPRINT when Docker rotates release keys. curl -fsSL https://download.docker.com/linux/debian/gpg -o /tmp/docker.gpg.asc && \ expected_fingerprint="$(printf '%s' "$OPENCLAW_DOCKER_GPG_FINGERPRINT" | tr '[:lower:]' '[:upper:]' | tr -d '[:space:]')" && \ + docker_gpg_pub_count="$(gpg --batch --show-keys --with-colons /tmp/docker.gpg.asc | awk -F: '$1 == "pub" { c++ } END { print c+0 }')" && \ + if [ "$docker_gpg_pub_count" != "1" ]; then \ + echo "ERROR: Docker apt key must contain exactly one public key (found $docker_gpg_pub_count); refusing a multi-key file." >&2; \ + exit 1; \ + fi && \ actual_fingerprint="$(gpg --batch --show-keys --with-colons /tmp/docker.gpg.asc | awk -F: '$1 == "fpr" { print toupper($10); exit }')" && \ if [ -z "$actual_fingerprint" ] || [ "$actual_fingerprint" != "$expected_fingerprint" ]; then \ echo "ERROR: Docker apt key fingerprint mismatch (expected $expected_fingerprint, got ${actual_fingerprint:-})" >&2; \