Sub topic 7
Security-only updates on dnf and on Debian/Ubuntu
This chapter assumes you can use a shell and sudo, know how apt and dnf refresh metadata, and can read apt list --upgradable and dnf check-update output. You will learn how to install only security fixes on each family. The two families do it in different ways, and the differences affect what you can safely automate.
Why security-only updates exist
A full upgrade changes many packages at once: bug fixes, new features, and sometimes behavior changes. A security-only run narrows the change set to packages that fix a published vulnerability. Fewer packages change, so there is less to test and less that can break. You still close the known holes.
Security-only updating is not free of side effects:
- A security fix can pull in dependencies that are not security fixes themselves.
- A kernel or libc fix still needs a reboot.
- Over time, skipping non-security updates lets the system drift from what your test machines run.
Treat it as a way to cut risk between regular full patch windows, not as a replacement for them.
How dnf marks security updates
On RHEL-family systems, repositories publish advisory data called updateinfo metadata, next to the package metadata. Each advisory has an ID (RHSA for security, RHBA for bug fixes, RHEA for enhancements), a type, a severity, a list of CVEs, and the packages that fix it. dnf reads this data when you filter with --security.
Because the filter depends on updateinfo, it only works when your repositories provide it. Red Hat, AlmaLinux, Rocky Linux, and CentOS Stream repositories do. Some third-party repositories do not, and for those --security finds nothing even when updates exist. An empty result therefore does not always mean the system is current.
Listing and inspecting security advisories
dnf updateinfo list --security
dnf updateinfo info --security
dnf check-update --security
echo "exit code: $?"dnf updateinfo list --securityprints one line per advisory: the ID, the severity, and the package.dnf updateinfo info --securityprints the full text for each advisory, including the description, the CVEs, and the references.dnf check-update --securityshows only the packages that carry a security fix. It exits with 100 when there are some and 0 when there are none, so scripts can branch on it.
You can also filter by a single advisory, a CVE, or a severity:
dnf updateinfo list --cve CVE-2024-6387
sudo dnf upgrade --advisory=RHSA-2024:4312
sudo dnf upgrade --sec-severity=Critical
sudo dnf upgrade --sec-severity=ImportantThese options are useful during an incident, when you want one specific fix on a few machines without touching anything else. The advisory ID and CVE above are examples. Use IDs from your own updateinfo list output.
Applying security updates
sudo dnf upgrade --securitydnf shows the transaction summary and asks for confirmation before it installs anything. Read the list of packages. If it includes more than you expected, those are dependencies of the security fixes. Then check whether a reboot is needed:
sudo dnf needs-restarting -r
echo "exit code: $?"A kernel advisory is the common case. The new kernel is installed but not running until you reboot.
How Debian and Ubuntu separate security updates
apt has no --security option. Debian and Ubuntu separate security fixes by where the package comes from. Each release has several archive sections, called pockets or suites, and security fixes go in their own:
| Distribution | Security suite | Typical host |
|---|---|---|
| Debian 12 | `bookworm-security` | `deb.debian.org/debian-security` |
| Ubuntu 22.04 | `jammy-security` | `security.ubuntu.com/ubuntu` (or your mirror) |
| Ubuntu 24.04 | `noble-security` | `security.ubuntu.com/ubuntu` (or your mirror) |
The release's regular suites (jammy, jammy-updates) carry other changes. Ubuntu also publishes security fixes for the packages it supports under Ubuntu Pro in separate ESM suites (esm-infra-security, for example). Those need an attached Pro subscription, which is free for personal use on a limited number of machines.
Seeing which pending updates come from a security suite
apt list --upgradable does not show the suite. Simulate the upgrade and look at the origin on each line instead:
sudo apt update
apt-get -s upgrade | grep '^Inst'
apt-get -s upgrade | grep '^Inst' | grep -i securityThe -s option simulates the upgrade and changes nothing. Each Inst line ends with the origin in brackets, for example Ubuntu:22.04/jammy-security or Debian-Security:12/stable-security. The second grep keeps only the lines whose origin mentions a security suite. If a package shows up under both a security suite and -updates, the newest version wins, and the origin shown is the one that version comes from.
You can read apt-cache policy for a single package to see every version and the suite that supplies it:
apt-cache policy opensslInstalling only the security packages
There is no single built-in command. You have two reliable options.
The first is to let unattended-upgrade do one run, since it already restricts itself to the origins you allow. Run it by hand so you see the output:
sudo unattended-upgrade --dry-run --debug
sudo unattended-upgrade -vThe first command shows what it would install and which origins it accepted. The second installs those packages. This is the most dependable method because the allowed origins are explicit and the tool is the same one your automation uses.
The second option is to name the packages yourself. Take the list from the simulation above and install them with --only-upgrade, so apt never installs a package that is missing:
sudo apt install --only-upgrade openssl libssl3Naming packages works for one or two urgent fixes. It does not scale to a long list.
What unattended-upgrades allows by default
The allowed origins are set in /etc/apt/apt.conf.d/50unattended-upgrades. A default Ubuntu file enables the main release and security suites and leaves -updates commented out:
// /etc/apt/apt.conf.d/50unattended-upgrades (excerpt, Ubuntu)
Unattended-Upgrade::Allowed-Origins {
"${distro_id}:${distro_codename}";
"${distro_id}:${distro_codename}-security";
"${distro_id}ESM:${distro_codename}-infra-security";
// "${distro_id}:${distro_codename}-updates";
};The first line matches the release pocket itself. After release day that pocket is frozen, so it rarely changes. The -security line is the one that matters. Debian uses a different syntax, with origin=Debian,codename=${distro_codename}-security,label=Debian-Security, so do not paste the Ubuntu lines into a Debian file.
Comparing the two approaches
| Question | dnf (RHEL family) | apt (Debian/Ubuntu) |
|---|---|---|
| How is a security update identified? | Advisory type in `updateinfo` metadata | The suite the package comes from |
| One command to list them? | `dnf updateinfo list --security` | No. Simulate and filter by origin |
| One command to install only them? | `dnf upgrade --security` | `unattended-upgrade`, or name the packages |
| Filter by CVE or severity? | Yes | No |
| Depends on third-party repository data? | Yes, repos need `updateinfo` | Yes, repos must use a separate security suite |
Gotchas
- Missing metadata gives a false all-clear. On dnf, a repository without
updateinfohides its security fixes from--security. Comparednf check-updatewithdnf check-update --securityfor a repository you do not know. - Dependencies come along. Both families upgrade required libraries as part of a security fix. Review the transaction before you confirm it.
- Newer than the fix. With
--security, dnf may install the version named in the advisory rather than the newest version in the repository. A later full upgrade then moves the package again. - Services keep running old code. Installing a fixed library does not change processes that already loaded the old one. Restart affected services or reboot, as covered in the chapter on reboots and restarts.
- Version numbers backport. Distributions often patch an older version instead of moving to a new upstream release. A scanner that only compares version numbers may report a hole that is already fixed. Check the advisory or changelog (
rpm -q --changelog openssl | head, orapt changelog openssl) for the CVE.
Exercise
A RHEL 9 server shows nothing for dnf updateinfo list --security, but dnf check-update lists 14 pending packages. Name two possible explanations and one command that helps tell them apart.
Show answer
Either none of the 14 updates are security fixes, or a repository that supplies them has no updateinfo metadata, so dnf cannot mark them as security fixes. Running dnf updateinfo list (without --security), or dnf repolist followed by checking which repository each pending package comes from, helps. If no advisories show up at all for a repository, its metadata lacks updateinfo. You can also read the changelog of a suspicious package with rpm -q --changelog to look for CVE references.
Exercise
On an Ubuntu 22.04 server, how do you list which pending updates come from a security suite without installing anything, and why does apt list --upgradable not do this on its own?
Show answer
Run apt-get -s upgrade | grep '^Inst' | grep -i security. The -s option simulates the upgrade, and each Inst line ends with the package's origin, such as Ubuntu:22.04/jammy-security. apt list --upgradable shows the new version but not the suite it comes from, so it cannot be filtered this way.