Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

HTTPSConnection double wrapping IPv6 address during CONNECT #100985

Closed
derekhiggins opened this issue Jan 12, 2023 · 0 comments
Closed

HTTPSConnection double wrapping IPv6 address during CONNECT #100985

derekhiggins opened this issue Jan 12, 2023 · 0 comments
Labels
stdlib Python modules in the Lib dir type-bug An unexpected behavior, bug, or error

Comments

@derekhiggins
Copy link
Contributor

derekhiggins commented Jan 12, 2023

Bug report

when http.client.HTTPSConnection is used with IPv6 addresses and a proxy results in the "Host:" Header being
wrapped in square brackets twice. (e.g. Host: [[fd2e:6f44:5dd8:c956::15]]:5050 )

$ cat /tmp/proxy_test.py
import http.client, ssl
conn = http.client.HTTPSConnection("fd2e:6f44:5dd8:c956::1", 8215, context=ssl._create_unverified_context())
conn.set_tunnel("[fd2e:6f44:5dd8:c956::15]", 5050)
conn.request("GET", "/", "")
response = conn.getresponse()
print(response.status, response.reason)

$ python3 /tmp/proxy_test.py
400 Bad Request


=== tcp dump showing extra squar brackets in "Host:" header ==
CONNECT [fd2e:6f44:5dd8:c956::15]:5050 HTTP/1.0

HTTP/1.1 200 Connection established

GET / HTTP/1.1
Host: [[fd2e:6f44:5dd8:c956::15]]:5050
Accept-Encoding: identity
Content-Length: 0

HTTP/1.1 400 Bad Request
Date: Thu, 12 Jan 2023 11:47:38 GMT
Server: Apache
Content-Length: 226
Connection: close
Content-Type: text/html; charset=iso-8859-1


Your environment

$ cat /etc/redhat-release
Red Hat Enterprise Linux CoreOS release 4.12

$ rpm -qf /usr/bin/python3
python3-3.9.10-4.el9_0.x86_64

Linked PRs

@derekhiggins derekhiggins added the type-bug An unexpected behavior, bug, or error label Jan 12, 2023
derekhiggins added a commit to derekhiggins/cpython that referenced this issue Jan 12, 2023
Update _get_hostport to always remove square brackets
from IPv6 addresses. The return them back if needed
in "CONNECT .." and "Host: ".
derekhiggins added a commit to derekhiggins/cpython that referenced this issue Jan 12, 2023
Update _get_hostport to always remove square brackets
from IPv6 addresses. Then add them if needed
in "CONNECT .." and "Host: ".
derekhiggins added a commit to derekhiggins/cpython that referenced this issue Jan 12, 2023
Update _get_hostport to always remove square brackets
from IPv6 addresses. Then add them if needed
in "CONNECT .." and "Host: ".
derekhiggins added a commit to derekhiggins/cpython that referenced this issue Jan 19, 2023
Update _get_hostport to always remove square brackets
from IPv6 addresses. Then add them if needed
in "CONNECT .." and "Host: ".
derekhiggins added a commit to derekhiggins/cpython that referenced this issue Jan 26, 2023
Update _get_hostport to always remove square brackets
from IPv6 addresses. Then add them if needed
in "CONNECT .." and "Host: ".
derekhiggins added a commit to derekhiggins/cpython that referenced this issue Feb 2, 2023
Update _get_hostport to always remove square brackets
from IPv6 addresses. Then add them if needed
in "CONNECT .." and "Host: ".
derekhiggins added a commit to derekhiggins/cpython that referenced this issue Feb 23, 2023
Update _get_hostport to always remove square brackets
from IPv6 addresses. Then add them if needed
in "CONNECT .." and "Host: ".
@iritkatriel iritkatriel added the stdlib Python modules in the Lib dir label Nov 25, 2023
serhiy-storchaka pushed a commit that referenced this issue Feb 17, 2024
Update _get_hostport to always remove square brackets
from IPv6 addresses. Then add them if needed
in "CONNECT .." and "Host: ".
miss-islington pushed a commit to miss-islington/cpython that referenced this issue Feb 17, 2024
…thonGH-100986)

Update _get_hostport to always remove square brackets
from IPv6 addresses. Then add them if needed
in "CONNECT .." and "Host: ".
(cherry picked from commit 465db27)

Co-authored-by: Derek Higgins <derekh@redhat.com>
serhiy-storchaka pushed a commit that referenced this issue Feb 17, 2024
…H-100986) (GH-115591)

Update _get_hostport to always remove square brackets
from IPv6 addresses. Then add them if needed
in "CONNECT .." and "Host: ".
(cherry picked from commit 465db27)

Co-authored-by: Derek Higgins <derekh@redhat.com>
serhiy-storchaka pushed a commit to serhiy-storchaka/cpython that referenced this issue Feb 17, 2024
…ECT (pythonGH-100986)

Update _get_hostport to always remove square brackets
from IPv6 addresses. Then add them if needed
in "CONNECT .." and "Host: ".
(cherry picked from commit 465db27)

Co-authored-by: Derek Higgins <derekh@redhat.com>
serhiy-storchaka added a commit that referenced this issue Feb 17, 2024
…H-100986) (GH-115606)

Update _get_hostport to always remove square brackets
from IPv6 addresses. Then add them if needed
in "CONNECT .." and "Host: ".
(cherry picked from commit 465db27)

Co-authored-by: Derek Higgins <derekh@redhat.com>
woodruffw pushed a commit to woodruffw-forks/cpython that referenced this issue Mar 4, 2024
…thonGH-100986)

Update _get_hostport to always remove square brackets
from IPv6 addresses. Then add them if needed
in "CONNECT .." and "Host: ".
diegorusso pushed a commit to diegorusso/cpython that referenced this issue Apr 17, 2024
…thonGH-100986)

Update _get_hostport to always remove square brackets
from IPv6 addresses. Then add them if needed
in "CONNECT .." and "Host: ".
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
stdlib Python modules in the Lib dir type-bug An unexpected behavior, bug, or error
Projects
None yet
Development

No branches or pull requests

3 participants