NGINX HTTP/2 flaw: fragmented frame headers cause active connections to be reclaimed

This article has been automatically translated.
Loading article...
Merry Christmas & Happy New Year!
Loading article...
If you use NGINX as a reverse proxy or load balancer and have HTTP/2 enabled, here's an issue worth ten minutes of your time: can an unauthenticated client crash your worker processes, or even go further? This HTTP/2 connection-state flaw was found by memN0ps, a researcher at Palo Alto Networks' Unit 42, while studying NGINX independently. It is now tracked as CVE-2026-123633, confirmed by F5 in the CVE record, and fixed in NGINX 1.30.7 (stable branch) and 1.31.9 (mainline branch). Affected versions are 1.19.7 through 1.30.6 and 1.31.0 through 1.31.8; after upgrading you must do a full restart, because a reload alone leaves the old binary running in memory.
First, how NGINX manages connection slots. The number of connections each worker can hold at once is set by worker_connections. When free slots run short, NGINX picks a connection from a "reclaimable queue" and closes it to free up space. Once a connection enters this queue, NGINX considers it safe to close at any time.
By design, the reclaimable flag should be cleared as soon as a request begins. But in affected versions, ngx_http_v2_create_stream() creates the stream without clearing the flag.
Triggering it isn't complicated: the client sends only part of the HTTP/2 HEADERS frame header. At that point ngx_http_v2_handle_connection() sees an incomplete frame, marks the connection reclaimable, and returns early—a reasonable optimization in itself, keeping half-received frames from holding a slot indefinitely. The client then sends the remaining bytes, NGINX creates the stream normally and increments the active stream count, but the reclaimable flag is still there.
An analogy: the hotel front desk sees a guest walk into the hallway, marks the room as "available," and hands the key to someone else—while the guest is still in the room. The analogy falls short in one way: what gets "evicted" here is the memory of the DNS resolver context, and the request using it keeps running.
A wrong flag alone won't free memory; something has to force NGINX to reclaim slots. The chain Unit 42 reproduced goes like this: a request needs to resolve a hostname at runtime, so it opens a new resolver UDP socket; opening a socket needs a connection slot, and ngx_get_connection() runs a drain check first.
ngx_drain_connections() kicks in when free slots drop to one-sixteenth of worker_connections or below and the queue contains reclaimable connections. It takes connections from the tail of the queue, sets the close flag, and calls the read handler. Because the active request was wrongly left in the queue, its resolver state gets freed—while the query itself still holds a pointer to it.
In the code path specifically, the DNS send in ngx_resolve_name_locked() happens before the timeout is set. The send can trigger the drain and free ctx; after the send returns, ngx_resolver_set_timeout() keeps reading that freed pointer. That read is exactly what ASan reports; source review shows that if execution continues, it may also write ctx->event and ctx->ident through the same pointer.
So the exposure condition isn't as broad as "HTTP/2 is on"—it's a specific configuration shape:
Note that Unit 42 only tested proxy_pass, but the public fix commit also lists upstream connection establishment as a drain trigger, so static upstream routing needs review too. Variable targets in grpc_pass, fastcgi_pass, uwsgi_pass, and scgi_pass are worth checking as well.
There's a common trap here: the config on disk and the config loaded by the running workers may not be the same thing. The master process can point to another config file with -c, while nginx -T prints the config on disk. Check the master process's command line first, then decide which file is live.
The fix has the same gap. nginx -s reload leaves the old binary running in memory, so reloading after a package upgrade may keep vulnerable code serving traffic.
Here's a checklist you can follow:
If step 3 found a matching route but you can't upgrade yet, you can lower risk with the mitigations below for now.
The CVE record lists no official workaround, so any temporary measure only reduces risk—it is not a fix.
最直接的是在暴露的监听上关闭 HTTP/2。注意要检查每一处 listen ... http2 参数,以及在 NGINX 1.25.1 及以后版本中 http 或 server 上下文里的 http2 on; 设置——两者任一都可能让 HTTP/2 保持开启。代价也很实在:gRPC 客户端可能直接不可用;其他流量回落到 HTTP/1.1 后连接数可能上升,反而把同一个 worker 推近 worker_connections 上限。
Another option is to raise worker_connections to give workers more headroom. But this only increases the number of slots an attacker must consume; the flaw itself remains. Whichever you choose, test it before deploying, and don't treat it as a substitute for upgrading.
In its testing, Unit 42 observed that NGINX logged a connection-drain warning before ASan aborted the process. But this warning also appears under ordinary connection pressure, and worker exits can have entirely unrelated causes. Worse, release builds may keep running after reading freed memory, so "it didn't crash" doesn't mean you're safe.
One easily overlooked detail: this warning is logged at most once per second per worker, so one line may cover several drain calls; and NGINX's default error_log level is error, which excludes warnings. If your logs are at the default level, this signal won't be recorded at all.
Consider setting error_log to warn or a more verbose level, then correlate drain warnings with resolver traffic and worker status—rather than treating a single worker exit as direct evidence of compromise.
When making decisions, it's important to be honest about the scope of the evidence. The ASan evidence comes from source builds of 1.31.7 and 1.31.8, tested on the loopback interface; the 1.31.8 configuration set worker_connections to 16 (not the documented default of 512) and ran with master_process off, and the sanitizer aborted a single process.
Unit 42 reproduced one DNS socket path, while F5's CVE description covers a broader HTTP/2 reverse proxy scenario. Also, the severity ratings themselves are inconsistent: 9.2 Critical under CVSS 4.0, 8.1 High under CVSS 3.1, and Medium on the NGINX security advisory page. That disagreement is exactly why you should patch based on the certain fact of "which versions are fixed" rather than agonizing over the score.
If your environment differs from the test conditions, don't conclude you're safe. Upgrading to 1.30.7 or 1.31.9 and confirming the running binary actually includes the fix is the reliable way to close this out.