# NGINX HTTP/2 Use-After-Free: CVE-2026-123633

NGINX HTTP/2 leaves connections marked reusable after stream creation, letting connection pressure free resolver state mid-request, causing use-after-free and potential RCE.

- Payout: Research
- Severity: critical
- Program: Nginx
- Write-up by: Bon Berry
- Disclosed: 2026-11-24
- CVE: CVE-2026-123633
- Write-up quality: 8/10
- Original: https://unit42.paloaltonetworks.com/cve-2026-123633-nginx-http2-vulnerability/
- Library page: https://bugbountylibrary.com/r/blog%3Aunit42-paloaltonetworks-com-cve-2026-123633-nginx-http2-vulnerability
- Tags: area:cloud domain:infra impact:dos impact:rce kind:research platform:threat-intel sev:critical tech:nginx technique:chained technique:source-review vuln:dos vuln:memory-corruption vuln:rce

**Target:** NGINX HTTP/2 reverse proxy with request-time DNS resolution
**Root cause:** ngx_http_v2_create_stream() fails to clear the reusable connection mark set when a partial HEADERS frame header arrives, so a live request sits on a connection cleanup logic still considers reclaimable. Under connection pressure, ngx_drain_connections() finalizes the live connection and frees resolver ctx while ngx_resolve_name_locked() still holds it.
**Steps:**
1. Configure HTTP/2 reverse proxy with variable proxy_pass hostname resolving via configured resolver (not literal IP or upstream group), worker_connections low (e.g. 16).
2. Open filler connections to approach the worker_connections limit.
3. Send a partial HTTP/2 HEADERS frame header (split the 9-byte header after 5 bytes) so ngx_http_v2_handle_connection() marks the connection reusable and returns early.
4. Send remaining header bytes; ngx_http_v2_create_stream() creates a live stream but leaves the reusable mark set.
5. Trigger request-time DNS lookup requiring a new resolver UDP socket; ngx_get_connection() runs ngx_drain_connections() which sets `c->close = 1; c->read->handler(c->read);` on the live connection.
6. Client closes socket with zero linger; GOAWAY write fails with Connection reset by peer, NGINX finalizes connection and request, ngx_resolve_name_done() frees ctx.
7. ngx_resolver_send_query() returns and ngx_resolver_set_timeout() reads freed ctx (`if (ctx->event || ctx->timeout == 0)`), ASan reports read from freed DNS lookup context.
**How found:** Researcher independently found the HTTP/2 connection-state defect while researching NGINX; noticed ngx_http_v2_create_stream() returns with the reusable mark still set after a partial frame header, then reasoned that a request-time DNS socket allocation under connection pressure would drain the live connection and free resolver state.
**Exploitation:** Chain with a separate unassigned memory disclosure leaking a libc pointer to compute libc base and bypass ASLR, then exploit the use-after-free for pre-auth RCE as the non-root NGINX worker. Required non-default NGINX configuration; some attempts failed to open a shell.
**Escalation:** Combined CVE-2026-123633 with an unassigned libc pointer disclosure to defeat ASLR and escalate from DoS to pre-authentication remote code execution as www-data.
**Insight:** When auditing connection-pool/reuse logic, check whether early-return paths that set a 'reusable' flag are cleared on the path that later creates a live stream; then look for any allocation inside request handling (DNS socket, upstream connect) that can trigger a drain and free state the request still references.

## Proof of concept (copied exactly from the original report)

**Split HEADERS frame header PoC trigger**

```
When a client sends only part of an HTTP/2 HEADERS frame header, ngx_http_v2_handle_connection() marks the connection reusable and returns early. The code below shows that decision:

ngx_reusable_connection(c, 1);

if (h2c->state.incomplete) {
 return;
}

 1
2
3
4
5

 ngx_reusable_connection(c, 1);
 
if (h2c->state.incomplete) {
 return;
}

The reusable mark lets NGINX reclaim connections stalled on partial frames before they exhaust the worker's slots.

The client then sends the remaining header bytes. ngx_http_v2_create_stream() builds a live stream and increments the active stream counter, but returns with the reusable mark still set:
```

**Resolver send then stale ctx timeout setup**

```
if (ngx_resolver_send_query(r, rn) != NGX_OK) {

 /* immediately retry once on failure */

 rn->last_connection++;
 if (rn->last_connection == r->connections.nelts) {
 rn->last_connection = 0;
 }

 (void) ngx_resolver_send_query(r, rn);
}

if (ngx_resolver_set_timeout(r, ctx) != NGX_OK) {
 goto failed;
}
```

**Drain closes reusable connection and calls handler**

```
c->close = 1;
c->read->handler(c->read);
```

