mitmproxy / mitmproxy/mitmproxy

In upstream mode, https requests will cause changes in flow.mode

Open
#3,750 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

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

Description

Problem Description

In upstream mode, https requests will cause changes in flow.mode.

Steps to reproduce the behavior:

proxy.py

from mitmproxy import http

def request(flow: http.HTTPFlow) -> None:
    if flow.request.method == "CONNECT":
        return
    if flow.live:
        print("flow.mode:", flow.mode)
        host = "127.0.0.1"
        port = 7890
        flow.live.change_upstream_proxy_server((host, port))

run bash

mitmdump -p 8081
mitmdump --mode upstream:http://127.0.0.1:8081 -s proxy.py --ssl-insecure
export http_proxy=http://127.0.0.1:8080
export https_proxy=http://127.0.0.1:8080

result

$ curl https://httpbin.org/get
...
flow.mode: upstream
...
$ curl https://httpbin.org/get -k
...
flow.mode: transparent
...
System Information
$ mitmproxy --version
Mitmproxy: 4.0.4

I don't know if this is a bug, but I think #3721 and #2123 are related to this issue.

English is not my native language; please excuse typing errors.

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 by reproducing the behavior with the provided mitmdump, proxy.py, and curl commands, comparing requests with and without -k. Trace where flow.mode changes during HTTPS handling and upstream proxy switching; done when HTTPS requests preserve the expected upstream mode without regressing the shown cases.

Written by the indexing model from the issue text.

Assessment

Tech stack
python
Domain
networking
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.