# PHPの脆弱性「php2shell」とは:しくみと対策(CVE-2026-109618・CVE-2026-109619) # php2shell explained: the critical PHP flaws CVE-2026-109618 and CVE-2026-109619 > 株式会社Bekito(Bekito Inc.、東京)による解説。人が読むページ(日本語・英語、動く図つき): https://bekito.co.jp/security/php/ 。このファイルはAIエージェント・LLM向けの同じ内容のテキスト版です。2026年10月22日18時(日本時間)時点。 > Explainer by Bekito Inc. (Tokyo). Human-readable page (Japanese and English, with animated diagrams): https://bekito.co.jp/security/php/ . This file is the same content as plain text for AI agents and LLMs. As of 18:00 JST, 22 October 2026. ## 要点 (Key points) - 「php2shell」は、2026年10月21日に修正されたPHP本体の重大な脆弱性2件、CVE-2026-109618(メモリ不足時の破損、OOM corruption)とCVE-2026-109619(古いグローバル状態、stale global state)の通称。 - 条件がそろうと、ログインしていない攻撃者が細工したリクエストを送るだけで、サーバー上で命令を実行できる恐れがある(リモートコード実行)。 - 深刻度:CVSS v4.0 9.2 Critical(PHPのセキュリティチーム)。米NISTのCVSS v3.1では9.8。公開前に出回った「10.0」は誤り。 - 修正版:PHP 8.5.12、8.4.27、8.3.36、8.2.35(2026年10月21日、日本時間22時半〜23時ごろ公開。php.netのChangeLogの日付は10月22日)。 - 影響範囲:少なくともPHP 5.4以降のほぼすべての版。PHP 8.1以前には公式の修正版が出ない(開発元は7.4・8.0・8.1向けに最小限のソース修正をGitHubのブランチで公開)。 - 対象:Webのリクエストを処理するすべてのPHP(PHP-FPM、Apacheのmod_php、php-cgi、FrankenPHP、LiteSpeed)。危険度が最も高いのはmod_phpで、既定の設定のまま、アプリのコードが動く前に攻撃が成立する。 - WordPress・Drupal・Joomla・Magentoなどでの成立が示されている。問題はPHP本体にあるため、アプリの種類は関係ない。 - 悪用(2026年10月22日時点):CISA(米国)とIPAは悪用を確認していない。watchTowrは攻撃の試みを観測。CISAのKEV(悪用が確認された脆弱性の一覧)には入っていない。国内で確認された侵入はない。 - 国内の影響:約211の組織が予防のためサービスを一時停止(piyolog集計、10月22日1時時点)。報道ではコドモン、BASE、Cygames、ニコニコ、pixiv、静岡銀行、阪急電鉄など。レンタルサーバー各社が緊急メンテナンス。さくらのクラウドはデータベースアプライアンスのphpMyAdmin等の画面を停止。 - 日本の公的機関:IPAが10月21日に「事前準備のお願い」。JVNに JVNVU#99905564(10月22日)。JPCERT/CCの注意喚起は10月22日時点で出ていない。 - "php2shell" is the nickname for two critical flaws in PHP itself, fixed on 21 October 2026: CVE-2026-109618 (out-of-memory corruption) and CVE-2026-109619 (stale global state). - Under the right conditions an unauthenticated attacker can run commands on the server by sending a crafted request (remote code execution). - Severity: CVSS v4.0 9.2 Critical (PHP security team); 9.8 on CVSS v3.1 (NIST). The "10.0" that circulated before release was wrong. - Fixed in PHP 8.5.12, 8.4.27, 8.3.36 and 8.2.35 (released 21 October 2026, about 13:30–14:00 UTC; php.net's ChangeLog dates them 22 October). - Affected: nearly every version from at least PHP 5.4. PHP 8.1 and older get no official release; the PHP team published minimal source backports for 7.4, 8.0 and 8.1 on GitHub branches. - All PHP serving web requests is affected (PHP-FPM, Apache mod_php, php-cgi, FrankenPHP, LiteSpeed). mod_php is highest risk: the attack works with default settings before any application code runs. - Shown to work against WordPress, Drupal, Joomla and Magento; the application does not matter. - Exploitation as of 22 October 2026: CISA and IPA have not confirmed exploitation; watchTowr reports attempts; not on CISA KEV; no confirmed intrusion in Japan. - Japan: about 211 organisations paused services as a precaution (piyolog count, 22 Oct 01:00 JST), including CoDMON, BASE, Cygames, Niconico, pixiv, Shizuoka Bank and Hankyu Railway per news reports. ## しくみ (How it works) CVE-2026-109618(途中で投げ出された書類):PHPのワーカーはリクエストのフォームの中身をメモリに書き込みながら準備する。途中でメモリ不足になると、PHPは longjmp() で作業を投げ出して後片付け(リクエスト終了処理)へ飛ぶ。このとき一部のメモリが「参照できるが初期化されていない」まま残り、終了処理がそれを完成品として読んだり、それに従って分岐したりする。攻撃者は、長さの宣言がない・パートごとのヘッダー数が無制限・空のファイル欄・入れ子のフィールド名などのmultipartアップロードで、PHPの見かけの上限内のままメモリを使い切らせる。mod_phpはリクエスト開始が失敗しても終了処理を走らせるため、アプリのコードより前に成立する。修正ではメモリ不足で longjmp() せず、次の安全な地点で止める「ソフトなOOM」と、より高い上限での _exit() に変更。 CVE-2026-109619(はがし忘れた付せん):使い回されるワーカーは、エラー・セッション・オブジェクト・拡張機能のグローバル状態を持ち、それが1件のリクエストのメモリを指す。致命的エラー(メモリ不足・タイムアウト)で初期化が飛ばされる、または後の終了処理の診断メッセージが状態を書き戻すと、解放済みのメモリを指す参照が残る。同じワーカーの次のリクエストで、通常の初期化より前にその状態が使われると、解放後使用(use-after-free)・メモリの漏えい・命令実行になる。確認された「使う側」:既定で有効なセッションのアップロード進捗(session_start() を呼ばなくても届く)、ディレクトリ単位の無効・非推奨な設定から出る警告(@ や display_errors=0 でも出る)、PHP 8.5で既定有効の fatal_error_backtraces。ワーカーが多いと成功率は下がるがゼロにはならない。メモリからパスワード・トークン・APIキーが漏れる恐れもある。 CVE-2026-109618 (the half-filled form): when memory runs out while a worker is writing request data, PHP longjmp()s straight to request shutdown, leaving some memory reachable but uninitialised; shutdown then reads it or branches on it. Crafted multipart uploads exhaust memory while staying inside PHP's apparent limits. mod_php runs shutdown even when startup fails, so the attack lands before application code runs. The fix removes the longjmp on OOM (soft OOM at the next safe point, hard _exit() at a higher threshold). CVE-2026-109619 (the stale sticky note): reused workers keep global state pointing into one request's memory. A fatal error can skip the reset, or later diagnostics can repopulate it, so a later request on the same worker uses freed memory before normal initialisation. Confirmed consumers: session upload progress (on by default, reachable without session_start()), warnings from invalid/deprecated per-directory settings (even when hidden), and fatal_error_backtraces on PHP 8.5. Impact: use-after-free, memory disclosure (passwords, tokens, API keys) and code execution. ## つなぎ方(SAPI)ごとの危険度 (Risk by SAPI) - Apache + mod_php:最も高い。既定の設定でログインなしの命令実行を確認。 / Highest; unauthenticated RCE confirmed with defaults. - PHP-FPM:高い。②はセッションのアップロード進捗で通常のプールでも命令実行を確認、①もアプリの処理経由で確認。 / High; flaw 2 confirmed on a normal pool via session upload progress, flaw 1 via application code paths. - php-cgi:対象。 / Affected. - LiteSpeed (LSAPI):影響の可能性が高い(未検証)。国内のレンタルサーバーで多い。 / Likely affected (untested); common on Japanese shared hosting. - FrankenPHP:既定で知られた経路はないが「影響しないとは言えない」。 / No known default path, but not immune. - コマンドラインのみ:低い。 / CLI only: low. ## いますぐやること (What to do now) 1. 使っているPHPをすべて洗い出す(php -v、phpinfo() の Server API、レンタルサーバーの管理画面、PHPが組み込まれた製品も)。 / Inventory every PHP (php -v, phpinfo() Server API, hosting control panel, embedded products). 2. 8.5.12・8.4.27・8.3.36・8.2.35以降へ更新し、すべてのワーカーを再起動。Linuxのパッケージは番号が古いままのことがある(例:Ubuntu 24.04 の 8.3.6-0ubuntu0.24.04.13 は修正済み)ので、ディストリビューションのお知らせで確認。 / Update and restart every worker; distribution packages may keep old version numbers. 3. PHP 8.1以前は8.4か8.5へ移行、または修正を出す保守ベンダーの版を使う。移れないサイトは一時停止も検討。8.2は2026年12月31日でサポート終了。 / Move off 8.1 and older; consider taking unmovable sites offline. 8.2 ends 31 Dec 2026. 4. 当面の対策(これだけでは安全にならない):memory_limit=-1 を php_admin_value で固定しメモリはコンテナ/cgroupで制限(RLIMIT_AS・RLIMIT_DATA は使わない)、post_max_size を小さく(アップロードなし8M、あり32M)、Webサーバー/プロキシでリクエストの大きさと形を制限、session.upload_progress.enabled=0 を php.ini かプール設定で入れて全ワーカー再起動(ini_set() や .user.ini では効かない)、PHP 8.5では fatal_error_backtraces=0、無効・非推奨のディレクトリ単位の設定を消す、pm.max_requests=1、WAF。 / Stopgaps (not a fix): as listed. 5. 攻撃の痕跡:PHPのプロセス(php-fpm、php-cgi、httpd、apache2)がシェルや curl・wget を起動、「Allowed memory size … exhausted … Unknown on line 0」と異常に大きなPOSTが同時刻、Apacheのsegfault、ワーカーの不自然な入れ替わり、異常に長い・形のおかしい PHPSESSID。疑わしければサーバー上のパスワード・APIキー・トークンを入れ替え、JPCERT/CCやIPAの窓口へ。 / Signs of attack and response: as listed; rotate secrets if suspicious. ## PHPのサポート期限(2026年10月22日時点) (PHP support status) - 8.5:通常のサポート、セキュリティ修正は2029年12月31日まで。修正版 8.5.12。 - 8.4:通常のサポート、2028年12月31日まで。修正版 8.4.27。 - 8.3:セキュリティ修正のみ、2027年12月31日まで。修正版 8.3.36。 - 8.2:セキュリティ修正のみ、2026年12月31日で終了。修正版 8.2.35。 - 8.1:2025年12月31日で終了。8.0:2023年11月26日で終了。7.4:2022年11月28日で終了。7.3以前も終了。いずれも公式の修正版なし。 - 8.6:開発中(RC4に修正が入っている)。 ## 同じ時期のPHP関連の脆弱性 (Other recent PHP-related flaws) - WordPress本体 CVE-2026-87902(2026年9月22日、WordPress 7.1.2で修正。4.7.0〜7.1.1が対象。CVSS v4 9.2):ページのアドレスから選ぶテンプレートの確認が甘く、テーマ外のPHPファイルを読み込ませられる。テーマに「page-」で始まるフォルダーがあり、pearcmd.php のようなファイルがあると命令実行。公開から5時間足らずで攻撃開始(Patchstack)、CISAが9月25日にKEVへ追加。 - 2026年7月の「wp2shell」(CVE-2026-60137・CVE-2026-63030、WordPress 7.0.2で修正)はWordPressの問題で、php2shellとは別物。 - PHPの定例セキュリティリリース(2026年9月24日、8.5.11・8.4.26・8.3.35・8.2.34):11件のCVE(PHP-FPMのIPv6接続元チェック、TLSの名前確認、HTTPリダイレクトでの認証情報の漏れなど)。悪用の報告なし。 ## Bekitoのサーバー (Bekito's own servers) Bekitoのサービスを動かすサーバーにはPHPが入っていない(2026年10月22日に確認)。php2shellの影響はない。 None of the servers running Bekito's services has PHP installed (checked 22 October 2026). Bekitoは、攻撃者と同じ外側から古いサーバーソフトや管理画面の露出を調べる「外から見える入口チェック」を提供している: https://bekito.co.jp/security/#entry-check ## 出典 (Sources) - https://www.php.net/archive/2026.php#2026-10-21-5 (PHP Security advisory、2026-10-21/事前予告 2026-10-20) - https://github.com/php/php-src/security/advisories/GHSA-w8hw-w9fx-j79w - https://github.com/php/php-src/security/advisories/GHSA-6wmf-4rv5-p3rp - https://thephp.foundation/blog/2026/10/21/todays-php-security-release-and-how-were-strengthening-php-security/ - https://www.ipa.go.jp/security/security-alert/2026/pre-alert20261021.html - https://jvn.jp/vu/JVNVU99905564/ - https://www.cisa.gov/news-events/alerts/2026/10/21/critical-vulnerabilities-php-require-immediate-patching - https://watchtowr.com/intelligence/php-remote-code-execution-php2shell/ - https://www.wiz.io/blog/php2shell-php-rce - https://piyolog.hatenadiary.jp/entry/2026/10/21/174516 - https://www.itmedia.co.jp/news/article/2610/22/2000002480/ - https://cloud.sakura.ad.jp/news/2026/10/21/database-appliance-feature-suspension/ - https://ubuntu.com/security/notices/USN-8948-1 - https://www.php.net/supported-versions.php - https://github.com/WordPress/wordpress-develop/security/advisories/GHSA-7hp8-65ch-5whp - https://www.bleepingcomputer.com/news/security/hackers-start-exploiting-critical-wordpress-flaw-for-code-execution/ ## 関連 (Related) - Node.js・npmの脆弱性(2026年10月): https://bekito.co.jp/security/nodejs/ (テキスト版: https://bekito.co.jp/security/nodejs/llms.txt) - Bekitoがサービスを守るしくみ: https://bekito.co.jp/security/ (テキスト版: https://bekito.co.jp/security/llms.txt) - 日本のサイバー被害ダッシュボード: https://bekito.co.jp/security/japan/ - 問い合わせ: https://bekito.co.jp/#contact / hello@bekito.co.jp