← Back to All News & Security Advisories
PHP 'PHP2Shell' RCE (CVE-2026-109618, CVE-2026-109619) and PHP-CGI Argument Injection (CVE-2024-4577)
PHP「PHP2Shell」RCE脆弱性(CVE-2026-109618 / 109619)とPHP-CGI引数インジェクション解説
| Critical Security Advisory
In-depth technical breakdown of the critical pre-script Remote Code Execution flaws in the core PHP engine ('PHP2Shell' CVE-2026-109618 and CVE-2026-109619) triggered during memory_limit bailout handling, alongside ongoing exploitation of PHP-CGI (CVE-2024-4577).
PHPコアエンジンのメモリ上限到達時(longjmp処理)に発生するスクリプト実行前リモートコード実行脆弱性「PHP2Shell」(CVE-2026-109618 / CVE-2026-109619)および継続して悪用が確認されているPHP-CGI脆弱性(CVE-2024-4577)の事実関係・技術メカニズム・緩和策を解説します。
1. Incident Overview & Threat Landscape
Two critical Remote Code Execution (RCE) vulnerabilities in the core PHP interpreter, tracked as CVE-2026-109618 and CVE-2026-109619 (collectively referred to as 'PHP2Shell', CVSS v3.1 score 9.2), have come under active, widespread exploitation in the wild and have been added to the CISA Known Exploited Vulnerabilities (KEV) catalog. Unlike application-level flaws in CMS plugins or frameworks, these vulnerabilities reside directly inside the Zend Engine's request initialization and out-of-memory (OOM) bailout routines.
Because the vulnerable code paths execute during the HTTP request parsing phase, before the target PHP application script is even invoked, unauthenticated remote attackers can trigger memory corruption and arbitrary code execution against standard PHP endpoints simply by sending specially crafted multipart HTTP POST requests. Automated threat actors are simultaneously chaining or co-deploying exploits for CVE-2024-4577 (CVSS 9.8, PHP-CGI Unicode best-fit argument injection) against unpatched legacy servers.
2. Technical Root Cause: Zend Engine longjmp() Bailout Corruption
Both CVE-2026-109618 and CVE-2026-109619 stem from how the PHP runtime handles fatal memory exhaustion (when an incoming request exceeds memory_limit) using non-local jumps (setjmp / longjmp via zend_bailout) while parsing complex HTTP input streams:
• CVE-2026-109618 (OOM Uninitialized Memory & Cleanup Corruption): When PHP processes deeply nested multipart/form-data payloads, RFC 1867 file upload structures, or massive variable arrays, the engine allocates internal hash tables and stream buffers incrementally. If memory allocation hits memory_limit mid-initialization, the Zend Memory Manager triggers a longjmp() bailout straight to the request shutdown handler. Several internal pointers remain non-NULL but uninitialized or partially populated. During the subsequent request cleanup phase, the engine attempts to traverse and free these half-constructed structures, resulting in deterministic heap corruption and arbitrary write primitives.
• CVE-2026-109619 (Stale Global State & Cross-Request Use-After-Free): In persistent Multi-Process or Worker SAPI models (such as PHP-FPM, Apache mod_php, FrankenPHP, and LiteSpeed SAPI), a single worker process handles thousands of sequential HTTP requests. When a fatal error triggers longjmp() during multipart or session state initialization, global SAPI state pointers are not atomically reset before the worker returns to the accept loop. A subsequent HTTP request handled by the same worker process references freed heap chunks (Use-After-Free), enabling an attacker to overwrite zend_function or zend_object handlers and execute arbitrary OS commands under the web server user context.
3. Connection to CVE-2024-4577 (PHP-CGI Argument Injection)
Security telemetry shows threat actors combining 'PHP2Shell' probes with CVE-2024-4577 scans. CVE-2024-4577 exploits Windows and multi-byte locale 'Best-Fit' character mapping (notably CP932 Japanese, CP936 Simplified Chinese, and CP950 Traditional Chinese) where the soft hyphen character (0xAD) is silently converted into a standard ASCII hyphen (0x2D) before being passed to php-cgi.exe or CGI wrappers.
This bypasses the historical CVE-2012-1823 protection and allows unauthenticated attackers to inject command-line flags such as -d allow_url_include=1 -d auto_prepend_file=php://input directly into the CGI query string, achieving instant RCE.
4. Affected PHP Versions & SAPI Environments
- PHP 8.5 Branch: All versions prior to PHP 8.5.12 (Fixed in 8.5.12)
- PHP 8.4 Branch: All versions prior to PHP 8.4.27 (Fixed in 8.4.27)
- PHP 8.3 Branch: All versions prior to PHP 8.3.36 (Fixed in 8.3.36)
- PHP 8.2 Branch: All versions prior to PHP 8.2.35 (Fixed in 8.2.35)
- Legacy / End-of-Life (EOL) Branches: PHP 8.1, 8.0, 7.4, 7.2, and 5.x contain the underlying architectural bailout behavior and do not receive official upstream patches from php.net, requiring vendor-backported distribution packages (RHEL/Ubuntu/Debian LTS) or WAF/SAPI isolation.
- Impacted SAPI Deployments: PHP-FPM, Apache httpd (mod_php / mpm_prefork / mpm_event), Nginx + FastCGI, LiteSpeed, FrankenPHP, and php-cgi.
5. Remediation & Defense-in-Depth Mitigations
- Apply Upstream or Distribution Security Patches: Upgrade immediately to PHP 8.5.12+, 8.4.27+, 8.3.36+, or 8.2.35+, or apply the corresponding backported errata from Red Hat (RHSA), Debian, or Ubuntu Security.
- Eliminate Worker State Persistence (CVE-2026-109619 Workaround): On legacy systems where binary upgrades require maintenance windows, configure PHP-FPM pools with pm.max_requests = 1 (or MaxConnectionsPerChild 1 in Apache) so worker processes recycle after every request, neutralizing cross-request Use-After-Free exploitation.
- Restrict Input Complexity & Multipart Thresholds: Enforce strict limits in php.ini (specifically max_input_nesting_level = 32, max_input_vars = 1000, max_file_uploads = 10, and conservative post_max_size) and configure upstream Nginx (client_max_body_size) or HAProxy to reject oversized payloads before they reach the PHP SAPI.
- Block CGI Argument Injection (CVE-2024-4577): Rewrite rules at the web server or WAF layer should block query strings containing %AD, %2D, or -d parameter injection patterns targeting CGI endpoints.
1. インシデント概要と脅威動向
PHPコアインタープリタにおける2件の重大なリモートコード実行(RCE)脆弱性「CVE-2026-109618」および「CVE-2026-109619」(総称「PHP2Shell」、CVSS v3.1スコア 9.2)について、インターネット上での広範な悪用が確認され、米国CISAの悪用確認済み脆弱性カタログ(KEV)に追加されました。CMSのプラグインやフレームワーク層の脆弱性とは異なり、本脆弱性はZend Engine自体のリクエスト初期化およびメモリ枯渇(OOM)時の緊急脱出(ベイルアウト)処理に存在します。
脆弱なコードパスはHTTPリクエストの解析フェーズ(アプリケーション側のPHPスクリプトが実行される前段階)で動作するため、認証を持たないリモートの攻撃者は、細工されたマルチパートHTTP POSTリクエストを送信するだけでメモリ破壊を引き起こし、任意のコードを実行可能です。また、攻撃者はレガシー環境を狙い、PHP-CGIの引数インジェクション脆弱性「CVE-2024-4577」(CVSS 9.8)を組み合わせた自動スキャン・攻撃も並行して展開しています。
2. 技術的根本原因:Zend Engineのlongjmp()ベイルアウト処理におけるメモリ破壊
CVE-2026-109618およびCVE-2026-109619はいずれも、複雑なHTTP入力ストリームの解析中にリクエストが「memory_limit」を超過した際、PHPランタイムが非局所ジャンプ(zend_bailoutによるsetjmp / longjmp)を用いて強制中断するメカニズムに起因しています。
• CVE-2026-109618(OOM発生時の未初期化メモリ参照およびクリーンアップ時のヒープ破壊):深くネストされたmultipart/form-dataペイロードやRFC 1867ファイルアップロード構造、大量の配列変数を解析する際、エンジンは内部ハッシュテーブルやストリームバッファを段階的に確保します。初期化の途中でメモリ割り当てがmemory_limitに達すると、Zend Memory Managerがlongjmp()を発火させ、リクエスト終了処理へ直接ジャンプします。このとき一部の内部ポインタが非NULLのまま未初期化または不完全な状態で残され、クリーンアップ処理がこれらを解放しようとしてヒープ領域を破壊し、任意メモリ書き込み(Arbitrary Write)を許します。
• CVE-2026-109619(残留グローバル状態とリクエスト横断型Use-After-Free):PHP-FPM、Apache mod_php、FrankenPHP、LiteSpeed SAPIなどの常駐ワーカー型SAPIモデルでは、単一のワーカープロセスが複数のHTTPリクエストを連続して処理します。マルチパートやセッション状態の初期化中に致命的エラーでlongjmp()が発生すると、グローバルSAPI状態ポインタが完全にリセットされないまま次のリクエスト待機ループへ戻ります。同一ワーカーが処理する後続のHTTPリクエストが解放済みヒープ領域を参照(Use-After-Free)することで、zend_functionやオブジェクトハンドラが書き換えられ、Webサーバー権限でのOSコマンド実行に至ります。
3. CVE-2024-4577(PHP-CGI引数インジェクション)との関連と複合攻撃
観測されている攻撃トラフィックでは、「PHP2Shell」へのエクスプロイト試行と同時に「CVE-2024-4577」への攻撃が併用されています。CVE-2024-4577は、マルチバイトロケール(特に日本語CP932、簡体字中国語CP936、繁体字中国語CP950)における文字コードの「ベストフィット(Best-Fit)マッピング」処理の不備を突き、ソフトハイフン(0xAD)が標準のASCIIハイフン(0x2D)へ内部変換される挙動を悪用します。
これにより過去のCVE-2012-1823対策が回避され、クエリ文字列から「-d allow_url_include=1 -d auto_prepend_file=php://input」などのコマンドライン引数をphp-cgiへ直接注入し、即座にリモートコード実行を行うことが可能となります。
4. 影響を受けるPHPバージョンおよびSAPI環境
- PHP 8.5系列:8.5.12未満のすべてのバージョン(8.5.12にて修正済み)
- PHP 8.4系列:8.4.27未満のすべてのバージョン(8.4.27にて修正済み)
- PHP 8.3系列:8.3.36未満のすべてのバージョン(8.3.36にて修正済み)
- PHP 8.2系列:8.2.35未満のすべてのバージョン(8.2.35にて修正済み)
- レガシー / サポート終了(EOL)バージョン:PHP 8.1、8.0、7.4、7.2、5.x系列も同一のアーキテクチャ上の問題を抱えており、php.netからの公式パッチは提供されないため、OSディストリビューション(RHEL / Ubuntu / Debian等)のバックポートパッチ適用またはWAF・SAPI分離による保護が必須です。
- 影響を受ける構成:PHP-FPM、Apache httpd (mod_php)、Nginx + FastCGI、LiteSpeed、FrankenPHP、およびphp-cgi環境。
5. 推奨される対策および緩和策(ワークアラウンド)
- セキュリティパッチの即時適用:PHP 8.5.12以上、8.4.27以上、8.3.36以上、8.2.35以上へのアップデート、またはRed Hat(RHSA)・Debian・Ubuntu等が提供するバックポート修正パッケージを適用してください。
- ワーカープロセスの状態再利用の防止(CVE-2026-109619緩和策):即時アップデートが困難なレガシー環境では、PHP-FPMの設定で「pm.max_requests = 1」(Apacheの場合はMaxConnectionsPerChild 1)を設定し、1リクエストごとにワーカーを再生成することでリクエスト横断型のUse-After-Free悪用を阻止できます。
- 入力ネスト深度とマルチパート制限の厳格化:php.iniにて「max_input_nesting_level = 32」「max_input_vars = 1000」「max_file_uploads = 10」および適切な「post_max_size」を設定し、前段のNginx(client_max_body_size)やリバースプロキシで異常なサイズのリクエストを遮断してください。
- CGI引数インジェクションの遮断(CVE-2024-4577対策):WAFまたはWebサーバーのRewriteルールにて、クエリ文字列に含まれる「%AD」や「-d」オプション注入パターンをブロックしてください。