Skip to content

gh-161104: Check the http.client tunnel host after IDNA encoding - #161105

Open
gpshead wants to merge 1 commit into
python:mainfrom
gpshead:http-tunnel-host-idna-check
Open

gpshead wants to merge 1 commit into
python:mainfrom
gpshead:http-tunnel-host-idna-check

Conversation

@gpshead

@gpshead gpshead commented Nov 1, 2026 •

Copy link
Copy Markdown
Member

Encode the tunnel host with IDNA first and run the existing disallowed-character check on the bytes that go into the CONNECT request line. IDNA passes ASCII through unchanged, so every host refused today is still refused with the same message; the only newly refused hosts are those whose encoding contains a space.

The Host header built in putrequest() has the same encode-after-check order, but a host like that can't be resolved for a direct connection, so it is left alone here.

Fixes #161104

ANT-2026-PIZPMECM

IDNA normalization maps U+00A0 and similar characters to an ASCII space,
so check the encoded host that is put into the CONNECT request line.
@gpshead gpshead added needs backport to 3.14 bugs and security fixes needs backport to 3.15 bugs and security fixes labels Nov 1, 2026
@gpshead gpshead self-assigned this Nov 1, 2026
@gpshead
gpshead marked this pull request as ready for review November 1, 2026 18:13
@gpshead
gpshead enabled auto-merge (squash) November 1, 2026 18:14
@gpshead gpshead added needs backport to 3.11 only security fixes needs backport to 3.12 only security fixes needs backport to 3.13 only security fixes labels Nov 1, 2026
@gpshead

gpshead commented Nov 1, 2026 •

Copy link
Copy Markdown
Member Author

I marked this for full backporting security style as it might be a way that #146211 could be bypassed. FYI @SethMichaelLarson

ie: if so we should move the news entry to Security.

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

Labels

awaiting core review needs backport to 3.11 only security fixes needs backport to 3.12 only security fixes needs backport to 3.13 only security fixes needs backport to 3.14 bugs and security fixes needs backport to 3.15 bugs and security fixes

Projects

None yet

Development

Successfully merging this pull request may close these issues.

HTTPConnection.set_tunnel() host check runs before IDNA maps U+00A0 to a space

2 participants