Skip to content

Support HTTP/3 through an HTTP(S) upstream proxy (CONNECT-UDP / MASQUE) #8633

Open

Description

@Giardi77

Problem Description

When a server connection is routed through an HTTP(S) upstream proxy, get_connection wraps the server layer in HttpUpstreamProxy (mitmproxy/proxy/layers/http/__init__.py:1124-1152), which opens a TCP CONNECT tunnel (mitmproxy/proxy/layers/http/_upstream_proxy.py:19-50). If the server layer is a QUIC/HTTP-3 layer (quic.ServerQuicLayer), the QUIC datagrams are written into that TCP tunnel. mitmproxy has no CONNECT-UDP (RFC 9298 / MASQUE) client, so HTTP/3 cannot be carried through an HTTP(S) upstream proxy.

For an addon this means routed HTTP/3 cannot work at all: today the only fail-closed option is to answer matched HTTP/3 flows with 502 before a server connection is made.

Steps to reproduce

Capture HTTP/3 (local redirect or WireGuard mode) and route it through an HTTP proxy with an addon:

def requestheaders(flow):
    if flow.request.is_http3:
        flow.server_conn.via = ("http", ("127.0.0.1", 18080))

with any HTTP proxy listening on 127.0.0.1:18080. The HTTP layer builds HttpUpstreamProxy around the QUIC server layer and sends a TCP CONNECT; the QUIC connection cannot use that tunnel. I verified the layer construction against the v12.3.1 source but did not run UDP capture end-to-end (it requires local mode or WireGuard).

Proposal

  • Implement CONNECT-UDP (RFC 9298) for HTTP/3 server connections whose server_conn.via points at an HTTP(S) upstream proxy.
  • If that is out of scope, fail routed HTTP/3 explicitly with a clear error and document that HTTP/3 is not routable through an HTTP(S) upstream proxy.

Additional context

Related: #8540 (support HTTP UDP MASQUE for HTTP/3), #7868 (forward WireGuard mode intercepts to an upstream proxy). A desktop UI built on mitmdump routes selected hosts through corporate HTTP proxies while capturing local/WireGuard traffic, including HTTP/3; today it has to fail matched HTTP/3 requests with 502.

Activity

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