mitmproxy / mitmproxy/mitmproxy

Endless Loop when Using Transparent Mode on Same Machine

Open
#3,139 7 comments 5 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

area/protocols kind/ux
Dominant language
Python
Stars
45.1k
Forks
4.7k
Avg merge
21h 12m
Merged PRs (30d)
16

Description

Steps to reproduce the problem

Add an entry in hosts file redirecting target website to localhost
Turn on IP Forwarding
Setup iptables as follows:
sudo iptables -t nat -A PREROUTING -p tcp --dport 443 -j REDIRECT --to-port 8080
etc. etc.

Run mitmproxy --mode transparent

Any other comments? What have you tried so far?

Seems that mitmproxy gets stuck in an endless loop as I'm trying to monitor the traffic on my own machine. It then bails out when there are too many open files and crashes. I'm not sure what's happening but I guess that when it opens the outgoing connection to the target website, it is getting the result from the hosts file, going to port 443 on localhost and being redirected back into itself. If this is the case then if a fix is desired I guess that when mitmproxy is looking up the target IP address it needs to bypass the local DNS server and get a result from the Internet, or at least somehow avoid using the hosts file.

System information

Mitmproxy: 4.0.0 binary
Python: 3.6.3
OpenSSL: OpenSSL 1.1.0h 27 Mar 2018
Platform: Linux-4.10.0-38-generic-x86_64-with-debian-stretch-sid (I'm actually using Mint)

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with the transparent-mode entry point and reproduce the issue on Linux using the hosts-file redirect, IP forwarding, and the stated iptables rule, then run mitmproxy --mode transparent. Done means same-machine transparent mode no longer loops until it exhausts open files or crashes.

Written by the indexing model from the issue text.

Assessment

Tech stack
linux, python
Domain
networking, operating-systems
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
32/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.