Skip to content

Commit a3c7b02

Browse files
mceplJamesJohnUtley
andcommitted
[CVE-2024-9287] ensure that bracketed hosts found by urlsplit are of IPv6 or IPvFuture format
Fix urlparse incorrectly retrieves IPv4 and regular name hosts from inside of brackets Reproducer is python3 -c \ 'from urllib.parse import urlparse; print(urlparse("https://user:some]password[@host.com"))' This command should fail with the error "ValueError: '@host.com' does not appear to be an IPv4 or IPv6 address". If it doesn’t and produces ParseResult(scheme='https', netloc='user:some]password[@host.com', path='', params='', query='', fragment='') it is this bug. Fixes: bsc#1233307 (CVE-2024-11168) Fixes: gh#python#103848 Co-authored-by: JohnJamesUtley <[email protected]> From-PR: gh#python/cpython!103849 Patch: CVE-2024-11168-validation-IPv6-addrs.patch
1 parent d864fbc commit a3c7b02

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

Lib/ipaddress.py

+3-1
Original file line numberDiff line numberDiff line change
@@ -1911,7 +1911,7 @@ class IPv6Address(_BaseV6, _BaseAddress):
19111911

19121912
"""Represent and manipulate single IPv6 Addresses."""
19131913

1914-
__slots__ = ('_ip', '__weakref__')
1914+
__slots__ = ('_ip', '_scope_id', '__weakref__')
19151915

19161916
def __init__(self, address):
19171917
"""Instantiate a new IPv6 address object.
@@ -1934,12 +1934,14 @@ def __init__(self, address):
19341934
if isinstance(address, int):
19351935
self._check_int_address(address)
19361936
self._ip = address
1937+
self._scope_id = None
19371938
return
19381939

19391940
# Constructing from a packed address
19401941
if isinstance(address, bytes):
19411942
self._check_packed_address(address, 16)
19421943
self._ip = int.from_bytes(address, 'big')
1944+
self._scope_id = None
19431945
return
19441946

19451947
# Assume input argument to be string or any object representation

0 commit comments

Comments
 (0)