Repository navigation
Download the sury keyring into a private directory - #161
Merged
Merged
Conversation
Bootstrap downloaded the sury keyring package to the fixed path /tmp/magebox-sury-keyring.deb and then ran `sudo dpkg -i` on it. Any other local user could create that file first, or swap it between the download and the install, and have their own package installed as root. The package is now fetched with net/http into a fresh 0700 directory from os.MkdirTemp, created with O_EXCL, and the directory is removed afterwards. The download also no longer goes through a shell.
peterjaap
approved these changes
Nov 12, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
On Ubuntu releases that use packages.sury.org (e.g. 26.04),
configureSuryRepositorydownloaded the keyring package to a fixed, predictable path and then installed it as root:On a machine with more than one local user, another user can pre-create that file (or a symlink), or replace it between the download and
dpkg -i. Then dpkg installs their package as root, maintainer scripts included.Fix
downloadToPrivateFilefetches the file withnet/httpinto a freshos.MkdirTempdirectory (mode 0700). It creates the file withO_EXCLand returns a cleanup that removes the directory.configureSuryRepositoryuses it, so the download no longer goes throughsh -c+curl.I did not pin a SHA-256 of the
.deb. sury republishes the keyring package when keys rotate, so a pinned hash would break bootstrap on the next rotation. HTTPS plus the private directory closes the local attack this is about.Testing
make lint: 0 issuesmake test: passes