
CVE-2026-119618 向けのコンテナ化された差分ラボおよび stdlib HTTP/2 PoC。Apache httpd 2.4.55-2.4.70 における mod_http2 のアロケータ競合によるヒープ破壊を対象とし、ASan/TSan による証拠を含む。
mod_http2 における assign_headers() のヒープ破壊| CVE | CVE-2026-119618 |
| コンポーネント | Apache HTTP Server、モジュール mod_http2(スタンドアロンの mod_h2) |
| 影響を受けるバージョン | httpd 2.4.55 – 2.4.70 · mod_h2 2.0.8 – 2.0.42 |
| 修正バージョン | httpd 2.4.71 · mod_h2 2.0.43 |
| CWE | CWE-362 — 不適切な同期を伴う共有リソースを使用した並行実行 |
| 影響 | httpd 子プロセスにおけるヒープ破壊。リモートコード実行の可能性 |
| ベクター | ネットワーク、未認証、HTTP/2(平文 h2c または TLS h2) |
| トリガー | Content-Type を伴い Content-Length を持たないボディなしの HTTP/2 リクエストで、リクエストヘッダーテーブルが容量まで埋められているもの |
| 修正コミット | 824beab9b9424d6cfb29595248fdbf6c3dddeab1(trunk 5ed39287660daacd1233cb9bbc984b25fa9a4fe3 のチェリーピック) |
| 上流 PR | apache/httpd#975 → apache/httpd#977、2026-11-09 にマージ |
| クレジット | Anthropic の OSS Scanner(ANT-2026-MAPKT6MZ)、Anthony Weems および Simon Scannell、Google Cloud Vulnerability Research |
| アドバイザリ | https://httpd.apache.org/security/vulnerabilities_24.html |
| 回避策 | Protocols ディレクティブから h2 と h2c を削除する |
| リポジトリ | https://github.com/googlesky/CVE-2026-119618 |
mod_http2 は各 HTTP/2 ストリームに専用のプールを与え、そのプールはセッションを所有するコネクションのアロケータを継承します。このアロケータにはミューテックスがありません。apr_allocator_create() はミューテックスを生成しないため、allocator_lock() はコネクション全体にとって何もしない処理(no-op)となります。リクエスト処理は、ワーカーがコネクションのアロケータに決して触れないようにするため、まさにその目的でプライベートなアロケータ(c2_transit_create())を持つワーカースレッドへ意図的に移されます。assign_headers() はこの不変条件を破ります。Content-Type を伴い Content-Length を持たないボディなしのリクエストに対して、ワーカーは合成された Content-Length: 0 を、リクエスト専用の r->headers_in ではなく共有のストリームテーブルへ書き込みます。テーブルが満杯のとき、この書き込みはコネクションのロックフリーアロケータから新しい 8 KB のノードを確保しますが、その間にコネクションスレッドが同じフリーリストから確保または解放を行っています。2 つのスレッドが同じノードをポップする可能性があり、その結果生じる二重所有が httpd 子プロセスのヒープを破壊します。
このリポジトリには、httpd 2.4.70 上で破壊を再現し、ThreadSanitizer でレースを証明し、同じトラフィック下で httpd 2.4.71 がクリーンであることを示し、あらゆる類似のリクエスト形状を検証し、公開された回避策を確認し、修正ライン上での 0-day スイープを記録する、コンテナ化された差分実験環境が含まれています。
modules/http2/h2_request.c、Apache httpd 2.4.70、assign_headers()。
行番号は 2.4.70 リリースの tarball に基づきます。
320: static void assign_headers(request_rec *r, const h2_request *req,
321: int no_body, int is_connect)
322: {
323: const char *cl;
324:
325: r->headers_in = apr_table_clone(r->pool, req->headers);
...
341: /* Unless we open a byte stream via CONNECT, apply content-length guards. */
342: if (!is_connect) {
343: cl = apr_table_get(req->headers, "Content-Length");
344: if (no_body) {
345: if (!cl && apr_table_get(req->headers, "Content-Type")) {
346: /* If we have a content-type, but already seen eos, no more
347: * data will come. Signal a zero content length explicitly.
348: */
349: apr_table_setn(req->headers, "Content-Length", "0");
350: }
351: }
2.4.71 での修正は 1 行を変更します:
- apr_table_setn(req->headers, "Content-Length", "0");
+ apr_table_setn(r->headers_in, "Content-Length", "0");
r->headers_in は r->pool の325行目で作成されたクローンであり、ワーカースレッドが所有するリクエストプールです。req->headers はストリームのテーブルであり、ストリームプールから割り当てられ、接続スレッドから到達可能です。
h2_session_open_stream() (h2_session.c:117) は、セッションプールの子としてストリームごとのプールを作成し、タグを付けます:
apr_pool_create(&stream_pool, session->pool);
apr_pool_tag(stream_pool, "h2_stream");
stream = h2_stream_create(stream_id, stream_pool, session, ...);
セッションプールは、MPM が child_main() 内で作成するコネクションプールの子孫です(server/mpm/prefork/prefork.c:423)。そのプールのアロケータは apr_allocator_create() に由来しており、そこにはミューテックスが一切設定されていません:
/* memory/unix/apr_pools.c:164 */
static APR_INLINE void allocator_lock(apr_allocator_t *allocator)
{
#if APR_HAS_THREADS
if (allocator->mutex) /* NULL for the MPM allocator */
apr_thread_mutex_lock(allocator->mutex);
#endif
}
一方、リクエスト処理は明示的にそのアロケータを避けるように設計されています。c2_transit_create()(h2_mplx.c:210)は各ワーカーにプライベートなアロケータを提供します:
/* We create a pool with its own allocator to be used for
* processing a request. This is the only way to have the processing
* independent of its parent pool in the sense that it can work in
* another thread.
*/
rv = apr_allocator_create(&allocator);
ワーカーの request_rec は、トランジットプールの子孫である c2->pool 上に作成されるため、ワーカーが通常行うすべての割り当てはプライベートです。
脆弱な書き込みは例外です。これはストリームプールから割り当てを行い、そのアロケータは接続のものです。
存在しないキーに対する apr_table_setn() は apr_table_add() にフォールスルーし、これが table_push() → apr_array_push_noclear() を呼び出します
(tables/apr_tables.c:126):
if (arr->nelts == arr->nalloc) {
int new_size = arr->nalloc <= 0 ? 1 : 2 * arr->nalloc;
apr_table_entry_t *new_elts = apr_palloc(arr->pool, elt_size * new_size);
...
}
テーブルは h2_request_create() によって apr_table_make(pool, 10) として作成されるため、nalloc は 10 から始まり倍々に増加します: 10、20、40、80、160。疑似ヘッダーはテーブルに格納されず、req->method、req->scheme、req->authority、req->path になります。
h2_request_end_headers()(h2_request.c:212)はちょうど 1 つの Host エントリを追加します。
したがって、79 個の通常ヘッダーを持つリクエストは 79 個のエントリを保持し、Host で 80 になり、assign_headers() が実行されると nelts == nalloc == 80 になります。脆弱な apr_table_setn() は配列を 160 エントリまで拡張します:
160 * sizeof(apr_table_entry_t) = 160 * 24 = 3840 bytes
allocator_align() (apr_pools.c:268) はそれを MIN_ALLOC
(8192) に丸めるため、プールのアクティブノードの残りが 3840 バイト未満になると、
書き込みはストリームプールのアロケータから新しい 8 KB ノードを要求します。
競合するのはこの割り当てです。
allocator_alloc() (apr_pools.c:289) は空きノードリスト
(allocator->free[index]、allocator->max_index) を走査してノードをポップし、
allocator_free() (apr_pools.c:426) はノードをプッシュして
max_index を書き換えます。ミューテックスがないため、これらは同じ
apr_allocator_t — child_main() 内の apr_allocator_create() によって
割り当てられた 200 バイトのヒープオブジェクト — に対する非同期の read-modify-write
シーケンスです。2 つのスレッドが同じノードをポップすると、その後 2 つの異なるプールが
重複するメモリを配布することになります。
ThreadSanitizer は 2.4.70 でまさにこれを検出します
(evidence/tsan-vulnerable.txt):
WARNING: ThreadSanitizer: data race
Read of size 8 at 0x7b34000001a0 by thread T1:
#0 allocator_alloc memory/unix/apr_pools.c:315
#1 apr_palloc memory/unix/apr_pools.c:843
#2 apr_array_push_noclear tables/apr_tables.c:132
#3 apr_table_setn tables/apr_tables.c:638
#4 assign_headers /build/httpd-2.4.70/modules/http2/h2_request.c:353
#5 h2_create_request_rec /build/httpd-2.4.70/modules/http2/h2_request.c:387
#6 c2_process /build/httpd-2.4.70/modules/http2/h2_c2.c:748
...
Previous write of size 8 at 0x7b34000001a0 by main thread:
#0 allocator_free memory/unix/apr_pools.c:480
#1 apr_allocator_free memory/unix/apr_pools.c:506
#2 apr_bucket_free buckets/apr_buckets_alloc.c:241
#3 socket_bucket_read buckets/apr_buckets_socket.c:43
...
Location is heap block of size 200 at 0x7b34000001a0 allocated by main thread:
#1 apr_allocator_create memory/unix/apr_pools.c:187
#2 child_main /build/httpd-2.4.70/server/mpm/prefork/prefork.c:423
ワーカー(スレッド T1、c2_process → assign_headers)はフリーリストを読み取り、
一方で接続スレッド(メインスレッド、h2_session_process →
h2_c1_read)がそれを書き込みます。競合するオブジェクトはアロケータそのものです。
この破壊は、アロケータ内部および接続スレッド上のストリームコードにおける
プロセスクラッシュとして観測されます — allocator_lock、
allocator_free、apr_palloc、run_cleanups、h2_stream_send_frame、
output_data_buffered(evidence/asan.*)。
h2_c2.c:748 は no_body フラグを渡します:
r = h2_create_request_rec(req, c, conn_ctx->beam_in == NULL);
conn_ctx->beam_in は stream->input から設定され、これはストリームがまだボディを期待している場合にのみ存在します。HEADERS フレームで終了するリクエストの場合、close_input() が実行済みで beam_in は NULL であるため、no_body == 1 となります。
したがって、この分岐には次の4つすべてが必要です:
Content-Type ヘッダー、Content-Length ヘッダーがないこと、:authority から合成される Host エントリ。CONNECT リクエストはこの分岐をショートカットします(if (!is_connect))。