Patching

Unattended-upgrades won't patch ondrej/php: here's why

Ubuntu's automatic security updates skip third-party repositories by default. What that means for PHP, Node.js and nginx packages, and how to stay patched.

You enabled automatic security updates on your Ubuntu servers. A few weeks later, a PHP security release comes out, and your servers are still running the old version. Nothing is broken. Unattended-upgrades is doing exactly what it's configured to do.

What unattended-upgrades updates by default

Ubuntu's unattended-upgrades package installs updates automatically, but only from the origins listed in its configuration. On a default install, /etc/apt/apt.conf.d/50unattended-upgrades allows Ubuntu's own security archive (and, for Ubuntu Pro users, the ESM archives):

Unattended-Upgrade::Allowed-Origins {
    "${distro_id}:${distro_codename}";
    "${distro_id}:${distro_codename}-security";
    "${distro_id}ESMApps:${distro_codename}-apps-security";
    "${distro_id}ESM:${distro_codename}-infra-security";
};

Packages from anywhere else are left alone. That's a sensible default: third-party repositories don't follow Ubuntu's stability rules, and an automatic jump to a new upstream version could break something.

Which packages that affects

On a typical web server, a lot of the most security-sensitive software comes from outside Ubuntu:

  • PHP from Ondřej Surý's PPA (ppa:ondrej/php), used by Laravel Forge, Ploi and countless install guides to get current PHP versions.
  • Node.js from NodeSource.
  • nginx from nginx.org's official repository.
  • Databases from MariaDB, MySQL or PostgreSQL's own repositories, and Redis from its vendor repository.

These packages follow upstream version numbers and get security fixes as new upstream releases. Unattended-upgrades won't install them unless you've allowed their origins.

Check where a package comes from

$ apt-cache policy php8.3-fpm
php8.3-fpm:
  Installed: 8.3.6-1+ubuntu22.04.1+deb.sury.org+1
  Candidate: 8.3.12-1+ubuntu22.04.1+deb.sury.org+1
  Version table:
     8.3.12-1+ubuntu22.04.1+deb.sury.org+1 500
        500 https://ppa.launchpadcontent.net/ondrej/php/ubuntu jammy/main amd64 Packages

Two things stand out: the package comes from the PPA, and a newer candidate is available but not installed. To see why, look at /var/log/unattended-upgrades/unattended-upgrades.log; packages from disallowed origins simply aren't considered.

Your options

  1. Upgrade on a schedule. Run sudo apt-get install --only-upgrade php8.3-fpm php8.3-cli (and the other PHP packages you use) as part of regular maintenance, then reload PHP-FPM.
  2. Allow the origin. Add the repository to Unattended-Upgrade::Origins-Pattern. Check the exact origin and label with apt-cache policy first. Only do this if you're comfortable with that repository's updates arriving automatically.
  3. Pin to a major version. Whatever you choose, keep each runtime on a supported major version; minor upgrades within it carry the security fixes.

Two more things automatic updates won't do

  • Restart services cleanly in every case. Updated libraries are only used once the processes using them restart.
  • Load a new kernel. Kernel updates install automatically but only take effect after a reboot. See Kernel updates need a reboot.

And automatic updates can quietly stop working: a held package, a full disk or a dpkg lock left behind can stop runs for weeks without anyone noticing.

How Uptavio handles it

Uptavio checks that automatic security updates are installed, switched on and actually running, and shows when they last succeeded. It knows where each package came from, so third-party builds are compared with upstream releases. When a vulnerable package needs a manual upgrade because its repository isn't covered by automatic updates, Uptavio says so and gives you the exact apt-get command, grouped across every server that needs it.

The takeaway

“Automatic updates are on” doesn't mean “everything is patched.” On most web servers, PHP, Node.js and nginx come from third-party repositories that unattended-upgrades skips by default. Know which packages those are, and make upgrading them part of your routine.


Uptavio checks this for you. Ubuntu-aware vulnerability scanning, outside-in exposure checks, patch and reboot tracking, and a To do list with the exact command for every fix. Free for 2 servers and 5 websites. Start free →

Know what to fix by lunchtime.

Two servers and five websites are free, forever. Every new organization also gets 14 days of Agency. No credit card, no inbound ports, and no keys handed over.