Post

Note - Security event PHP

Note - Security event PHP

🛡️ Post-Mortem: Handling a Critical PHP Vulnerability (php2shell)

Note for my private blog – for future memory and learning. 📝


🖥️ My Setup

  • OS: Ubuntu 24.04 LTS (Noble Numbat)
  • Base Version: PHP 8.3.6

1️⃣ Wednesday: The Alarm Goes Off 🚨

Reports are flooding the internet about a critical PHP vulnerability. Everyone needs to act now!

  • Officially, the bug is reported fixed in PHP 8.3.36.
  • I ran sudo apt update, but the system insisted that no updates were available for my PHP 8.3.6.

My Acute Crisis Handling: ⚔️ Even though the update wasn’t showing up in apt yet, I locked the door manually via the PHP configuration (php.ini):

1
file_uploads = Off

After that, I ran a full system upgrade to ensure I had the latest patches and rebooted the machine:

1
sudo apt upgrade -y && sudo reboot

2️⃣ Thursday: Truth Time in the Terminal 🔍

I asked my AI companion for guidance to verify if my server was safe now.

Step A: Check the installed package version

1
dpkg -l | grep php8.3-cli

Output on my screen:

1
ii  php8.3-cli                      8.3.6-0ubuntu0.24.04.13                          amd64        command-line interpreter for the PHP scripting language

AI confirmed: Looking good! My machine updated automatically in the background.

Step B: When did it actually happen? I dove into the installation logs to check the timeline:

1
grep -E "configure php8.3-cli" /var/log/dpkg.log

Output:

1
2
2026-10-21 06:34:18 configure php8.3-cli:amd64 8.3.6-0ubuntu0.24.04.12 <none>
2026-10-22 06:51:45 configure php8.3-cli:amd64 8.3.6-0ubuntu0.24.04.13 <none>

💡 Conclusion: The critical version .13 landed completely automatically on my server this morning at 06:51:45 AM via Ubuntu’s automatic background upgrades!


3️⃣ When Do the Automatic Updates Run? ⏱️

To understand the mechanics of these background updates, I checked the system timers:

1
systemctl list-timers apt-daily-upgrade.timer

Output:

1
2
NEXT                         LEFT LAST                               PASSED       UNIT                    ACTIVATES
Fri 2026-10-23 06:09:24 CEST  20h Thu 2026-10-22 06:51:19 CEST 2h 48min ago apt-daily-upgrade.timer apt-daily-upgrade.service

This tool wakes up the unattended-upgrades service twice a day to download and install critical security patches.


4️⃣ Experiment: Mail Notifications on Update 📧

I attempted to set up emails to get alerted whenever the server performs a background upgrade.

Installing the SMTP client:

1
sudo apt update && sudo apt install postfix bsd-mailx -y

Editing the unattended-upgrades config:

1
sudo vi /etc/apt/apt.conf.d/50unattended-upgrades

Uncommented the line and entered my email:

1
Unattended-Upgrade::Mail "your-email@domain.com";

Testing the mail delivery:

1
sudo unattended-upgrades --dry-run --debug

❌ No mail arrived. I checked the mail log:

1
sudo tail -n 20 /var/log/mail.log

Status: Connection timed out on port 25.

⚠️ Lesson Learned: My cloud provider (Hetzner) blocks port 25 by default to prevent spam. Getting this to work requires shifting to port 587 or configuring an external mail relay service. Dropped for now. I don’t want to overcomplicate the setup or introduce a chain of new vulnerabilities just for an email notification.


5️⃣ Do Web Services Require a Manual Restart? 🔄

Do I need to manually restart PHP after this morning’s update to flush the old code from RAM? Nope, the system handled it all!

I verified the status of my PHP service:

1
systemctl status php8.3-fpm

Output:

1
2
● php8.3-fpm.service - The PHP 8.3 FastCGI Process Manager
     Active: active (running) since Thu 2026-10-22 06:51:50 CEST; 3h 19min ago

This confirms that the exact second the .13 package finished installing at 06:51:50 AM, Ubuntu automatically restarted the service. The secure code is active in the server’s memory! 🚀


6️⃣ How to Check the History Locally in the Future 📂

If I want to look back in a couple of weeks to see what the server has been up to, I can use these commands:

1
2
3
4
5
6
# Check the raw unattended upgrade logs
sudo tail -n 50 /var/log/unattended-upgrades/unattended-upgrades.log
sudo grep "Allowed originating package" /var/log/unattended-upgrades/unattended-upgrades.log

# The beautiful and comprehensive history receipt for all updates
sudo cat /var/log/apt/history.log

7️⃣ LSNED: The Mystery of Version Numbers (Backporting) 🎓

My biggest “Learn Something New Every Day” takeaway from this crisis:

On Ubuntu, you will never receive the official upstream version number (PHP 8.3.36). Ubuntu freezes the major version (8.3.6) to guarantee that your websites won’t break due to changing features or deprecated functions.

Instead, Ubuntu’s security team takes the source code patch from version 8.3.36 and copy-pastes it directly back into the frozen package.

1
2
From: 8.3.6-0ubuntu0.24.04.12  (Vulnerable)
To:   8.3.6-0ubuntu0.24.04.13  (Secured and patched! ✅)

That small trailing number (.13) is my absolute proof that the security hole is patched.

🛡️ The Ultimate Truth: CVE Checking via Ubuntu Pro

I can query the server directly about the status of the vulnerability using pro fix:

1
pro fix --dry-run CVE-2026-109618

The tool responds instantly:

1
2
3
4
5
1 affected source package is installed: php8.3
A fix is available in Ubuntu standard updates.
The update is already installed.

✔ CVE-2026-109618 is resolved.

Conclusion: The server is fully secured, the code is updated, the service is refreshed in RAM, and I am significantly smarter regarding the inner workings of Ubuntu! 🥂


Tags: #Ubuntu #PHP #Security #DevOps #SysAdmin #LSNED

This post is licensed under CC BY 4.0 by the author.