Skip to the stories
AI & ML

NGINX HTTP/2 Use-After-Free: A Connection-Pressure Bug Fixed in 1.30.7 and 1.31.9

  • Bon Berry
  • 891 reads

A stale HTTP/2 connection flag can free memory still used by an active request. NGINX 1.30.7 and 1.31.9 contain the fix.

NGINX HTTP/2 Use-After-Free: A Connection-Pressure Bug Fixed in 1.30.7 and 1.31.9

A stale connection-state flag is at the center of CVE-2026-123633, a use-after-free defect in NGINX HTTP/2 reverse proxies. Under connection pressure, NGINX can reclaim a connection that still has an active request, freeing memory that request continues to use. F5 says an unauthenticated client may trigger a denial of service; its CVE record says code execution may be possible if address space layout randomization (ASLR) is disabled or bypassed.

The practical priority is to identify exposed HTTP/2 proxy workers and install a release containing the fix. NGINX lists versions 1.19.7 through 1.30.6 and 1.31.0 through 1.31.8 as affected. The stable branch fix is in 1.30.7; the mainline fix is in 1.31.9. F5 also lists affected NGINX Plus releases in its NGINX Plus advisory.

How the stale state leads to freed memory

NGINX keeps a reusable-connection queue so it can reclaim connections when a worker needs another connection slot. The bug arises because an HTTP/2 connection can remain marked reusable after a request has started. That leaves cleanup logic with a misleading signal: it sees a connection eligible for reuse even though a live request still depends on it.

The state can be left behind when a client sends only part of an HTTP/2 HEADERS frame header. In the affected code, ngx_http_v2_handle_connection() marks the connection reusable and returns early. When the rest of the header arrives, ngx_http_v2_create_stream() creates a live stream and increments the active-stream count, but affected releases fail to clear the reusable mark.

The fixes in 1.30.7 and 1.31.9 clear that state during stream creation with ngx_reusable_connection(h2c->connection, 0). That change closes the gap between the connection’s recorded status and the active work attached to it.

Why a DNS lookup can trigger the drain

The demonstrated path depends on a worker running low on free connection slots. A request-time DNS lookup can need a new UDP socket for its selected nameserver. If the worker doesn’t already have a socket for that server, and the answer isn’t cached or part of an in-flight lookup, opening the socket requires another connection slot.

Before allocating a connection, ngx_get_connection() checks whether connections need to be drained. ngx_drain_connections() can act when free slots fall to one sixteenth of worker_connections or less and at least one reusable connection is present. It selects connections from the reusable queue, marks them for closure and invokes their read handlers.

In the reproduced case, the request used an HTTP/2 proxy route with a variable upstream hostname, a configured resolver and a hostname that wasn’t a literal IP address or a configured upstream group. The DNS lookup therefore needed to run during the request. Opening a new resolver socket triggered the drain while the connection still carried an active request.

The client had closed its socket with zero linger after completing the frame. When NGINX tried to send a GOAWAY frame as part of handling the drained connection, the write failed with “Connection reset by peer.” NGINX then finalized the connection and request. Request cleanup reached ngx_resolve_name_done(), which freed the resolver state even though the lookup path still held a pointer to it.

The timing makes the defect a memory-lifetime problem across two parts of the request flow. In ngx_resolve_name_locked(), the DNS send happens before timeout setup. That send can trigger the connection drain and free the lookup context. When control returns, ngx_resolver_set_timeout() can read from the freed context; source review also found later writes through the stale pointer.

What testing showed—and what it didn’t

The researcher reproduced the use-after-free with AddressSanitizer on unmodified NGINX 1.31.7 and 1.31.8 builds. The test ran in an isolated Debian 13 guest, with NGINX built from source using Clang 19.1.7, HTTP/2, AddressSanitizer and UndefinedBehaviorSanitizer. Requests went over loopback. The sanitizer stopped the process at the first read from freed DNS lookup memory.

For the 1.31.8 run, the test set worker_connections to 16 and opened 13 filler connections that NGINX hadn’t marked reusable. The researcher split the nine-byte HEADERS frame header after five bytes. In a control run, the complete frame header arrived before the HPACK block; NGINX sent a DNS query and continued running. These conditions show one repeatable route to the bug, rather than a measure of how often it occurs in deployed systems.

The source build included HTTP/2, which requires the --with-http_v2_module build option. The test also used master_process off and a smaller connection limit than the documented default of 512. The public fix commit identifies upstream connection setup as another drain trigger. That makes it sensible to review static upstream routes as well as the variable-hostname DNS route used in the test.

F5’s CVE record assigns a 9.2 Critical score under CVSS 4.0 and an 8.1 High score under CVSS 3.1. The NGINX advisory labels the issue Medium. Those assessments use different scoring contexts; the operational behavior described by F5 is that an unauthenticated client may cause a denial of service when worker connections run low.

The report also describes a separate memory disclosure that exposed a libc pointer, and a demonstration combining that issue with CVE-2026-123633. The researcher reported the additional bug separately. F5 assessed it as limited to a non-typical configuration, and it had no CVE identifier at the time of the report. It isn’t necessary to reproduce that chain to understand or address the HTTP/2 connection-state defect.

Review configuration and logs, then upgrade

Start by confirming the running NGINX build and whether HTTP/2 is enabled on reverse-proxy listeners. Inspect routes that use variable destinations, configured resolvers and request-time upstream setup, then consider how close workers get to their connection limits. NGINX’s configuration output can help, but it shows files on disk; a master process may have started with a different configuration path, and loaded worker configuration can differ from current files.

A connection-drain warning can help with triage, but it isn’t proof of this defect. The warning can occur during ordinary connection pressure, while worker exits can have other causes. NGINX defaults to an error log level that omits warnings, so temporarily set error_log to warn or a more detailed level and correlate messages with traffic and worker state. The warning is rate-limited to at most once per second per worker, so a single line may cover multiple drain events.

The CVE record lists no workaround. If an upgrade has to wait, teams can use configuration review and connection-pressure monitoring to assess exposure, but those steps don’t replace the fix. After upgrading, verify that workers are running a binary containing the corrected code. A configuration reload with nginx -s reload leaves the old binary in memory; a full restart or live binary upgrade is needed to move workers onto the new executable.

F5’s advisory and the NGINX security advisories provide the affected-version details, while the CVE record describes the reported impact. F5 credits memN0ps of Palo Alto Networks Unit 42 among the reporters, alongside Albert Ebb of Metnir, Nir Ohfeld at Wiz Research, Xint.io, Hrithik Ram and Zenneth.

The key operational signal is the mismatch between an active HTTP/2 request and a connection still available for cleanup. Because the reproduced DNS path is only one way to reach that state, teams should treat affected HTTP/2 reverse proxies as candidates for upgrade and confirm the fixed binary is the one their workers actually run.

Source: Bon Berry · unit42.paloaltonetworks.com

From the same set