A local, differential proof-of-concept for a heap use-after-free in nginx's HTTP/2
module. A client can park a connection as *reusable* with a partial HEADERS frame,
then complete the request so a stream is created on that still-reusable connection.
Under `worker_connections` pressure nginx drains the connection while one of its
streams is being processed, frees the connection pool, and then continues using the
This repository builds the vulnerable and patched nginx under AddressSanitizer and
shows the UAF firing on 1.31.8 and absent on 1.31.9.
| Affected software | nginx, HTTP/2 module (`--with-http_v2_module`) |
| Vulnerability class | Heap use-after-free (CWE-416) |
| Demonstrated impact | Worker-process crash (denial of service) |
| Upstream fix | [`2df48a501`]( |
| Regression introduced in | [`76672e650`]( |
Commit `76672e650` made nginx register an HTTP/2 connection as *reusable* once it has
read a partial frame from the client but has no streams yet — a DoS mitigation for
clients that open a connection and stall. If a client sends only the first byte of a
HEADERS frame, the connection enters the reusable queue.
When the rest of the HEADERS frame arrives, `ngx_http_v2_create_stream` builds a
stream on that connection, but (before the fix) never clears the reusable flag. The
connection is now reusable *and* carries a live stream.
If that stream then does work that allocates a connection slot — for example a
`proxy_pass` upstream connect, which calls `ngx_get_connection` →
`ngx_drain_connections` under slot pressure — nginx may select this very connection
to drain. Draining a connection that still has streams makes nginx try to send a
GOAWAY frame; the client has reset the connection, so the send fails, and on send
failure nginx immediately finalizes the connection and releases its pool
(`ngx_destroy_pool`). Control then unwinds back up to the still-executing
`ngx_event_connect_peer`, which reads the request structure that was just freed.
The fix marks the connection non-reusable the moment a stream is created, so it can
never be selected for draining while a stream is live.
- The build and reproduction run entirely inside the container on loopback
(127.0.0.1). Nothing listens off-host and no external network is contacted at
runtime (the build clones nginx from GitHub).
- The bug is a race. The harness is tuned to hit it reliably but timing depends on
the host; the differential (crash on 1.31.8, no crash on 1.31.9) is the signal, not
- Confirmed on Linux/aarch64 with gcc 12.2 and AddressSanitizer. gcc is used rather
than clang because Debian's clang omits the aarch64 ASan runtime.
git clone && cd CVE-2026-123633-PoC
`make test` builds the Docker image (nginx 1.31.8 and 1.31.9 under ASan) and runs
8 trials against each build. Override the defaults with
The vulnerable build crashes with an AddressSanitizer report on every trial; the
# vuln (nginx 1.31.8), N=8, deadline=20s, wc=64 fillers=30
# patched (nginx 1.31.9), N=8, deadline=20s, wc=64 fillers=30
==NN==ERROR: AddressSanitizer: heap-use-after-free ...
#0 ... ngx_event_connect_peer src/event/ngx_event_connect.c:66
SUMMARY: AddressSanitizer: heap-use-after-free src/event/ngx_event_connect.c:66 in ngx_event_connect_peer
A full captured report is in [`evidence/asan_uaf_vuln.txt`](evidence/asan_uaf_vuln.txt).
From the captured report (`evidence/asan_uaf_vuln.txt`):
**Freed** — the connection pool is destroyed when the drained connection is finalized:
ngx_destroy_pool src/core/ngx_palloc.c:90
ngx_http_free_request src/http/ngx_http_request.c:4071
ngx_http_v2_close_stream src/http/v2/ngx_http_v2.c:4768
ngx_http_v2_finalize_connection src/http/v2/ngx_http_v2.c:5021
ngx_http_v2_read_handler src/http/v2/ngx_http_v2.c:380 (reentrant drain)
**Used after free** — the upstream connect, still on the stack, reads the freed request:
ngx_event_connect_peer src/event/ngx_event_connect.c:66 (READ of size 4)
ngx_http_upstream_connect src/http/ngx_http_upstream.c:1606
ngx_http_upstream_init_request src/http/ngx_http_upstream.c:868
ngx_http_v2_read_handler src/http/v2/ngx_http_v2.c:422 (outer HEADERS)
The request pool is allocated in `ngx_http_v2_create_stream`
(`src/http/v2/ngx_http_v2.c:3158`). `ngx_http_v2_read_handler` appears twice on the
stack — the outer HEADERS processing and the reentrant drain — which is the
self-drain reentry at the heart of the bug.
This demonstrates a memory-safety violation under AddressSanitizer and a
worker-process crash. It does **not** demonstrate remote code execution, information
disclosure, or exploitability on a production (non-ASan) build. The impact shown is
denial of service of the affected worker.
- Upstream fix commit:
- nginx source:
- `patches/` — the upstream fix diff and the commit that introduced the condition.
Apache License 2.0 — see [`LICENSE`](LICENSE).
The full story
This article is one source in a clustered incident — the cluster page carries the summary, timeline and every other outlet covering it.
