Repository navigation
ci: check the WineHQ and apt.llvm.org signing keys' fingerprints - #4198
Conversation
The wine job wrote https://dl.winehq.org/wine-builds/winehq.key straight into /etc/apt/keyrings and the translator-tests job piped https://apt.llvm.org/llvm-snapshot.gpg.key into gpg --dearmor, so apt trusted whatever key those URLs served that day. Every other download in CI is pinned (actions by commit, glslang by SHA-256, the Vulkan headers by commit). scripts/check_apt_key.py (standard library, gpg --show-keys) requires the downloaded file to hold exactly one primary key with the given fingerprint; both steps now download to a temporary file, check it against the fingerprint each project publishes (WineHQ D43F6401...672F, apt.llvm.org 6084F3CF...7421) and only then install it. tests/test_check_apt_key.py: the parser and the check with a stand-in gpg (the key, another key, two primary keys, subkeys, an unreadable file, no gpg), the command line, and a scan of .github/workflows that fails for a key download not checked right after (both of today's downloads fail it on the old workflows). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Kam471
left a comment
There was a problem hiding this comment.
Ran this at f03dcbde on Windows 11:
python -I tests/test_check_apt_key.py-> 13 tests, OK.python -I tests/test_ci_registration.py-> 8 tests, OK.- Both modified workflow YAML files parse with PyYAML;
git diff --checkclean.
check_apt_key.py reads the downloaded key with gpg --show-keys --with-colons (no keyring import), requires exactly one primary key, normalizes spaces/case, and rejects a second primary key appended to the file; subkeys are allowed. Both steps now verify before gpg --dearmor/install, and the pinned fingerprints are the published LLVM and WineHQ ones.
This is a duplicate of #4188 (Flyander) but is the earlier claim: #3918's claim by @Exopus-0x65f7ad0 at 2026-11-22T23:14:47Z precedes #4188's claim at 23:41:32Z. Under the coordination rule, this PR should land and #4188 close; it also carries the tested helper that #4188 lacks. I'll note that on #4188.
|
Tested
One overlap: #4204 adds a second, unchecked AI-assisted. |
Flyander
left a comment
There was a problem hiding this comment.
The key pin is bypassable through the unvalidated WineHQ source configuration fetched by this job.
| key=$(mktemp) | ||
| wget -q -O "$key" https://dl.winehq.org/wine-builds/winehq.key | ||
| python3 -I scripts/check_apt_key.py "$key" D43F640145369C51D786DDEA76F1A20FF987672F | ||
| sudo install -m 644 "$key" /etc/apt/keyrings/winehq-archive.key |
There was a problem hiding this comment.
[P2] Pin or construct the WineHQ source stanza too. This pins the key file, but the next command still installs a .sources document downloaded directly from WineHQ without checking its contents. A modified stanza can set Trusted: yes, which makes APT trust the source even when authentication checks fail and bypasses the key fingerprint pin. Generate the small stanza locally with the intended URI, suite and Signed-By path, or validate the downloaded document and reject trust-bypass options. Debian documents that Trusted: yes disables parts of apt-secure: https://manpages.debian.org/testing/apt/sources.list.5.en.html.
There was a problem hiding this comment.
Checked just now: the live winehq-noble.sources (and winehq-jammy.sources) is these six lines, with no Trusted: option:
Types: deb
URIs: https://dl.winehq.org/wine-builds/ubuntu
Suites: noble
Components: main
Architectures: amd64 i386
Signed-By: /etc/apt/keyrings/winehq-archive.key
Writing it locally gives a byte-identical file (cmp exit 0 against the download), so the second wget can go:
codename=$(. /etc/os-release && echo "$VERSION_CODENAME")
printf 'Types: deb\nURIs: https://dl.winehq.org/wine-builds/ubuntu\nSuites: %s\nComponents: main\nArchitectures: amd64 i386\nSigned-By: /etc/apt/keyrings/winehq-archive.key\n' "$codename" \
| sudo tee "/etc/apt/sources.list.d/winehq-$codename.sources" >/dev/nullAI-assisted.
Claim: #3918 (comment) (new BUILD item)
Problem
Two CI steps trust an apt signing key on first fetch:
.github/workflows/runtime.yml(wine job,winehq-stable):sudo wget -q -O /etc/apt/keyrings/winehq-archive.key https://dl.winehq.org/wine-builds/winehq.key.github/workflows/ci.yml(translator-tests):curl -fsSL https://apt.llvm.org/llvm-snapshot.gpg.key | sudo gpg --dearmor -o /usr/share/keyrings/llvm-snapshot.gpgapt then installs whatever those keys sign. Every other download in CI is pinned (actions by commit SHA, glslang by SHA-256, the Vulkan headers by commit), so these two keys were the one unpinned trust root: a key swapped on either server (or appended to the file) would be trusted without anyone noticing.
Change
scripts/check_apt_key.py KEYFILE FINGERPRINT(standard library; reads the file withgpg --show-keys --with-colons, which lists without importing): the file must hold exactly one primary key with that fingerprint (subkeys allowed). Exit 0/1, 2 on a usage error.mktempfile, check it, and only then install it (gpg --dearmor/install -m 644). Pinned fingerprints, as each project publishes them and as the keys served today read:D43F 6401 4536 9C51 D786 DDEA 76F1 A20F F987 672F6084 F3CF 814B 57C1 CF12 EFD5 15CF 4D18 AF4F 7421.sourcesfile WineHQ's step also downloads is unchanged: it only names the keyring; the packages' signatures are what the key protects.Tests
python -I tests/test_check_apt_key.py(new, picked up byci.yml's standard-library loop): 13 tests, OK. GnuPG is stood in for by a small Python program, so they need no gpg or real key: the pinned key (with a subkey) passes; another key, two primary keys, an empty file, an unreadable file and a missing gpg fail; usage errors exit 2. A workflow scan fails for any.key/.gpg/.ascdownload that is piped, written into apt's keyrings, or not checked bycheck_apt_key.pyright after; onmain's workflows it fails atci.yml:125andruntime.yml:217.gpg2.4.9: WineHQ key + WineHQ fingerprint → exit 0; LLVM key + LLVM fingerprint → exit 0; LLVM key + WineHQ fingerprint → exit 1 ("is key 6084…, expected D43F…"); both keys concatenated → exit 1 ("holds 2 primary keys"); junk bytes → exit 1.ci.ymllines run underbash -eo pipefail(withsudoechoed): the pinned fingerprint reaches the install line; a wrong one stops the step with exit 1 before it.tests/test_ci_registration.py,test_docs_repo_paths.py,test_text_write_line_endings.py: OK;scripts/check_no_game_data.py: clean.Limitations
ubuntu-24.04(python3,gpg2.4,wget,curl,install).AI-assisted (Claude Code). Tested on Windows 11 (Git for Windows gpg 2.4.9); no GPU or game files involved.