Skip to content

Conversation

@Cycloctane
Copy link

@Cycloctane Cycloctane commented Nov 7, 2025

Description

mitmproxy does not limit the size and memory consumption when decoding http messages bodies. Clients or servers can easily crash mitmproxy by sending a single request/response with highly compressed data via proxy.

This pr makes mitmproxy use body_size_limit in option to limit decompressed body size of incoming http messages, protecting it from zip bombs DoS attacks.

http bodies decoding now raises ValueError as decoding fails if decompressed data length exceeds body_size_limit.

Checklist

  • I have updated tests where applicable.
  • I have added an entry to the CHANGELOG.

@Cycloctane
Copy link
Author

Cycloctane commented Nov 11, 2025

@mhils This is the PR mentioned in that advisory. Please take a look :)
This feature needs brotli v1.2.0. So it can not pass the old-dependencies tests.

Copy link
Member

@mhils mhils left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the PR and sorry for the slow turnaround! Overall I'm happy to add this DoS mitigation, but I don't think it warrants a new property on HttpMessage. Can we just use an option and access that directly please?

@Cycloctane
Copy link
Author

Could you please expand on that? This feature needs size limit settings from context options. But it seems that not all places that decode http messages have access to the current context.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants