Skip to content

httplib: wrong Host header when connecting to IPv6 link-local address #73561

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

Closed
JonathanGuthrie mannequin opened this issue Jan 25, 2017 · 5 comments · Fixed by #93324
Closed

httplib: wrong Host header when connecting to IPv6 link-local address #73561

JonathanGuthrie mannequin opened this issue Jan 25, 2017 · 5 comments · Fixed by #93324
Assignees
Labels
3.7 (EOL) end of life stdlib Python modules in the Lib dir type-bug An unexpected behavior, bug, or error

Comments

@JonathanGuthrie
Copy link
Mannequin

JonathanGuthrie mannequin commented Jan 25, 2017

BPO 29375
Nosy @gpshead, @vadmium

Note: these values reflect the state of the issue at the time it was migrated and might not reflect the current state.

Show more details

GitHub fields:

assignee = None
closed_at = None
created_at = <Date 2017-01-25.20:14:44.074>
labels = ['3.7', 'type-bug', 'library']
title = 'httplib: wrong Host header when connecting to IPv6 link-local address'
updated_at = <Date 2017-01-26.21:13:35.139>
user = 'https://bugs.python.org/JonathanGuthrie'

bugs.python.org fields:

activity = <Date 2017-01-26.21:13:35.139>
actor = 'JonathanGuthrie'
assignee = 'none'
closed = False
closed_date = None
closer = None
components = ['Library (Lib)']
creation = <Date 2017-01-25.20:14:44.074>
creator = 'JonathanGuthrie'
dependencies = []
files = []
hgrepos = []
issue_num = 29375
keywords = []
message_count = 3.0
messages = ['286276', '286286', '286333']
nosy_count = 3.0
nosy_names = ['gregory.p.smith', 'martin.panter', 'JonathanGuthrie']
pr_nums = []
priority = 'normal'
resolution = None
stage = 'needs patch'
status = 'open'
superseder = None
type = 'behavior'
url = 'https://bugs.python.org/issue29375'
versions = ['Python 2.7', 'Python 3.5', 'Python 3.6', 'Python 3.7']

Linked PRs

@JonathanGuthrie
Copy link
Mannequin Author

JonathanGuthrie mannequin commented Jan 25, 2017

This is related to bpo-5111.

An IPv6 link-local address must include a scope specifier as part of the address passed to the HTTPConnection or HTTPSConnection constructor, that scope specifier is not being stripped from the address passed in the HTTP 1.1 Host: header line.

So, suppose I was attempting to connect to an HTTP server on fe80::8aae:1dff:fea4:29c8. That's a link-local address, so I must give the scope specifier, which is the interface I can use to connect to that address. So, the address I would pass to the HTTPConnection constructor might look like "fe80::8aae:1dff:fea4:29c8%eth0". The appropriate Host line in the HTTP request would be "Host: [fe80::8aae:1dff:fea4:29c8]" but it is actually "Host: [fe80::8aae:1dff:fea4:29c8%eth0]"

Compliant HTTP servers reject requests including this line as malformed.

@JonathanGuthrie JonathanGuthrie mannequin added the type-bug An unexpected behavior, bug, or error label Jan 25, 2017
@vadmium vadmium added 3.7 (EOL) end of life stdlib Python modules in the Lib dir labels Jan 25, 2017
@vadmium
Copy link
Member

vadmium commented Jan 25, 2017

More closely related: bpo-23448, about the same thing with urllib, which adds the Host value itself. Any solution should be shared between both modules.

@JonathanGuthrie
Copy link
Mannequin Author

JonathanGuthrie mannequin commented Jan 26, 2017

Yes, it is more closely related to bpo-23448. My search for related issues apparently wasn't exhaustive enough.

@mib1185
Copy link
Contributor

mib1185 commented Jul 5, 2023

Hi,
according to the dev-guid - reviewing, i would like to "ping" this issue.
Do you mind to have a look into the linked PR? Unfortunately it is without a review since more than a year, but it is a quite small PR to fix this issue.
thx

@mib1185
Copy link
Contributor

mib1185 commented Aug 17, 2023

Hi,
according to the dev-guid - reviewing, i would like to "ping" this issue.
Do you mind to have a look into the linked PR?
thx

@gpshead gpshead self-assigned this Nov 19, 2023
gpshead pushed a commit that referenced this issue Nov 19, 2023
…3324)

Omit the `@interface_scope` from an IPv6 address when used as Host header by `http.client`.

---------

Co-authored-by: Gregory P. Smith <[email protected]> [Google LLC]
miss-islington pushed a commit to miss-islington/cpython that referenced this issue Nov 19, 2023
…er (pythonGH-93324)

Omit the `@interface_scope` from an IPv6 address when used as Host header by `http.client`.

---------

(cherry picked from commit ce1096f)

Co-authored-by: Michael <[email protected]>
Co-authored-by: Gregory P. Smith <[email protected]> [Google LLC]
miss-islington pushed a commit to miss-islington/cpython that referenced this issue Nov 19, 2023
…er (pythonGH-93324)

Omit the `@interface_scope` from an IPv6 address when used as Host header by `http.client`.

---------

(cherry picked from commit ce1096f)

Co-authored-by: Michael <[email protected]>
Co-authored-by: Gregory P. Smith <[email protected]> [Google LLC]
gpshead pushed a commit that referenced this issue Nov 19, 2023
…der (GH-93324) (#112272)

gh-73561: Omit interface scope from IPv6 when used as Host header (GH-93324)

Omit the `@interface_scope` from an IPv6 address when used as Host header by `http.client`.

---------

(cherry picked from commit ce1096f)


 [Google LLC]

Co-authored-by: Michael <[email protected]>
gpshead pushed a commit that referenced this issue Nov 19, 2023
…der (GH-93324) (#112273)

gh-73561: Omit interface scope from IPv6 when used as Host header (GH-93324)

Omit the `@interface_scope` from an IPv6 address when used as Host header by `http.client`.

---------

(cherry picked from commit ce1096f)


 [Google LLC]

Co-authored-by: Michael <[email protected]>
aisk pushed a commit to aisk/cpython that referenced this issue Feb 11, 2024
…er (python#93324)

Omit the `@interface_scope` from an IPv6 address when used as Host header by `http.client`.

---------

Co-authored-by: Gregory P. Smith <[email protected]> [Google LLC]
Glyphack pushed a commit to Glyphack/cpython that referenced this issue Sep 2, 2024
…er (python#93324)

Omit the `@interface_scope` from an IPv6 address when used as Host header by `http.client`.

---------

Co-authored-by: Gregory P. Smith <[email protected]> [Google LLC]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
3.7 (EOL) end of life stdlib Python modules in the Lib dir type-bug An unexpected behavior, bug, or error
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants