You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
MITM crash when modifying request with 'chunked' content encoding #4824
127.0.0.1:55064: mitmproxy has crashed!
<---snip--->
ValueError: Received both a Transfer-Encoding and a Content-Length header, refusing as recommended in RFC 7230 Section 3.3.3. See https://github.com/mitmproxy/mitmproxy/issues/4799 for detail
At a glance, the issue looks to be at https://github.com/mitmproxy/mitmproxy/blob/main/mitmproxy/http.py#L375 where the content-length header is unconditionally set whenever content is updated. Perhaps this just needs a simple if ce != "chunked" guard? With another glance at the spec, chunked encoding specifies the chunk size within the body of each chunk and I'm assuming once we have a response all these chunks have already been decoded, so we don't have to worry about updating this for a modified response
Thanks, this is an excellent catch. I think the guard you are proposing is one correct piece of the puzzle. The other part is that we should only validate inbound requests, it's fine if we send Content-Length + Transfer-Encoding upstream if a CL header is added by a user.
Activity
mhils commentedon Sep 24, 2021
Thanks, this is an excellent catch. I think the guard you are proposing is one correct piece of the puzzle. The other part is that we should only validate inbound requests, it's fine if we send Content-Length + Transfer-Encoding upstream if a CL header is added by a user.
matthewhughes934 commentedon Sep 26, 2021
👍 adding with #4827
matthewhughes934 commentedon Sep 28, 2021
Closing as this is fixed with the PR I linked above.