Skip to content

Fix CONNECT response framing and IPv6 authority in tunnel proxies#493

Merged
ericmj merged 2 commits into
mainfrom
connect-tunnel-fixes
Jul 21, 2026
Merged

Fix CONNECT response framing and IPv6 authority in tunnel proxies#493
ericmj merged 2 commits into
mainfrom
connect-tunnel-fixes

Conversation

@ericmj

@ericmj ericmj commented Jul 19, 2026

Copy link
Copy Markdown
Member

Two fixes to HTTP/1 CONNECT tunnel establishment:

  • RFC 9110 (section 9.3.6) requires clients to ignore Content-Length and Transfer-Encoding header fields in a 2xx response to CONNECT. The HTTP/1 parser treated them as regular body framing, so a proxy replying with 200 plus content-length: 0 — which some real proxies send — emitted {:done, ref} as a body response and Mint.TunnelProxy rejected the tunnel with :unexpected_trailing_responses. Any 2xx response to CONNECT is now body-less: the response ends at the header section, and everything after it belongs to the tunnel, so it stays in the buffer instead of being parsed as HTTP.
  • The authority-form request target requires IPv6 addresses to be enclosed in square brackets (RFC 3986, section 3.2.2), but the tunnel proxy sent CONNECT ::1:443 for IPv6 targets, which proxies cannot parse unambiguously.

Both are covered by parser-level tests and by a new offline test module that runs full tunnel establishment against a local CONNECT proxy, so they run in the default suite without Docker.

ericmj added 2 commits July 19, 2026 18:29
RFC 9110 (section 9.3.6) forbids these header fields in a successful
response to CONNECT and requires clients to ignore them when present.
The HTTP/1 parser treated them as regular body framing, so a proxy
replying to CONNECT with "200" plus "content-length: 0" - which some
real proxies send - emitted {:done, ref} as a body response, and
Mint.TunnelProxy rejected the tunnel with :unexpected_trailing_responses.

Any 2xx response to CONNECT is now body-less: the response is done at
the end of the header section and everything after it belongs to the
tunnel, so it stays in the buffer instead of being parsed.
The authority-form request target requires IPv6 addresses to be
enclosed in square brackets (RFC 3986, section 3.2.2), but the tunnel
proxy sent "CONNECT ::1:443" for IPv6 targets, which proxies cannot
parse unambiguously.
@coveralls

Copy link
Copy Markdown

Coverage Report for CI Build 0

Coverage increased (+0.3%) to 87.881%

Details

  • Coverage increased (+0.3%) from the base build.
  • Patch coverage: 6 of 6 lines across 2 files are fully covered (100%).
  • No coverage regressions found.

Uncovered Changes

No uncovered changes found.

Coverage Regressions

No coverage regressions found.


Coverage Stats

Coverage Status
Relevant Lines: 1642
Covered Lines: 1443
Line Coverage: 87.88%
Coverage Strength: 493.88 hits per line

💛 - Coveralls

@ericmj
ericmj merged commit 4e38b23 into main Jul 21, 2026
3 checks passed
@ericmj
ericmj deleted the connect-tunnel-fixes branch July 21, 2026 12:15
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.

3 participants