From fb625c68684374b0fd9e6483e946811d460ea88c Mon Sep 17 00:00:00 2001 From: Maximilian Hils Date: Mon, 14 Jun 2021 12:35:08 +0200 Subject: [PATCH] fix h2 bug found via fuzzing --- mitmproxy/proxy/layers/http/_http2.py | 4 ++++ test/mitmproxy/proxy/layers/http/test_http_fuzz.py | 1 + 2 files changed, 5 insertions(+) diff --git a/mitmproxy/proxy/layers/http/_http2.py b/mitmproxy/proxy/layers/http/_http2.py index f2b5d5a12..7277e93fb 100644 --- a/mitmproxy/proxy/layers/http/_http2.py +++ b/mitmproxy/proxy/layers/http/_http2.py @@ -65,6 +65,8 @@ class Http2Connection(HttpConnection): stream is not None and stream.state_machine.state is not h2.stream.StreamState.CLOSED + and + self.h2_conn.state_machine.state is not h2.connection.ConnectionState.CLOSED ): return False else: @@ -79,6 +81,8 @@ class Http2Connection(HttpConnection): stream.state_machine.state is not h2.stream.StreamState.HALF_CLOSED_LOCAL and stream.state_machine.state is not h2.stream.StreamState.CLOSED + and + self.h2_conn.state_machine.state is not h2.connection.ConnectionState.CLOSED ): return True else: diff --git a/test/mitmproxy/proxy/layers/http/test_http_fuzz.py b/test/mitmproxy/proxy/layers/http/test_http_fuzz.py index 1aaeccbf1..05a9a6526 100644 --- a/test/mitmproxy/proxy/layers/http/test_http_fuzz.py +++ b/test/mitmproxy/proxy/layers/http/test_http_fuzz.py @@ -236,6 +236,7 @@ def _h2_request(chunks): @example([ b'\x00\x00%\x01\x04\x00\x00\x00\x01A\x8b/\x91\xd3]\x05\\\x87\xa6\xe3M3\x84\x86\x82`\x85\x94\xe7\x8c~\xfff\x88/\x91' b'\xd3]\x05\\\x87\xa7\\\x82h_\x00\x00\x07\x01\x05\x00\x00\x00\x01\xc1\x84\x86\x82\xc0\xbf\xbe']) +@example([b'\x00\x00\x03\x01\x04\x00\x00\x00\x01\x84\x86\x82\x00\x00\x08\x07\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00']) def test_fuzz_h2_request_chunks(chunks): _h2_request(chunks)