PHP2Shell: Two Critical PHP Vulnerabilities That Let Hackers Take Over Any Website
SecurityOctober 25, 2026·8 min read
#PHP#Cybersecurity#RCE#Web Security#Vulnerability#Server Security

PHP2Shell: Two Critical PHP Vulnerabilities That Let Hackers Take Over Any Website

On October 21, 2026, the PHP security team released emergency patches for two critical vulnerabilities that affect every PHP version from 5.4 (released in 2004) up to 8.5.11. The flaws, tracked as CVE-2026-109618 and CVE-2026-109619 and nicknamed "PHP2Shell", allow an unauthenticated attacker to achieve remote code execution (RCE) on any server running a vulnerable PHP build.

In practical terms: a single malicious HTTP request can give an attacker a shell on your server — no login, no application code, no PHPMyAdmin required.

This guide breaks down exactly how the vulnerabilities work, who is affected, and what steps you need to take to protect your servers.

The PHP2Shell Vulnerabilities: A Technical Breakdown

Both flaws exploit the same underlying mechanism: PHP's use of longjmp() for fatal error handling.

When PHP runs out of memory or hits a fatal error, it does not unwind the stack normally. Instead, it calls longjmp() — a C function that jumps execution to a saved checkpoint, effectively aborting the current request. The problem is that this jump can happen at a moment when internal request data is only partially initialized, or when global state still points to memory that has already been freed.

CVE-2026-109618: RCE via Out-of-Memory Corruption

This vulnerability exploits the way PHP handles out-of-memory (OOM) conditions during multipart form parsing (file uploads).

When PHP receives a file upload, it parses the multipart body and allocates memory for each part. If the request triggers an OOM condition at the wrong moment — for example, while parsing a deeply nested multipart field or a request with excessive headers — PHP calls longjmp() to abort.

The jump can interrupt PHP while internal request structures are only half-built. The subsequent request cleanup routine then walks those structures and tries to free memory that was never properly initialized. That memory may still contain data from earlier allocations controlled by the attacker.

By carefully crafting a multipart request, an attacker can corrupt memory in a way that leads to arbitrary code execution. The request stays within PHP's apparent memory_limit, making it harder to detect with basic rate limiting.

Key technical detail: PHP's zend_multipart_read_post function in rfc1867.c does not account for early exits via longjmp() during memory allocation. The zend_hash_destroy cleanup in SAPI_API then operates on invalid or attacker-influenced state.

CVE-2026-109619: RCE via Stale Global State (Use-After-Free)

The second vulnerability is a classic use-after-free, triggered through PHP's global state management.

PHP workers (in PHP-FPM, Apache mod_php, and similar setups) reuse the same process for multiple requests. Certain global state variables temporarily point into request-owned memory. Under specific conditions — such as a fatal error during shutdown, or memory exhaustion during initialization — the global state may not be correctly reset, or may be repopulated after being reset.

When a subsequent request arrives on the same worker, it reads that stale global state before its own initialization completes. The stale pointers refer to memory that has already been freed. Accessing freed memory can leak data or, with sufficient control, lead to code execution.

Confirmed trigger path: Session upload progress (session.upload_progress.enabled, which is On by default in many PHP configurations). When a file upload starts, PHP creates internal structures to track progress. If the request fails at the right moment, those structures are not cleaned up, and a later request may interact with them.

Who Is Affected

The scope is unusually broad:

| PHP Branch | Vulnerable Versions | Patched Version | |------------|---------------------|-----------------| | 8.5 | 8.5.0 – 8.5.11 | 8.5.12 | | 8.4 | 8.4.0 – 8.4.26 | 8.4.27 | | 8.3 | 8.3.0 – 8.3.35 | 8.3.36 | | 8.2 | 8.2.0 – 8.2.34 | 8.2.35 |

  • PHP 8.1 and older: No patch available. These versions reached end-of-life and the PHP project is not releasing fixes. You must upgrade or isolate these systems.
  • All web-serving setups are at risk: PHP-FPM, Apache with mod_php (considered highest risk), php-cgi, FrankenPHP, and LiteSpeed.

How to Check If You Are Vulnerable

Run this command on your server:

php -v

If your version is lower than the patched release for your branch, you are vulnerable. For example:

  • PHP 8.4.26 → vulnerable (needs 8.4.27)
  • PHP 8.3.35 → vulnerable (needs 8.3.36)
  • PHP 8.1.33 → vulnerable, no patch available

You can also check your phpinfo() page or run:

php -r "echo PHP_VERSION;"

How to Fix PHP2Shell

Immediate Actions

  1. Update PHP to the patched version for your branch:

    • PHP 8.5 → update to 8.5.12
    • PHP 8.4 → update to 8.4.27
    • PHP 8.3 → update to 8.3.36
    • PHP 8.2 → update to 8.2.35

    On Ubuntu/Debian:

    sudo apt update && sudo apt upgrade php8.4
    sudo systemctl restart php8.4-fpm
    

    On CentOS/RHEL/Rocky:

    sudo dnf update php
    sudo systemctl restart php-fpm
    

    On Windows (XAMPP/WAMP), download the patched binaries from the official PHP website.

  2. Restart your PHP service after updating:

    sudo systemctl restart php-fpm
    # or
    sudo systemctl restart apache2
    

If You Cannot Patch Immediately

If you are on an EOL branch (PHP 8.1 or older) or cannot patch right away:

  • Disable session upload progress — this partially mitigates CVE-2026-109619:

    session.upload_progress.enabled = Off
    

    Add this to your php.ini or a site-specific .user.ini file, then reload PHP.

  • Restrict multipart parsing: Reduce the number of allowed multipart fields and file size limits in your web server configuration. This makes the OOM attack harder but is not a complete fix.

  • Take the server offline if it serves sensitive data and cannot be patched within hours. There is no fully effective configuration workaround.

  • Upgrade your PHP branch: If you are on 8.1 or older, plan an upgrade to a supported branch (8.2, 8.3, or 8.4). EOL versions receive no security patches.

Understanding the Attack Surface

What makes PHP2Shell particularly dangerous is that the attack reaches the PHP runtime before your application code executes. This means:

  • Framework-level protections (Laravel middleware, Symfony firewalls, WordPress plugins) do not block the initial exploitation.
  • WAF rules that inspect application-level payloads may miss the raw multipart or memory-state manipulation.
  • Shared hosting environments are especially at risk — a single vulnerable PHP process can lead to cross-tenant compromise.

The attack requires network access to the web server and the ability to send crafted HTTP requests. It does not require authentication, a valid session, or any knowledge of the application.

Lessons for Developers and Sysadmins

  1. Patch your runtime, not just your app: Application-layer security cannot protect against runtime memory corruption. Keep your language runtime, web server, and OS packages up to date.

  2. Monitor PHP versions in production: Many breaches happen because teams forget to patch EOL software. Set up alerts for new PHP security releases.

  3. Disable unused PHP features: session.upload_progress is useful for UX but rarely essential. If you do not need it, turn it off. Every enabled feature is a potential attack surface.

  4. Use containers with minimal PHP builds: If you are using Docker, base your images on official PHP images and rebuild regularly. A single docker pull php:8.4-fpm gives you the latest patched version.

  5. Have an incident response plan: If your server runs a critical service and a CVSS 9.2 RCE drops, you need to patch within hours, not weeks. Automate your patch testing and deployment pipeline.

What About WordPress and Other PHP Apps?

WordPress, Drupal, Joomla, and every other PHP application run on the same PHP runtime. The vulnerability is in PHP itself, not in any application. Updating WordPress plugins or themes will not fix this — you must update the PHP binary on your server.

Most managed WordPress hosts updated within 24 hours of the disclosure. If you are on shared hosting, contact your provider and ask which PHP version they are running. If they cannot confirm a patched version, move to a host that can.

Timeline of the PHP2Shell Disclosure

| Date | Event | |------|-------| | Oct 21, 2026 | PHP team releases 8.5.12, 8.4.27, 8.3.36, 8.2.35 | | Oct 21, 2026 | CVE-2026-109618 and CVE-2026-109619 officially published | | Oct 22, 2026 | Google Cloud and Wiz Research publish technical analysis | | Oct 23, 2026 | CERT-EU issues Security Advisory 2026-018 | | Oct 24, 2026 | CISA adds vulnerabilities to Known Exploited Vulnerabilities catalog | | Oct 25, 2026 | Active exploitation confirmed in the wild |

Conclusion

The PHP2Shell vulnerabilities are a reminder that the software stack we rely on every day can harbor critical flaws for years before they surface. PHP powers over 75% of the web, which makes every memory-corruption bug in its runtime a potential global crisis.

The fix is straightforward: update PHP. The challenge is doing it fast enough across thousands of servers, legacy applications, and shared hosting environments.

If you manage any PHP servers, check your versions today. If you are on an EOL branch, upgrade now. The window between patch release and mass exploitation is measured in days, not weeks.


This article is for educational purposes. Always verify patches against your specific environment before deploying to production.

Prabin Uprety

Prabin Uprety

Founder, SecureX Lab • Full-stack developer and cybersecurity researcher based in Birtamode, Nepal

Prabin Uprety is the founder of SecureX Lab, a software development and SaaS company based in Birtamode-4, Jhapa, Nepal. With over 5 years of experience in full-stack development (React, Next.js, Django, Node.js), Prabin specializes in building privacy-first tools for Nepali users and contributing to the local open-source community. His work focuses on bridging the gap between advanced technology and practical, everyday needs — from secure document conversion to Bikram Sambat date utilities. Prabin holds a degree in Computer Science and regularly writes about cybersecurity, AI, and Nepal's digital transformation. Connect with him on LinkedIn or follow his work at securexlab.com.