php2shell

The PHP Security Team released an emergency patch to address two critical-level security flaws in the PHP core engine. The cybersecurity community has dubbed this pair of vulnerabilities PHP2Shell.

The two vulnerabilities are tracked under the identification codes CVE-2026-109618 and CVE-2026-109619. Both carry a severity score of CVSS v4.0 9.2 (Critical) because they allow attackers to execute arbitrary code remotely (Unauthenticated Remote Code Execution / RCE) without requiring prior account access or authentication.

Understanding How the Vulnerabilities Work

The primary danger of PHP2Shell lies in its location: the flaw exploits the internal memory allocation mechanism of the PHP runtime at the core engine level. Attackers can hijack web application worker processes before the main script (such as WordPress, Laravel, or other frameworks) is even processed.

1. CVE-2026-109618: Out-of-Memory Handling & Data Corruption

  • Mechanism: This vulnerability occurs when an Out-of-Memory (OOM) condition is triggered during request processing (such as sending a large multipart/form-data payload).

  • Impact: When the memory limit is reached, PHP executes cleanup instructions via longjmp() while a new internal data structure is only partially initialized. The cleanup process mistakenly treats this invalid data as valid, triggering memory corruption and opening the door for attackers to execute arbitrary code.

2. CVE-2026-109619: Stale Global State & Use-After-Free

  • Mechanism: This stems from a failure to properly clean up global state in the worker process. When a request completes or encounters an error, the allocated memory is freed. However, internal global state pointers continue to point to that freed memory location (a stale reference).

  • Impact: This Use-After-Free (UAF) condition can be leveraged by a subsequent request handled by the same worker process (for instance, by manipulating the session.upload_progress feature) to read or overwrite internal memory and gain full control over the process runtime.

Scope of Impact and Affected Versions

These vulnerabilities affect all web server infrastructure running PHP, including PHP-FPM, Apache mod_php, LiteSpeed, php-cgi, and FrankenPHP.

  • Affected Versions: All PHP versions from legacy releases up to 8.5.11, 8.4.26, 8.3.35, and 8.2.34. End-of-Life (EOL) versions such as PHP 5.x, 7.x, 8.0, and 8.1 are also confirmed vulnerable.

  • Active Exploitation: In-the-wild exploitation activity has been detected, and cybersecurity agencies such as CISA have added the related stale state issue to their Known Exploited Vulnerabilities (KEV) catalog.

Patched Releases

The PHP development team has released official security updates. Users are strongly advised to update their PHP runtimes immediately to the following versions:

PHP Series Secure Version (Patched Release) Support Status
PHP 8.5 8.5.12 Supported
PHP 8.4 8.4.27 Supported
PHP 8.3 8.3.36 Supported
PHP 8.2 8.2.35 Supported
PHP 8.1 and below No official release End-of-Life (EOL)

Note for EOL PHP Versions: PHP does not issue official updates for version 8.1 and below. Users running legacy versions are urged to migrate immediately to PHP 8.2+ or rely on backported patch packages provided by OS vendors (such as Ubuntu LTS, RHEL, or Debian).

Recommended Mitigation Steps

The developers have not provided a purely configuration-based workaround that can fully replace software updates. However, the following combination of updates and temporary mitigations should be implemented:

1. Apply Updates (Primary Step)

  • Upgrade your PHP runtime to the secure release corresponding to your branch (8.5.12, 8.4.27, 8.3.36, or 8.2.35).

  • IMPORTANT: Restart your PHP services (php-fpm, apache2, nginx, etc.) after the update process to ensure running worker processes are refreshed.

2. Temporary Configuration Workarounds

If upgrading your environment immediately is not feasible:

  • Reset Worker Processes: Set the parameter pm.max_requests = 1 in your PHP-FPM configuration (www.conf). This forces worker processes to terminate and reload after serving a single request, interrupting persistent memory exploitation scenarios (stale state execution).

  • Set Request Limits on WAF / Reverse Proxy: Configure payload size limits (body request) on reverse proxies (Nginx/Apache) or Web Application Firewalls (WAF) to prevent giant requests engineered to trigger Out-of-Memory (OOM) errors.

  • Centralize Configuration: Move all configuration directives to the main php.ini file and avoid per-directory configurations (such as .htaccess) to minimize early-stage warning/error handlers from executing prematurely.

Impact on Web Application Ecosystems & CMS

The PHP2Shell vulnerability does not distinguish between different web frameworks or applications. Because execution occurs during memory allocation inside the PHP core engine, all PHP-based platforms face high direct risk if the server has not been updated.

1. Content Management Systems (CMS) & E-Commerce

  • WordPress & WooCommerce: As the platform with the largest market share, WordPress installations are primary targets for mass automated scanning. Attackers utilize RCE execution to inject backdoor scripts, modify wp-config.php, create hidden administrator accounts, or place credit card skimmers on checkout pages.

  • Drupal, Joomla, & Magento (Adobe Commerce): News portals, enterprise platforms, and online stores risk sensitive database data breaches and total server takeover.

2. Modern Web Frameworks (Laravel, Symfony, CodeIgniter)

  • The belief that modern frameworks are immune to this flaw is incorrect. Even if an application enforces strict MVC architecture, input sanitization, and data encryption, the vulnerability triggers before application scripts (routing & controllers) are executed by PHP-FPM.

Indicators of Compromise (IoC) & Detection Techniques

Security Operations Center (SOC) teams and system administrators can monitor log indicators and system activity to detect exploitation attempts:

1. Web Server & PHP-FPM Log Anomalies

  • Repeated PHP-FPM Crash Logs: Look for consecutive Segmentation fault (SIGSEGV) or bus error (SIGBUS) messages in PHP-FPM logs (/var/log/php-fpm/error.log):

    Plaintext
    [WARNING] child 12345 exited on signal 11 (SIGSEGV) after 0.001200 seconds from start
    
  • Unusually Large Multipart HTTP Payloads:Content-Type: multipart/form-data headers with an abnormally high count of boundaries or intentionally inflated header sizes sent within milliseconds.

  • Sudden Memory Spikes: Instant spikes in RAM usage followed by a sharp drop due to the PHP worker process crashing.

2. Post-Exploitation Activity Traces

If an attacker successfully executes code, the following artifacts may be found on the server:

  • Creation of small, randomly-named PHP files in publicly accessible directories (such as /wp-content/uploads/ or /tmp/).

  • Execution of reverse shells connecting php-fpm or www-data processes to unknown external IP addresses over non-standard ports (e.g., 4444, 8080, 1337).

  • Unauthorized file permission modifications or altered core system files via shell command execution.

Incident Response Playbook

If you suspect or confirm that your server has been scanned or compromised by the PHP2Shell exploit, execute the following emergency steps immediately:

Step 1: Isolation and Containment

  1. Isolate Server from External Traffic: Temporarily block inbound traffic via WAF, security groups, or host firewalls (iptables/ufw) to prevent further command execution from the attacker's Command & Control (C2) server.

  2. Stop and Reset PHP Services:

    Bash
    sudo systemctl stop php8.x-fpm
    # or for Apache
    sudo systemctl stop apache2
    

Step 2: Analysis and Remediation

  1. Update PHP Packages: Upgrade the runtime to a recommended secure version.

    Bash
    # Example on Ubuntu/Debian
    sudo apt-get update && sudo apt-get install --only-upgrade php8.3-fpm php8.3-cli
    
  2. Audit Files & Code Integrity: Use tools like maldet (Linux Malware Detect), ClamAV, or Git integrity checkers to inspect changes in the application directory.

    Bash
    git status  # If using a Git repository
    
  3. Inspect Running Processes: Verify no unauthorized processes are running under the www-data or nginx users.

    Bash
    ps aux | grep -E "www-data|nginx|apache"
    

Step 3: Recovery and Hardening

  1. Rotate Credentials: Update secret keys, database passwords, API keys, and SSH credentials stored in server environments (.env, wp-config.php).

  2. Enable Continuous Monitoring: Deploy the latest WAF rulesets from vendors (such as ModSecurity, Cloudflare, or AWS WAF) that block payload patterns designed to trigger OOM conditions and stale memory state manipulation.

Conclusion

The PHP2Shell (CVE-2026-109618 & CVE-2026-109619) case underscores the critical importance of vulnerability management at the runtime infrastructure level. Because this flaw resides in the core engine, no application-level code protections can substitute for patching.

Organizations are advised to update their PHP runtimes to the latest patched releases immediately (8.5.12, 8.4.27, 8.3.36, or 8.2.35) and ensure all web servers utilize worker auto-restart mechanisms as an auxiliary mitigation measure.