<?xml version="1.0" encoding="utf-8" standalone="yes"?><rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom"><channel><title>Security on Daniel Zhang</title><link>https://zhangdapeng.dev/tags/security/</link><description>Recent content in Security on Daniel Zhang</description><generator>Hugo -- gohugo.io</generator><language>en-us</language><lastBuildDate>Mon, 02 Nov 2026 10:39:00 +0800</lastBuildDate><atom:link href="https://zhangdapeng.dev/tags/security/index.xml" rel="self" type="application/rss+xml"/><item><title>Understanding PHP2Shell (CVE-2026-109618): From Memory Corruption to Full Remediation</title><link>https://zhangdapeng.dev/p/php2shell-vulnerability-analysis-and-fix-guide/</link><pubDate>Mon, 02 Nov 2026 10:39:00 +0800</pubDate><guid>https://zhangdapeng.dev/p/php2shell-vulnerability-analysis-and-fix-guide/</guid><description>&lt;p&gt;Security researchers recently disclosed a critical Remote Code Execution (RCE) vulnerability flaw within the core of the PHP engine, collectively tracked as &lt;strong&gt;PHP2Shell&lt;/strong&gt; (&lt;strong&gt;CVE-2026-109618&lt;/strong&gt; and &lt;strong&gt;CVE-2026-109619&lt;/strong&gt;). Assigned a CVSS 4.0 score of 9.2, this vulnerability allows unauthenticated attackers to execute arbitrary system commands on target servers.&lt;/p&gt;
&lt;p&gt;This guide provides a comprehensive technical breakdown of the underlying memory safety issues, identifies affected versions, and outlines actionable patch and mitigation procedures for sysadmins and developers.&lt;/p&gt;
&lt;hr&gt;
&lt;h2 id="1-vulnerability-overview"&gt;1. Vulnerability Overview
&lt;/h2&gt;&lt;ul&gt;
&lt;li&gt;&lt;strong&gt;CVE Identifiers&lt;/strong&gt;: CVE-2026-109618, CVE-2026-109619&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Alias&lt;/strong&gt;: PHP2Shell&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Vulnerability Class&lt;/strong&gt;: Memory Safety Violation / Remote Code Execution (RCE)&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;CVSS Score&lt;/strong&gt;: 9.2 (Critical)&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Impact&lt;/strong&gt;: Unauthenticated attackers can craft malicious HTTP requests to bypass sandbox boundaries, executing shell commands or implanting backdoors with the privileges of the underlying PHP worker process.&lt;/li&gt;
&lt;/ul&gt;
&lt;hr&gt;
&lt;h2 id="2-low-level-technical-mechanism"&gt;2. Low-Level Technical Mechanism
&lt;/h2&gt;&lt;p&gt;The PHP2Shell vulnerability stems from improper handling of &lt;strong&gt;Out-of-Memory (OOM)&lt;/strong&gt; exceptions and dirty lifecycle states within the request-scoped &lt;strong&gt;Global State&lt;/strong&gt;:&lt;/p&gt;
&lt;h3 id="cve-2026-109618-uninitialized-memory--abnormal-jump-oom"&gt;CVE-2026-109618: Uninitialized Memory &amp;amp; Abnormal Jump (OOM)
&lt;/h3&gt;&lt;ul&gt;
&lt;li&gt;&lt;strong&gt;Mechanism&lt;/strong&gt;: When PHP encounters an Out-of-Memory condition while processing unusually large requests or complex object allocations, the Zend Engine issues a &lt;code&gt;longjmp()&lt;/code&gt; call to abort execution and unroll the stack.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Flaw&lt;/strong&gt;: In specific extensions and core functions, &lt;code&gt;longjmp()&lt;/code&gt; unwinds execution while leaving request memory in a partially initialized &amp;ldquo;dirty&amp;rdquo; state. During subsequent Request Cleanup routines, the engine accesses or dereferences uninitialized pointers.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Exploitation&lt;/strong&gt;: An attacker can precisely timing-attack memory allocations so that cleaning procedures invoke attacker-controlled function pointers, achieving hijack of control flow and RCE.&lt;/li&gt;
&lt;/ul&gt;
&lt;h3 id="cve-2026-109619-stale-global-state--dangling-pointers"&gt;CVE-2026-109619: Stale Global State &amp;amp; Dangling Pointers
&lt;/h3&gt;&lt;ul&gt;
&lt;li&gt;&lt;strong&gt;Mechanism&lt;/strong&gt;: Under persistent worker models (e.g., PHP-FPM or Apache &lt;code&gt;mod_php&lt;/code&gt;), the PHP engine maintains global state structures across sequential HTTP requests.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Flaw&lt;/strong&gt;: Under edge-case error conditions, pointers within the global state fail to reset properly, retaining references to memory blocks freed during the previous request lifecycle (a Use-After-Free condition).&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Exploitation&lt;/strong&gt;: When the worker handles a subsequent HTTP request, it reuses the dirty global state before full re-initialization, leading to memory corruption usable for arbitrary code execution.&lt;/li&gt;
&lt;/ul&gt;
&lt;hr&gt;
&lt;h2 id="3-affected-versions"&gt;3. Affected Versions
&lt;/h2&gt;&lt;p&gt;All PHP versions prior to the emergency security releases are vulnerable (including EOL versions such as PHP 5.x and 7.x):&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;strong&gt;PHP 8.5 Series&lt;/strong&gt;: Versions prior to &lt;code&gt;8.5.12&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;PHP 8.4 Series&lt;/strong&gt;: Versions prior to &lt;code&gt;8.4.27&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;PHP 8.3 Series&lt;/strong&gt;: Versions prior to &lt;code&gt;8.3.36&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;PHP 8.2 Series&lt;/strong&gt;: Versions prior to &lt;code&gt;8.2.35&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;End-of-Life (EOL) Versions&lt;/strong&gt;: PHP 8.1, 8.0, 7.x, and 5.x (Not maintained upstream, but structurally vulnerable).&lt;/li&gt;
&lt;/ul&gt;
&lt;hr&gt;
&lt;h2 id="4-detection--auditing"&gt;4. Detection &amp;amp; Auditing
&lt;/h2&gt;&lt;h3 id="step-1-verify-running-php-binary"&gt;Step 1: Verify Running PHP Binary
&lt;/h3&gt;&lt;p&gt;Check your CLI PHP version via terminal:&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;"&gt;&lt;code class="language-bash" data-lang="bash"&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;php -v
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;For FPM setups, inspect the binary explicitly:&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;"&gt;&lt;code class="language-bash" data-lang="bash"&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;php-fpm -v
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;h3 id="step-2-check-os-package-manager-backports"&gt;Step 2: Check OS Package Manager Backports
&lt;/h3&gt;&lt;p&gt;If running enterprise distribution packages (RHEL, Ubuntu LTS, Debian), verify whether the vendor has backported security fixes:&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;"&gt;&lt;code class="language-bash" data-lang="bash"&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;&lt;span style="color:#75715e"&gt;# RedHat / CentOS / Rocky Linux&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;rpm -q php --changelog | grep -E &lt;span style="color:#e6db74"&gt;&amp;#34;CVE-2026-109618|CVE-2026-109619&amp;#34;&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;&lt;span style="color:#75715e"&gt;# Debian / Ubuntu&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;apt-changelog php | grep -E &lt;span style="color:#e6db74"&gt;&amp;#34;CVE-2026-109618|CVE-2026-109619&amp;#34;&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;hr&gt;
&lt;h2 id="5-remediation--patching-guide"&gt;5. Remediation &amp;amp; Patching Guide
&lt;/h2&gt;&lt;p&gt;A defense-in-depth approach is strongly recommended: &lt;strong&gt;Prioritize binary updates, complemented by temporary INI configurations and WAF rules.&lt;/strong&gt;&lt;/p&gt;
&lt;h3 id="option-a-official-upgrades-recommended"&gt;Option A: Official Upgrades (Recommended)
&lt;/h3&gt;&lt;p&gt;Upgrade your PHP installation to the respective patched release:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;strong&gt;PHP 8.5&lt;/strong&gt; $\rightarrow$ Upgrade to &lt;strong&gt;8.5.12&lt;/strong&gt;&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;PHP 8.4&lt;/strong&gt; $\rightarrow$ Upgrade to &lt;strong&gt;8.4.27&lt;/strong&gt;&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;PHP 8.3&lt;/strong&gt; $\rightarrow$ Upgrade to &lt;strong&gt;8.3.36&lt;/strong&gt;&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;PHP 8.2&lt;/strong&gt; $\rightarrow$ Upgrade to &lt;strong&gt;8.2.35&lt;/strong&gt;&lt;/li&gt;
&lt;/ul&gt;

 &lt;blockquote&gt;
 &lt;p&gt;&lt;strong&gt;Important&lt;/strong&gt;: You must restart running worker processes after updating binaries to purge vulnerable code from memory:&lt;/p&gt;

 &lt;/blockquote&gt;
&lt;div class="highlight"&gt;&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;"&gt;&lt;code class="language-bash" data-lang="bash"&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;&lt;span style="color:#75715e"&gt;# Restart PHP-FPM (example for PHP 8.3)&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;sudo systemctl restart php8.3-fpm
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;&lt;span style="color:#75715e"&gt;# Or restart Apache Web Server&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;sudo systemctl restart apache2
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;hr&gt;
&lt;h3 id="option-b-temporary-ini-mitigations"&gt;Option B: Temporary INI Mitigations
&lt;/h3&gt;&lt;p&gt;If immediate binary upgrades are not feasible or you are operating legacy EOL systems, adjust &lt;code&gt;php.ini&lt;/code&gt; settings to reduce OOM trigger vectors and disable volatile upload progress tracking:&lt;/p&gt;
&lt;p&gt;Add or update the following parameters in your &lt;code&gt;php.ini&lt;/code&gt;:&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;"&gt;&lt;code class="language-ini" data-lang="ini"&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;&lt;span style="color:#75715e"&gt;; [PHP2Shell Mitigation Settings]&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;&lt;span style="color:#75715e"&gt;; Restrict maximum memory per request to curb unexpected heap spikes&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;&lt;span style="color:#a6e22e"&gt;memory_limit&lt;/span&gt; &lt;span style="color:#f92672"&gt;=&lt;/span&gt; &lt;span style="color:#e6db74"&gt;128M&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;&lt;span style="color:#75715e"&gt;; Limit max POST payload size&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;&lt;span style="color:#a6e22e"&gt;post_max_size&lt;/span&gt; &lt;span style="color:#f92672"&gt;=&lt;/span&gt; &lt;span style="color:#e6db74"&gt;8M&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;&lt;span style="color:#75715e"&gt;; Limit maximum file upload size&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;&lt;span style="color:#a6e22e"&gt;upload_max_filesize&lt;/span&gt; &lt;span style="color:#f92672"&gt;=&lt;/span&gt; &lt;span style="color:#e6db74"&gt;7M&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;&lt;span style="color:#75715e"&gt;; Disable Session Upload Progress tracking to prevent global state pointer leaks&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;&lt;span style="color:#a6e22e"&gt;session.upload_progress.enabled&lt;/span&gt; &lt;span style="color:#f92672"&gt;=&lt;/span&gt; &lt;span style="color:#e6db74"&gt;0&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;Reload the service configuration:&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;"&gt;&lt;code class="language-bash" data-lang="bash"&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;sudo systemctl reload php8.3-fpm
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;hr&gt;
&lt;h3 id="option-c-web-application-firewall-waf-rules"&gt;Option C: Web Application Firewall (WAF) Rules
&lt;/h3&gt;&lt;ol&gt;
&lt;li&gt;&lt;strong&gt;Payload Body Restrictions&lt;/strong&gt;: Filter out oversized &lt;code&gt;multipart/form-data&lt;/code&gt; requests at the HTTP proxy level (Nginx/HAProxy).&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Strict Request Validation&lt;/strong&gt;: Block POST requests lacking valid &lt;code&gt;Content-Length&lt;/code&gt; headers, and reject malformed multipart boundaries before passing requests to upstream PHP workers.&lt;/li&gt;
&lt;/ol&gt;
&lt;hr&gt;
&lt;h2 id="6-conclusion"&gt;6. Conclusion
&lt;/h2&gt;&lt;p&gt;The PHP2Shell vulnerability exposes critical edge-case flaws in memory management and unrolled state cleanup. Given the severity of remote code execution, infrastructure administrators should immediately audit their PHP runtime environments, apply official upgrades, and ensure Worker processes are restarted.&lt;/p&gt;</description></item></channel></rss>