Skip to content

Cybersecurity

PHP2Shell: How I’d Patch PHP and Audit a Next.js Stack

Fix PHP’s October 2026 critical vulnerabilities with exact patched versions, deployment checks, and a separate Next.js security review.

By · Published · 8 min read

Security incidents expose a gap that product teams often overlook: the difference between updating a project and updating the software actually serving requests.

The latest PHP security advisories I verified as of October 22, 2026 concern CVE-2026-109618 and CVE-2026-109619, disclosed on October 21. Both carry a publisher CVSS v4.0 score of 9.2, Critical. They concern runtime memory handling and can permit unauthenticated remote code execution. This is a runtime patching problem, not something a new frontend fixes. PHP’s OOM advisory, PHP’s stale-state advisory.

My response would start with a deployment inventory and end with evidence from the live application. Here is the process I would use.

What the two PHP vulnerabilities actually mean

CVE-2026-109618 concerns out-of-memory handling. An interrupted operation can leave request data incompletely initialized; cleanup can subsequently use that invalid data. PHP’s advisory describes a demonstrated mod_php attack before application execution. That makes an application-level login check an inadequate boundary for that path. Technical advisory.

CVE-2026-109619 concerns state surviving beyond a request. A worker can retain references to freed request memory, which a later request can consume. Exploitation depends on reachable operations and the worker lifecycle; the advisory validates session lifecycle RCE paths for mod_php and PHP-FPM. Worker recycling does not eliminate the underlying defect. Technical advisory.

These are deployment-dependent vulnerabilities. An advisory demonstrating an exploit is not proof that a particular website has been compromised. Equally, a quiet error log is not sufficient evidence that a vulnerable deployment is safe.

Which PHP versions contain the fixes?

Use this branch-specific baseline for both CVEs:

  • Installed upstream branch: PHP 8.2; Versions below the fixed baseline: 8.2.x before 8.2.35; First fixed release: 8.2.35
  • Installed upstream branch: PHP 8.3; Versions below the fixed baseline: 8.3.x before 8.3.36; First fixed release: 8.3.36
  • Installed upstream branch: PHP 8.4; Versions below the fixed baseline: 8.4.x before 8.4.27; First fixed release: 8.4.27
  • Installed upstream branch: PHP 8.5; Versions below the fixed baseline: 8.5.x before 8.5.12; First fixed release: 8.5.12

These are the security baselines announced by PHP. Install a newer supported release containing the fixes when available, rather than treating this table as a permanent version pin. PHP release changelog.

For distribution packages, a lower upstream-looking version can contain a vendor backport. Verify the exact package revision against the vendor’s notice for both CVEs. Conversely, an installed package does not prove that old workers have exited.

PHP 8.1 and older need a supported upgrade or explicit vendor patch evidence. PHP provided exceptional source backports for 7.4, 8.0, and 8.1; those do not restore normal upstream support. PHP 8.2’s security support ends December 31, 2026, so patch it now and schedule the branch upgrade separately. PHP advisory, support calendar.

My remediation workflow: find, patch, restart, prove

1. Map every place PHP runs

I would list production sites, staging systems, admin tools, scheduled jobs, containers, hosting accounts, and origin servers. For each, record the owner, runtime branch, package source, serving mode, extension set, and deployment method.

The terminal’s default PHP binary is only one observation:

# Read-only CLI inventory; this does not verify the web runtime.
php -v
php --ini
php -m

A server can use PHP 8.4 in a shell while its web pool still runs 8.2. A container can have a different runtime from its host. That is why I would identify the web server’s actual handler, FPM socket or upstream, and deployed container image before choosing an update command.

2. Prepare a recoverable change

Capture configuration and application backups, verify the database restore process, and select a patched rollback target. A rollback plan that restores a vulnerable runtime merely restores the exposure.

For an emergency branch-preserving update, test critical application behavior: login, sessions, file uploads, checkout, webhooks, and background work. Major-version migrations deserve compatibility testing beyond the emergency patch.

3. Install through the deployment’s existing package channel

For a Debian/Ubuntu installation already using PHP 8.4 FPM, the following is an example workflow, not a universal installer:

# Inspect candidates first. Compare exact revisions with your vendor advisory.
sudo apt-get update
apt-cache policy php8.4-fpm php8.4-cli php8.4-common

# Proceed only when the candidate revision fixes both CVEs.
# Include every installed PHP 8.4 extension package in the reviewed update.
sudo apt-get install --only-upgrade php8.4-fpm php8.4-cli php8.4-common

# Validate configuration before restarting the actual serving service.
sudo php-fpm8.4 -t
sudo systemctl restart php8.4-fpm

Package names and service names vary. This example does not update an Apache module, a separate PHP branch, a container, or another host. If the configured vendor has no fixed package, escalate to the host or use a verified supported deployment path rather than adding an unreviewed repository under pressure.

For containers, rebuild from a verified patched base, test, and redeploy every replica. Updating the host does not update the image. Pin the tested artifact digest and replace stale rollback images. Docker documents why rebuilding and refreshing the base image are separate steps. Docker build guidance.

4. Verify the runtime that receives real traffic

Use an authenticated internal diagnostic or deployment inspection to establish the web runtime version, SAPI, effective configuration, and package/image identity. Do not leave a public phpinfo() page online.

Then verify all serving workers were replaced, all replicas received the release, and the load balancer has no old pool behind it. Check a request through the public hostname and directly validate the authorized origin path where appropriate. Run application smoke tests and watch error rate, latency, memory, and restarts.

My closure record would include the exact build, deployment time, affected environments, successful checks, and any exception with an owner and deadline.

What if the patch cannot be installed immediately?

Treat temporary controls as exposure reduction with an expiry time. PHP explicitly says a complete update is required. Its advisory includes narrowly scoped session and request-processing mitigations; they are not substitutes for patching. If a safe update cannot be delivered promptly, evaluate isolating affected PHP routes or temporarily taking the service offline. PHP mitigation guidance.

I would avoid copying isolated configuration suggestions without their limitations. For example, changing memory behavior can trade one failure mode for another; availability limits and application requirements still matter. Follow the complete advisory with the host’s operational guidance.

Where Next.js helps—and where it introduces its own risk

A Next.js frontend can change how a product exposes its backend. It cannot repair memory corruption inside a PHP CMS, API, legacy route, or admin service that remains reachable. A headless architecture still needs a patched headless backend.

There is also a separate, current Next.js patching task. The October 14 advisory identifies 15.5.28 and 16.4.1 as patched releases for that update. It covers cache-related RCE, an image-optimization dependency issue, and Server Actions denial of service, with differing applicability. Use its version guidance and recheck later advisories before deployment. Next.js October security update.

# Inspect the actual dependency tree first.
npm ls next react react-dom sharp

# Choose ONE applicable supported release path after compatibility review:
npm install [email protected]
# OR: npm install [email protected]

Commit the resulting lockfile, run the application’s required checks, rebuild, and redeploy. Do not apply the two alternatives sequentially. These are baselines for that advisory, not a guarantee against every future vulnerability.

For my application review, I would verify authentication and resource authorization inside each Server Action, validate untrusted input, and keep secrets and database access in a server-only layer. A protected page does not automatically protect a separately callable mutation. Next.js data security guide.

I would also review secret exposure, private response caching, session cookies, rate limits, uploads, and security headers. A CSP should be tested against hydration and third-party integrations; it is a separate browser defense, not a runtime patch. Next.js production checklist.

Checklist I would use before closing the task

  • Every PHP deployment and owner is recorded.
  • Exact upstream releases or vendor revisions fix both CVEs.
  • Serving workers, containers, replicas, and rollback artifacts are accounted for.
  • Live web-runtime evidence matches the intended build.
  • Login, sessions, uploads, business transactions, and jobs pass smoke tests.
  • Suspicious activity is investigated separately from patch completion.
  • Next.js and its dependencies have their own advisory review.
  • Temporary controls have an owner and removal/review date.

Frequently asked questions

Does updating WordPress or a PHP framework fix these issues?

Do not assume so. Confirm that the hosting runtime itself contains the PHP fixes. Application and dependency maintenance remain separate workstreams.

Is PHP-FPM a reason to skip the update?

No. PHP includes FPM in the affected deployment scope. Exploit conditions differ by path; the general advice is to patch. PHP security advisory.

Should I rewrite a PHP application in Next.js today?

Patch first. Evaluate a migration later against product needs, maintenance costs, and the full system boundary. A rushed rewrite can retain the old vulnerable backend while adding another runtime to maintain.

Need a second pair of engineering eyes?

If you need help deciding what to patch or how to verify a mixed PHP and Next.js deployment, contact NodeDR and ask to discuss an engineering review. Include your hosting platform, PHP branch, and application type. Agree the scope and availability before starting, and keep credentials out of the initial inquiry.

Research cutoff: October 22, 2026. The PHP project’s advisories are the primary technical sources. NVD detail URLs for CVE-2026-109618 and CVE-2026-109619 were checked, but did not return readable detail records through the research tool; no independent NVD score or enrichment is asserted here.

Author

Raktim Ranjit is a software engineer and the founder of NodeDR Infotech. He builds and maintains the software described here.

Have something in mind?

Let’s build something useful.

Tell me about the idea, product, or workflow you’re working through.

Tap to say hello