r/SelfHosting • u/Budget_Complex_3132 • 6d ago
Found out about the php2shell fixes from a hosting email. How do you keep track of PHP updates on servers you barely touch?
This is kind of embarrassing, but I didn't hear about the php2shell fixes from any process of my own, I heard about them from a hosting email. Then I spent an evening SSHing into boxes to work out which ones even run PHP.
A handful of small client sites on VPSes plus a couple of internal tools, all headless. Some are on distro packages, one is on a PPA, and one is a Docker image I haven't rebuilt in about a year, which I now realise means it never got the fix.
What do you actually do to stay on top of this? Automatic updates, some monitoring tool, a spreadsheet?
I'd like the next one to not be a surprise.
2
u/Stock_Feedback_9648 6d ago
Three things cover most of it. 1) unattended-upgrades (or dnf-automatic), and add the PPA to its allowed origins, since by default it only takes the distro security pocket, so the PPA box would've missed the fix. 2) The Docker image is the real gap: nothing rebuilds it. A scheduled CI rebuild with
--pull(weekly is plenty) plus Diun or Renovate to tell you when the base image changes solves that, and a Trivy scan of running images flags stale PHP. 3) A tiny inventory:ansible all -m shell -a 'php -v', or a cron script that writesphp -vand package versions somewhere, tells you in seconds which boxes are affected next time. For the news side, your distro's security-announce list plus watching php/php-src releases on GitHub means you hear about it before the hosting email does.3
u/siteflux 5d ago
the docker one is the sneaky one, if you never rebuild it you never get the base image patch. i'd pin the php version in a compose file and let a nightly watch check which containers are out of date, that kills the spreadsheet.
1
u/jaysuncle 5d ago
I have scripts that run every day checking for updates. I get status notifications from these scripts.
1
u/FarToe1 5d ago
It's a problem, even for a fulltime sysadmin. The amount and speed of critical disclosures is overwhelming and difficult to stay on top of, even with reading lots of websites, rss feeds, reddit and mailing lists. Noise to signal is huge.
Do at least this;
Those two things can remove a lot of pressure from you. It's nice to learn about these exploits and when you check, find your servers have already updated and are protected.
(Disclaimer: Updating frequently does carry a chance of picking up a nasty from a compromised supply-chain release, but generally distro packages are well checked. The risk seems to be more from non-repo installs; pip, npm etc. The bottom line is that no method is truly safe, so ensure you have good backups of what's important, including an offline one)
1
u/CollegeElectricalKid 2d ago
Distro packages plus unattended-upgrades covers most of it. The Docker image is the one that will bite you, because nothing updates it unless you rebuild, so put docker build pull on a schedule. I keep a tiny inventory file with every server, how PHP got there and which version it's on, plus a monthly reminder to run php -v everywhere. My client sites are on Contabo VPSes and their October email was clear that the host side was theirs and PHP on my box was mine, which is fair. Also worth knowing that 8.2 hits end of life on 31 December, so plan those jumps now.