LinuxXII · Repository Security and Supply ChainThird-party repos
Third-party repository risk
What you'll learn
- Recognise the risks of third-party repositories
- Apply pin and priority rules to contain third-party risk
- Configure apt preferences or dnf priority to keep third-party repos scoped
- Audit which repositories the host trusts
Prerequisites
Verified against Ubuntu 24.04 LTS · Debian 12 (Bookworm) · RHEL 9.x · Rocky Linux 9.x · AlmaLinux 9.x · Linux kernel 6.1 LTS / 6.6 LTS · systemd 255+ · OpenSSH 8.7p1 (RHEL 9) / 9.6p1 (Ubuntu 24.04) · nftables 1.0.x · chrony 4.x · Pacemaker 2.1.x · Corosync 3.1.x · 2026-08-09
Third-party repositories are how production hosts get software that is not in the base distribution — Docker, NodeSource, Elasticsearch, Kubernetes. They are also one of the most common attack vectors: a compromised or malicious repository pushes backdoored packages to every host that trusts it.
The risk
A third-party repository has access to every host that trusts it. The compromises are well-documented:
- Compromised legitimate repository — the repository’s signing key or build infrastructure is breached.
- Malicious actor disguised as legitimate — fake repositories mimicking popular projects.
- Supply-chain compromise — a package maintainer’s account is compromised, allowing a backdoored version to be pushed.
$ apt-cache policy 'docker*' | head; dnf repolistdocker-ce:
Installed: (none)
Candidate: 5:26.1.3-1
Version table:
5:26.1.3-1 500
500 https://download.docker.com/linux/ubuntu noble/stable amd64 Packages
docker-ce-cli:
...Illustrative output
Scoping with apt preferences
$ sudo tee /etc/apt/preferences.d/docker-pin.pref >/dev/null <<'EOF'
Package: docker-ce
Pin: origin download.docker.com
Pin-Priority: 50
Package: docker-ce-cli
Pin: origin download.docker.com
Pin-Priority: 50
Package: containerd.io
Pin: origin download.docker.com
Pin-Priority: 50
EOF
sudo apt update...Illustrative output
Confirm the result rather than assuming it:
$ apt-cache policy containerd.iocontainerd.io:
Installed: (none)
Candidate: (none)
Version table:
1.7.27-1 50
50 https://download.docker.com/linux/ubuntu noble/stable amd64 PackagesIllustrative output
Scoping with dnf
$ cat /etc/yum.repos.d/docker-ce.repo[docker-ce-stable]
name=Docker CE Stable - $basearch
baseurl=https://download.docker.com/linux/centos/$releasever/$basearch/stable
enabled=1
gpgcheck=1
gpgkey=https://download.docker.com/linux/centos/gpg
priority=200
Illustrative output
$ dnf config-manager --dump docker-ce-stable | grep -E '^(name|priority|enabled|gpgcheck)'enabled = 1
gpgcheck = 1
name = Docker CE Stable - x86_64
priority = 200Illustrative output
Auditing the trust store
The audit has to be format-agnostic. Since Ubuntu 24.04 the
default is the deb822 .sources format in
/etc/apt/sources.list.d/, not the one-line .list format, so
any sweep that globs *.list reports zero repositories on a
current host — while Docker and NodeSource sit there
configured. A glob with no directory prefix is worse still: it
matches against the current working directory, not the
repository directory.
$ grep -rhE '^(deb|deb-src) |^(Types|URIs|Suites|Components|Signed-By):' /etc/apt/sources.list /etc/apt/sources.list.d/ 2>/dev/nullTypes: deb
URIs: https://download.docker.com/linux/ubuntu
Suites: noble
Components: stable
Signed-By: /etc/apt/keyrings/docker.asc
Types: deb
URIs: http://archive.ubuntu.com/ubuntu/
Suites: noble noble-updates noble-backports
Components: main restricted universe multiverse
Signed-By: /usr/share/keyrings/ubuntu-archive-keyring.gpgIllustrative output
$ apt-cache policy; ls /etc/yum.repos.d/ && dnf repolist -v...Illustrative output
- Inventory every third-party repository on each host, in both the one-line and deb822 formats. Remove ones no longer in use
- Verify each signing key fingerprint against the vendors published source, using the Signed-By keyring named in the stanza
- Demote priorities so the base distribution wins by default — Pin-Priority 50 on apt, priority=200 on dnf
- Confirm the effective value with
apt-cache policyanddnf config-manager --dump, not by reading the config file - Scope packages — only the specific packages from the third-party repo, not the entire repository
- Document the rationale for each repository in the runbook
Knowledge check
Knowledge check · 4 questions
Q1. You are adding docker-ce.repo to a RHEL 9 host. What priority value keeps the base distribution ahead of Docker?
Q2. A host can trust any number of third-party repositories without increased risk.
Q3. Which of the following are correct third-party repository practices? Select all that apply.
Q4. Your quarterly audit script runs `for f in *.list; do cat $f; done` and reports no third-party repositories on a fleet of Ubuntu 24.04 hosts. What should you conclude?
Passing score: 75%. Answers are checked in this browser.