Skip to main content
RunBook Academy

LinuxXXIX · Linux Security HardeningUpdates

Package update discipline - patching as a security control

Foundation⏱ ~10 minaptdnf

What you'll learn

  • Apply a patch frequency appropriate for the environment
  • Configure unattended upgrades safely
  • Validate patches before production deploy
  • Track CVEs and react to high-severity findings

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.

Patches are the single most impactful security control. A known-vulnerable package with an available patch is a known-vulnerable host. The discipline: patch frequently, test before production, react to high-severity findings within hours.

The patch lifecycle

1. Vulnerability disclosed
2. CVE assigned
3. Distribution package released
4. Testing
5. Production deploy
6. Verification

The total time from step 1 to step 6 is the mean time to patch (MTTP). The goal: minimise MTTP for high-severity CVEs.

Patch frequency

SeverityMTTP target
Critical (RCE, auth bypass)Hours to 1 day
High (privilege escalation, info disclosure)Days to 1 week
MediumWeeks
LowMonthly or quarterly

Critical CVEs need emergency patching. High CVEs patch in the next regular cycle. Medium and low patch in batch.

Automated patching

For non-critical environments, unattended upgrades are acceptable:

# Debian/Ubuntu
sudo apt install unattended-upgrades
sudo dpkg-reconfigure unattended-upgrades
# /etc/apt/apt.conf.d/50unattended-upgrades
Unattended-Upgrade::Allowed-Origins {
    "${distro_id}:${distro_codename}-security";
};
Unattended-Upgrade::AutoFixInterruptedDpkg true;
Unattended-Upgrade::MinimalSteps true;
Unattended-Upgrade::Remove-Unused-Kernel-Packages true;
Unattended-Upgrade::Remove-New-Unused-Dependencies true;
Unattended-Upgrade::Remove-Unused-Dependencies false;
Unattended-Upgrade::Automatic-Reboot false;
# /etc/apt/apt.conf.d/20auto-upgrades
APT::Periodic::Update-Package-Lists "1";
APT::Periodic::Unattended-Upgrade "1";

For RHEL family, use dnf-automatic:

sudo dnf install dnf-automatic
sudo systemctl enable --now dnf-automatic.timer
# /etc/dnf/automatic.conf
[commands]
upgrade_type = security
apply_updates = yes

Test before production

Critical patches should be tested in a non-production environment first:

# In staging
sudo apt upgrade -y

# Test critical services
sudo systemctl status nginx postgresql sshd

# Run application smoke tests
curl -I https://staging.example.com

If the staging tests pass, deploy to production with automation:

# Via configuration management
ansible-playbook -i prod update.yml

React to high-severity findings

Subscribe to security advisories for your distribution:

  • Ubuntu: https://ubuntu.com/security/notices
  • Debian: https://security-tracker.debian.org/
  • RHEL: https://access.redhat.com/security/security-updates/
  • SUSE: https://www.suse.com/support/security/

For high-severity CVEs:

  1. Confirm the host is affected (check installed package version against the CVE).
  2. Test the patch in staging.
  3. Apply to production within the MTTP target.
  4. Verify the vulnerability is fixed.

Track CVEs

# Debian/Ubuntu: pending updates, then the CVEs behind them
apt list --upgradable
sudo apt install debsecan
debsecan --suite bookworm --format detail
debsecan --suite bookworm --only-fixed --format packages

# RHEL family: pending security errata, then the CVE mapping
dnf check-update --security
dnf updateinfo list security
dnf updateinfo info --cve CVE-2024-3094

# Compliance scan (installed as the openscap-scanner package)
sudo oscap oval eval --results oval-results.xml com.redhat.rhsa-all.xml

apt list --upgradable and dnf check-update --security match on repository metadata, so they list pending updates. They cannot tell you which CVEs you are exposed to, which are already closed by a backport, or which have no fix yet. That is what debsecan and dnf updateinfo add. See linux-scanning-and-detecting-vulns for the full treatment.

For fleet-wide visibility:

  • OpenSCAP: scan and report compliance with a security policy.
  • Anchore and Trivy: vulnerability scanners you can install and run yourself. Vulners is a commercial vulnerability database, not a distribution package; its scanner is a Python client that needs an API key.
  • Cloud-native: AWS Inspector, Azure Defender, GCP Security Command Center.

Common pitfalls

  • Unattended upgrades on production: critical services may break after an upgrade. Test in staging first.
  • Skipping security updates: missing security patches is the leading cause of successful attacks.
  • Manual upgrades on Friday: an unmonitored upgrade can cause an outage that nobody notices until Monday.
  • Forgetting reboots: kernel updates require a reboot. Track pending reboots with needs-restarting -r (RHEL) or /var/run/reboot-required (Debian).

Knowledge check

Knowledge check · 3 questions

  1. Q1. What is the right MTTP target for a critical CVE?

  2. Q2. Unattended upgrades should run on production without testing.

  3. Q3. Which of the following are valid sources for security advisories? Select all that apply.

Passing score: 75%. Answers are checked in this browser.