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
Include sent headers with CONNECT request to upstream proxy #6328
base: main
Are you sure you want to change the base?
Include sent headers with CONNECT request to upstream proxy #6328
Conversation
Thanks for the PR! I see how this can be useful, but forwarding headers by default can also lead to unexpected leaks. For example, you may not want to forward your proxy authentication headers to an upstream proxy, or you do not want to forward the true user agent. I'd be happy to have this as an off-by-default option (something like
The upstream_auth option is already doing that I believe, see https://github.com/mitmproxy/mitmproxy/blob/main/mitmproxy/addons/upstream_auth.py. |
Thank you for the feedback. That makes sense, that it might accidentally leak content. I'll have a look if we can make it as an addon, but when I was playing with the different events it didn't seem like we could actually access the headers sent from the client to mitmproxy on the connect call. What Since I had to make the changes that I did in this PR for the connection between mitmproxy to the upstream proxy for any headers to be available in the flow in this event:
|
Take a look at the proxyauth addons - that one accesses them. |
07fa747
to
caea19b
Compare
Yes, you were completely right. Looks like it wasn't too difficult to achieve! I'll add some tests as well, but I'm not sure what your general policy is on addons. Do you merge them if they are general enough, or are they better left to each user to have on their side? Similar question to whether or not it should be a default addon or not? |
An |
Any update on this? :) |
Description
Includes the request headers from the client to the upstream proxy in the CONNECT request. Looking at #5802, and the relevant events, I don't believe that there is a way today to access the headers that are sent from the client and override the empty headers sent to the upstream proxy.
I don't know if this is the best way to tackle it, or if there is a reason to strip all the headers in the CONNECT request, but for my specific use case of the day, it would be nice to be able to handle the traffic differently based on the user agent of the caller.
Checklist