Skip to content

fix: force http/1.1 ALPN on secure web proxy outer TLS - #8435

Open
asaf-shitrit wants to merge 4 commits into
mitmproxy:mainfrom
asaf-shitrit:fix/secure-web-proxy-alpn
Open

asaf-shitrit wants to merge 4 commits into
mitmproxy:mainfrom
asaf-shitrit:fix/secure-web-proxy-alpn

Conversation

@asaf-shitrit

@asaf-shitrit asaf-shitrit commented Sep 11, 2026

Copy link
Copy Markdown

Description

Continues #8204 (commit kept, @emanuele-em as author) and adds the behavioral test from review. A TLS client offering h2,http/1.1 gets http/1.1 on the outer handshake and h2 on the inner TLS through the tunnel. On main the first assertion fails.

server.address is None holds for the outer handshake in both explicit modes, because handle_connect sets it before the tunneled TLS and upstream mode leaves it unset until the first request. The extra conditions proposed in #8192 add nothing beyond the existing client assert and this check.

Not changed here: after CONNECT on a secure web proxy, NextLayer keys on the outer client.alpn and picks HttpLayer for the tunnel, so raw TCP through the tunnel stalls.

Closes #8192
Supersedes #8204

Checklist

  • I have updated tests where applicable.
  • I have added an entry to the CHANGELOG.

emanuele-em and others added 2 commits September 11, 2026 17:48
The existing test builds the layer stack by hand, which is how the
`len(context.layers) == 2` guard went stale unnoticed. This one runs
Proxyserver with TlsConfig, connects with a client offering h2,http/1.1,
and checks that the outer TLS gets http/1.1 while the inner TLS through
the CONNECT tunnel still gets h2.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Secure web proxy negotiates h2 ALPN with client, breaking HTTP/1.1 CONNECT

2 participants