This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author steve.dower
Recipients benjamin.peterson, ezio.melotti, larry, ned.deily, steve.dower, vstinner
Date 2019-03-06.17:37:20
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <>
URLs encoded with Punycode/IDNA use NFKC normalization to decompose characters [1]. This can result in some characters introducing new segments into a URL.

For example, \uFF03 is not equal to '#' under direct comparison, but normalizes to '#' which changes the fragment part of the URL. Similarly \u2100 normalizes to 'a/c' which introduces a path segment.

Currently, urlsplit() does not normalize, which may result in it returning a different netloc from what a browser would

>>> u = "\"
>>> urlsplit(u).netloc.rpartition("@")[2]

>>> # Simulate
>>> u = "\".encode("idna").decode("ascii")
>>> urlsplit(u).netloc.rpartition("@")[2]

(Note that .netloc includes user/pass and .rpartition("@") is often used to remove it.)

This may be used to steal cookies or authentication data from applications that use the netloc to cache or retrieve this information.

The preferred fix for the urllib module is to detect and raise ValueError if NFKC-normalization of the netloc introduce any of '/?#@:'. Applications that want to avoid this error should perform their own decomposition using unicodedata or transcode to ASCII via IDNA.

>>> # New behavior
>>> u = "\"
>>> urlsplit(u)
ValueError: netloc '' contains invalid characters under NFKC normalization

>>> # Workaround 1
>>> u2 = unicodedata.normalize("NFKC", u)
>>> urlsplit(u2)
SplitResult(scheme='https', netloc='', path='', query='', fragment='')

>>> # Workaround 2
>>> u3 = u.encode("idna").decode("ascii")
>>> urlsplit(u3)
SplitResult(scheme='https', netloc='', path='', query='', fragment='')

Note that we do not address other characters, such as those that convert into period. The error is only raised for changes that affect how urlsplit() locates the netloc and the very common next step of removing credentials from the netloc.

This vulnerability was reported by Jonathan Birch of Microsoft Corporation and Panayiotis Panayiotou ( via the Python Security Response Team. A CVE number has been requested.

Date User Action Args
2019-03-06 17:37:20steve.dowersetrecipients: + steve.dower, vstinner, larry, benjamin.peterson, ned.deily, ezio.melotti
2019-03-06 17:37:20steve.dowersetmessageid: <>
2019-03-06 17:37:20steve.dowerlinkissue36216 messages
2019-03-06 17:37:20steve.dowercreate