Skip to content

Scope proxyauth by proxy mode: transparent/local/WireGuard requests get 401 and lose the origin Authorization header #8631

Open

Description

@Giardi77

Problem Description

proxyauth is a single global option with no per-mode or per-listener scope. ProxyAuth.requestheaders authenticates every HTTP flow (mitmproxy/addons/proxyauth.py:75-83). is_http_proxy() is true only for RegularMode and UpstreamMode (mitmproxy/addons/proxyauth.py:143-151); every other mode takes the server-style branch: it reads Authorization, answers 401 with WWW-Authenticate when the header is missing or invalid, and, when it is valid, deletes it (del f.request.headers[auth_header], mitmproxy/addons/proxyauth.py:108).

So with proxyauth enabled, every request captured through transparent, local or WireGuard mode (and reverse mode) is replaced with a 401 unless the client sends proxy credentials as an origin Authorization header. If it does, the origin no longer receives its own Authorization header. One option also applies to every listener in the process, so an authenticated HTTP proxy listener cannot coexist with a transparent capture listener that has no login.

Steps to reproduce

mitmdump --mode reverse:http://127.0.0.1:18189 --set proxyauth=alice:s3cret
  • curl -i http://127.0.0.1:8080/ returns 401 with WWW-Authenticate: Basic realm="mitmproxy".
  • curl -i -H 'Authorization: Basic YWxpY2U6czNjcmV0' http://127.0.0.1:8080/ returns 200, but the origin receives no Authorization header; an origin Authorization: Bearer ... is consumed and rejected before it can be forwarded.

A local- or WireGuard-captured flow goes through the same branch.

Proposal

  • Scope proxyauth by proxy mode or listener: for example a per-mode/per-listener setting, or apply it only to regular/upstream servers unless explicitly enabled elsewhere.
  • Outside proxy modes, do not read or delete the request's Authorization header.

Additional context

A desktop UI built on mitmdump serves an explicit HTTP proxy listener with an optional client login and also captures transparent traffic (local redirect, WireGuard) in the same process; the login must not apply to the transparent listeners. Related: #4473 (proxy authentication in reverse mode, where the docs were updated to say mitmproxy falls back to Basic Auth).

Activity

  1. added a commit that references this issue on Nov 23, 2026
    eeb09ee
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions