-
Notifications
You must be signed in to change notification settings - Fork 66
discussion: what does mitmproxy need? #47
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
Thanks @njsmith! To add to the list:
In general, failing for a malformed client request is okay for us. The scenario we definitely want to avoid is having a connection where the behaviour is different if mitmproxy is in between or not. From the list above, our definite must-have requirements are probably header capitalization and order, and emitting HTTP/1.0 messages. It is worth noting that we also have the separate pathod/pathoc project for more creative forms of pentesting/fuzzing. I see three viable ways forward:
I'd generally prefer approach 3 - that'd be fantastic real-word validation for h11 and we'd have less code to maintain. However, I'd also understand if @cortesi has a considerably stronger preference for mirroring connections as-is. FWIW, the list above includes quite a few edge cases we don't support currently either (non-standard keepalive was never a problem so far, chunk extension metadata isn't implemented, we also strip whitespace around headers). |
Sounds all good! Or what everybody's general feeling regarding strict RFC-compliance vs. being liberal in what is accepted? Maybe I'm overthinking this, and in reality it is no big issue... |
Chaps, I'm open to being convinced, but at the moment i'm -1. Mitmproxy has two different constituencies. The first is app/web testers, who are completely fine with data not being relayed strictly accurately between the client and server, as long as gross behaviour doesn't change. The second are people who use mitmproxy as a forensic tool, and in other work where strict fidelity is crucial. When I was consulting, that was about half of the stuff I did. In this context, it's super important that what enters mitmproxy on one end is to the greatest extend possible identical to what exits it on the other. Because of this second use case, mitmproxy places demands on its protocol stack that aren't reasonable, and arguably makes the stack worse for conventional use. Things that are user conveniences or useful protections against errors in a user-focused protocol are fatal constraints for us. Even if we fixed some of the issues listed by @njsmith now, we can't expect the type of protocol fidelity we need to be a project goal for h11 in the longer term. |
This seems to have petered out, so closing... we can re-open if the discussion starts back up. |
I've been talking with @mhils a bit about this on IRC, and there's some discussion in https://github.com/njsmith/h11/issues/31#issuecomment-309774081, but I kind of want to see mitmproxy's requirements all written down in one place. Let's use this issue for that.
@mhils says:
Here are some places off the top of my head where h11 currently will not do byte-for-byte pass-through:
Transfer-Encoding
andConnection
)There are probably a few other issues like this that I'm not thinking of right now.
Also, as noted, we're pretty strict about forbidding a lot of things that a pentester might reasonably want to emit. (In fact, "would a pentester find this useful" is one of the criteria that we use to decide what to forbid, because generally you don't want your software to be accidentally turned into a pentester :-).) Some kinds of validation could be disabled without too much work (see e.g. #33), but other kinds are more difficult. For example, h11 absolutely won't tolerate incoming data with whitespace around header names (
Host : example.com
) or illegal characters in header values – both of which are classic sources of security bugs – and this is enforced implicitly by the regexes used to parse the header name and value in the first place, rather than being some extra code that could be switched on or off.I guess if you want to monkeypatch that's your business, but if you go that route then I feel like I should give you the standard warning just as a matter of practicality I don't think we can guarantee that your monkeypatches will keep working in future releases, or that the hooks you're trying to monkeypatch will even still exist. API guarantees only apply to APIs :-).
So... if you need h11 to be able to handle all of the pass-through cases listed above, then realistically I don't see how to implement that without the codebase turning into something monstrous and full of bugs. From discussions so far I'm guessing you don't actually care about all of these, but currently I don't understand the criteria that determine which ones you care about and which ones you don't, so I can't guess which ones are important. (In particular, it seems like HTTP/1.0 stuff might matter in practice?) Can you elaborate?
The text was updated successfully, but these errors were encountered: