Lesson 12 of 14 · 20m
Patching like a pipeline, not a chore
unattended-upgrades pinned to -security, needrestart for stale libraries, and why a patched package still needs a restart.
An apt list --upgradable nobody ran in six months isn't a backlog — it's an inventory of CVEs you already know about. The wrong mental model is "patching means running upgrade when someone remembers." The correct model is a pipeline: security updates apply themselves, the process list gets checked for stale libraries, and reboots get scheduled for the few changes that actually need one.
The pipeline
On Debian/Ubuntu, unattended-upgrades already exists; most boxes just never turned it on:
apt install unattended-upgrades
dpkg-reconfigure -plow unattended-upgrades # interactive enable/etc/apt/apt.conf.d/50unattended-upgrades decides what gets applied — the Allowed-Origins stanza should pin ${distro_id}:${distro_codename}-security (and usually -updates), not everything. Security-only unattended upgrades are the sane default: the fixes that close known holes land overnight without surprise-upgrading your PHP minor version at 4 a.m.
On the RHEL family it's dnf-automatic: apply_updates = yes in /etc/dnf/automatic.conf, then enable dnf-automatic-install.timer. dnf needs-restarting -r is the RHEL-side reboot check; plain needs-restarting lists processes using updated libraries, the same job needrestart does on Debian.
A patched binary that never restarted is still vulnerable
apt replaces files on disk; it does not restart processes. Your app keeps the old OpenSSL mapped in memory until it restarts — the package is patched and the vulnerability is still live. needrestart exists to catch exactly this:
needrestart -r l # list stale services/libs, non-interactive
cat /var/run/reboot-required 2>/dev/null # kernel or libc says: rebootThis is not theoretical: regreSSHion (CVE-2024-6387, July 2024) was an unauthenticated RCE in sshd's signal handler — boxes that "installed the patch" but never restarted sshd kept the exploitable code resident. After patching sshd, openssl, systemd, or libc: restart the service or schedule the reboot. needrestart automates the boring part.
Routine checks that take ninety seconds
apt list --upgradable 2>/dev/null | head -30
apt-get -s upgrade | tail -10 # simulated — nothing applied
apt-get --with-new-pkgs upgrade # take updates that pull new deps
apt-mark hold postgresql-16 # pin what you change deliberately
apt changelog openssh-server | head -40 # what the update actually fixesUbuntu's phased updates (Phased-Update-Percentage in apt policy) roll some packages out gradually — "the update exists but apt says nothing's new" is usually this, not a bug. And apt-listchanges surfaces NEWS and changelog entries before install — on interactive sessions it's the difference between "applied an update" and "knew what changed."
Know your reboot cadence too: kernel, glibc, systemd, openssl, and microcode changes are only complete after a reboot or a full service restart. unattended-upgrades can reboot on a schedule (Unattended-Upgrade::Automatic-Reboot and Automatic-Reboot-Time in 50unattended-upgrades) — pick a window and own it, or the patched kernel sits installed-but-unused indefinitely.
Try this
On a scratch VM: install unattended-upgrades, restrict it to -security, run unattended-upgrade --dry-run --debug and read what it would do. Then upgrade a library a running process has mapped, run needrestart -r l, restart the process, run it again — watch the stale list empty. That is the difference between "package patched" and "vulnerability closed."
Triage the CVE noise
Not every CVE in apt list --upgradable deserves your evening. Debian's security tracker and debsecan score what's actually reachable on your box — a critical bug in a library nothing calls is lower priority than a medium bug in your internet-facing sshd. Patch the ones with an exploit path to your attack surface first: anything reachable from the network, anything root or uid-0-adjacent, anything that parses untrusted input. The rest lands on the normal cadence.
Pitfalls
- Auto-applying everything including majors: an unattended Postgres or Docker major bump is an outage you scheduled yourself.
- Forgetting the kernel: apt installs the new kernel alongside the old; you run the old one until reboot — and unattended-upgrades won't reboot unless told.
apt-mark holdand forgetting: a held package is a permanent exemption from security fixes. Review holds quarterly.- "We patch monthly" on an internet-facing box: exploit kits turn public CVEs around in days. Security updates land on a tighter clock than that.
Was this lesson helpful?
Keep reading
Related articles from the SudoSecurity blog.
Self-Host OpenClaw: VPS Setup to Production (2026)
Self-host OpenClaw from zero to production. Server provisioning, SSH lockdown, Docker, reverse proxy, Fail2ban, performance tuning, and full backup strategy in one guide.
Zero Trust Everything: The Complete Guide to Self-Hosting Teleport for Secure Infrastructure Access
SudoSecurity runs Teleport internally for everything — admin panel access, secure database connections, Kubernetes, and zero-trust philosophy across our entire team. This is the complete technical guide to installing, configuring, and running your own self-hosted Teleport cluster from scratch.
Red Hat Called This Bug a 5.9. Two Weeks Later It Was a 9.8.
CVE-2026-98432 is a use-after-free in the IPv4 TCP handshake, reachable by anybody who can reach a listening port, sitting in the kernel since 4.4. Red Hat scored it 5.9 moderate and deferred the fix. Then 8.1. Then 9.8.
Self-Hosting Vaultwarden Without Trusting the Defaults
Vaultwarden gives you a Bitwarden-compatible password server in one container and about ten minutes. The defaults that make that possible leave org creation open, audit logging off, accounts on PBKDF2, and a rate limiter that trusts a header anyone can set.