Mitmproxy --listen-host 127.0.0.1 and request replay

Hello all,

When I bind the proxy to the local interface, I cannot replay requests. Is this a bug or an expected behaviour?

Consider the following example:

  1. Start mitmproxy with no arguments. Proxy will listen on port 8080 of all interfaces.
    $ netstat -na | grep 8080
    tcp          0      0  *.8080                 *.*                    LISTEN
    
  2. Make a request through the proxy. Example: http_proxy="http://127.0.0.1:8080" curl -v http://www.example.org. A response is received.
  3. Modify or just resend the request in mitmproxy (key r). A new response is received, and everything works correctly.

And the following:

  1. Start mitmproxy binding only to the local interface. mitmproxy --listen-host 127.0.0.1
    $ netstat -na | grep 8080
    tcp          0      0  127.0.0.1.8080         *.*                    LISTEN
    
  2. Make a request through the proxy, as before. A response is received.
  3. Modify or just request the request in mitmproxy. Now the request fails after a while with an error. I see different error messages for HTTP and HTTPS requests. For HTTP, I get Error connecting to "www.example.org": [Errno -5] no address associated with name

I want mitmproxy only to listen on my local interface. I know that, by default, remote requests are ignored (allow_remote option is false by default), but I believe mitmproxy should behave similarly in both cases presented above. Am I correct?

I am testing with the following version:

$ mitmproxy --version
Mitmproxy: 3.0.0dev0967 (5067438e) 
Python:    3.6.0
OpenSSL:   LibreSSL 2.5.3
Platform:  OpenBSD-6.1-amd64-64bit

Thank you very much!

Definitely a bug - thanks. Would you mind filing an issue for this on GitHub so that we can keep track of it?

Thank you for your reply. Created the issue #2647 on GitHub.

1 Like