Repository navigation
Conversation
Signed-off-by: Бат-Орших <[email protected]>
Signed-off-by: Бат-Орших <[email protected]>
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
ClientQuicLayeradds every Initial datagram tohandshake_datagram_buf. Each time one arrives, it re-parses the whole buffer with a fresh aioquic connection. If a client keeps sending valid but incomplete Initials on one UDP tuple, the buffer never stops growing and the parsing work grows roughly quadratically. That can stall the proxy for other clients.This change adds
MAX_CLIENT_HELLO_DATAGRAM_BYTES(64 KiB) to cap how much Initial data is buffered while waiting for a complete ClientHello. That is still plenty for fragmented ClientHellos, including large post-quantum ones. When the cap is exceeded, the buffer is cleared and the handshake fails. This uses the existing "Cannot parse ClientHello" error path, which logs a warning, firestls_failed_clientand closes the connection. Since every datagram is at least 1200 bytes, this also bounds the number of replays per tuple.The full incremental parser suggested in the issue is not part of this change. Keeping one
QuicConnectionacross calls would mean reworking the monkeypatching in_client_hello_parser.py, and the cap already bounds the work.Testing: I added
test_clienthello_too_large. It lowers the limit so that a legitimately fragmented ClientHello exceeds it, then checks that the connection is closed and the buffer is cleared. The existing fragmented-ClientHello tests still pass with the default limit.test/mitmproxy/proxy/layers/quic/passes with 100% coverage of_stream_layers.py, and ruff and mypy are clean.🤖 Generated with Claude Code
Fixes #8619
This change was prepared with an AI coding agent (Claude) and reviewed by me before submitting. I'm happy to make any changes you'd like.