DEV Community

sunah kim
sunah kim

Posted on Originally published at zenn.dev

Patching a Critical PHP RCE on an EOL OS, Same Day: 3 Traps I Hit

What happened

On October 22, an unauthenticated RCE in PHP (CVE-2026-109618 / 109619) went public. The production e-commerce site I manage was, to put it mildly, not in great shape:

  • Production: PHP 8.2.30 (the fix was 8.2.35)
  • Dev: PHP 8.1.34 (the 8.1 branch is already EOL — no fix coming)
  • OS: Amazon Linux 2 (also EOL as of June 2026)

The first question was: does an EOL OS even receive the fixed packages? The Remi repository — the usual fallback — was no help: its RHEL7-generation builds are frozen at 8.3.8. The answer turned out to be amazon-linux-extras, which was still alive:

# Dev server (moving 8.1 -> 8.2)
amazon-linux-extras disable php8.1
amazon-linux-extras enable php8.2
yum clean metadata && yum update php\*
Enter fullscreen mode Exit fullscreen mode

Eleven packages updated on production, twelve on dev, all to 8.2.35, verified with yum history info. That part was smooth. Every trap came afterward.

The traps

Trap 1: mod_php does not swap out on reload

My first instinct after yum update was systemctl reload httpd. Wrong. With mod_php, the parent process keeps the old libphp.so loaded, so a reload leaves the old engine running against the new extension .so files on disk — a symbol mismatch. The error log shows lines like:

PHP Warning:  PHP Startup: Unable to load dynamic library 'opcache'
(symbol lookup error: undefined symbol: ...)
Enter fullscreen mode Exit fullscreen mode

The fix is to chain update and restart in a single line:

yum update -y php\* && systemctl restart httpd
Enter fullscreen mode Exit fullscreen mode

Measured downtime: 1–3 seconds.

Trap 2: the maintenance page failed three times in a row

During the patch window I wanted "let my IP through, show everyone else a maintenance page." Apache rejected my assumptions three consecutive times:

  1. With RewriteEngine On in .htaccess, the maintenance rewrite rules in the server's <Directory> block are not inherited — they're replaced wholesale. Fix: RewriteOptions InheritDownBefore, so server-level rules are evaluated first.
  2. I used SetEnvIf Query_String for a bypass check, but SetEnvIf cannot see the query string. Fix: SetEnvIfExpr.
  3. Distributing a check flag with Header set Set-Cookie overwrote the application's session cookie, logging everyone out. Fix: Header always add.
RewriteOptions InheritDownBefore
SetEnvIfExpr "%{QUERY_STRING} =~ /maintenance-check/" allow_check
Header always add Set-Cookie "maint=1; Path=/"
Enter fullscreen mode Exit fullscreen mode

Trap 3: your "common-sense time window" dies on contact with logs

My initial plan was "do it at 3 a.m., when traffic is low" — based on the last four days of access logs. Re-aggregating a full month told a different story: late-night traffic was almost entirely bot noise. Real purchases averaged 1.3/day, with zero purchases between 02:00 and 05:00. A few seconds of restart during the day was effectively harmless. The more striking finding: about 40% of all requests were vulnerability-scan 404s, with constant probes for .env (all 403). Within hours of disclosure, the attackers were already at work.

Verification — with live ammunition

Post-patch verification happened on production, not staging:

  1. Create a ¥1 test product, set shipping to ¥0
  2. Pay with a real card → confirm success
  3. Cancel immediately, delete the product, restore settings

Nothing else proves the full path through the payment gateway. I also kept the temporary mitigation in place even after the fixed version landed:

; Permanently disable an unused feature that makes a handy attack vector
session.upload_progress.enabled = 0
Enter fullscreen mode Exit fullscreen mode

Cleanup: removed 13 leftover Remi php83 packages from the dev server and disabled that repo, and added opcache to production, which had been missing it (mixed-origin package sets always blow up on the next update).

Takeaways

  • Even on an EOL OS, Amazon Linux 2 delivered the fixed PHP the same day via amazon-linux-extras
  • But "runtime patched" and "safe" are different statements. While the OS is EOL, the kernel and OpenSSL holes stay open (that became a separate migration story later)
  • For mod_php, restart is the only option. reload buys you symbol mismatches
  • Plan maintenance windows from a month of logs, not a few days
  • Don't write temp files to a production server without sign-off. I did it once that day, and deleted it immediately

Looking back, the command I ran most that day wasn't yum — it was curl -I. Verifying that things changed takes longer than changing them. That's what an emergency patch actually looks like.

Top comments (1)

Collapse
 
hritik_chaudhary_5db0056f profile image
Hritik Chaudhary •

One caveat on verifying with curl -I: the X-Powered-By header only carries the PHP version while expose_php is On, and many hardening guides turn that off. Once it is off, compare the age of the oldest Apache process with the package install time: ps -o lstart= -p $(pgrep -o httpd) against rpm -q --qf '%{INSTALLTIME:date}\n' php. With mod_php, a process older than the package is still running the old build.