Skip to main content
RunBook Academy

LinuxXII · Repository Security and Supply ChainThird-party repos

Third-party repository risk

Intermediate⏱ ~10 minbashapt-cacheapt-configdnf repolist

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

Not yet marked complete on this device.

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.
Read-only / Safethird-party repo
$ apt-cache policy 'docker*' | head; dnf repolist
docker-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

Configuration changepin third-party
$ 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:

Read-only / Safeverify apt pin
$ apt-cache policy containerd.io
containerd.io:
Installed: (none)
Candidate: (none)
Version table:
1.7.27-1 50
50 https://download.docker.com/linux/ubuntu noble/stable amd64 Packages

Illustrative output

Scoping with dnf

Read-only / Safepriority field
$ 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

Read-only / Safeverify dnf priority
$ dnf config-manager --dump docker-ce-stable | grep -E '^(name|priority|enabled|gpgcheck)'
enabled = 1
gpgcheck = 1
name = Docker CE Stable - x86_64
priority = 200

Illustrative 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.

Read-only / Safeaudit repos (both formats)
$ grep -rhE '^(deb|deb-src) |^(Types|URIs|Suites|Components|Signed-By):' /etc/apt/sources.list /etc/apt/sources.list.d/ 2>/dev/null
Types: 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.gpg

Illustrative output

Read-only / Safeauthoritative repo list
$ apt-cache policy; ls /etc/yum.repos.d/ && dnf repolist -v
...

Illustrative output

  1. Inventory every third-party repository on each host, in both the one-line and deb822 formats. Remove ones no longer in use
  2. Verify each signing key fingerprint against the vendors published source, using the Signed-By keyring named in the stanza
  3. Demote priorities so the base distribution wins by default — Pin-Priority 50 on apt, priority=200 on dnf
  4. Confirm the effective value with apt-cache policy and dnf config-manager --dump, not by reading the config file
  5. Scope packages — only the specific packages from the third-party repo, not the entire repository
  6. Document the rationale for each repository in the runbook

Knowledge check

Knowledge check · 4 questions

  1. Q1. You are adding docker-ce.repo to a RHEL 9 host. What priority value keeps the base distribution ahead of Docker?

  2. Q2. A host can trust any number of third-party repositories without increased risk.

  3. Q3. Which of the following are correct third-party repository practices? Select all that apply.

  4. 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.