diff options
Diffstat (limited to 'meta-python/recipes-devtools/python/python3-urllib3/CVE-2021-33503.patch')
| -rw-r--r-- | meta-python/recipes-devtools/python/python3-urllib3/CVE-2021-33503.patch | 67 | 
1 files changed, 67 insertions, 0 deletions
diff --git a/meta-python/recipes-devtools/python/python3-urllib3/CVE-2021-33503.patch b/meta-python/recipes-devtools/python/python3-urllib3/CVE-2021-33503.patch new file mode 100644 index 0000000000..838add9555 --- /dev/null +++ b/meta-python/recipes-devtools/python/python3-urllib3/CVE-2021-33503.patch  | |||
| @@ -0,0 +1,67 @@ | |||
| 1 | From 2d4a3fee6de2fa45eb82169361918f759269b4ec Mon Sep 17 00:00:00 2001 | ||
| 2 | From: Seth Michael Larson <sethmichaellarson@gmail.com> | ||
| 3 | Date: Wed, 26 May 2021 10:43:12 -0500 | ||
| 4 | Subject: [PATCH] Improve performance of sub-authority splitting in URL | ||
| 5 | |||
| 6 | CVE: CVE-2021-33503 | ||
| 7 | Upstream-Status: Backport [https://github.com/urllib3/urllib3/commit/2d4a3fee6de2fa45eb82169361918f759269b4ec.patch] | ||
| 8 | Signed-off-by: Nikhil R <nikhil.r@kpit.com> | ||
| 9 | Signed-off-by: Ranjitsinh Rathod <ranjitsinh.rathod@kpit.com> | ||
| 10 | Comment: Refresh hunks to remove patch fuzz warnings | ||
| 11 | |||
| 12 | --- | ||
| 13 | src/urllib3/util/url.py | 8 +++++--- | ||
| 14 | test/test_util.py | 10 ++++++++++ | ||
| 15 | 2 files changed, 15 insertions(+), 3 deletions(-) | ||
| 16 | |||
| 17 | diff --git a/src/urllib3/util/url.py b/src/urllib3/util/url.py | ||
| 18 | index 6ff238fe3c..81a03da9e3 100644 | ||
| 19 | --- a/src/urllib3/util/url.py | ||
| 20 | +++ b/src/urllib3/util/url.py | ||
| 21 | @@ -63,12 +63,12 @@ IPV6_ADDRZ_RE = re.compile("^" + IPV6_ADDRZ_PAT + "$") | ||
| 22 | BRACELESS_IPV6_ADDRZ_RE = re.compile("^" + IPV6_ADDRZ_PAT[2:-2] + "$") | ||
| 23 | ZONE_ID_RE = re.compile("(" + ZONE_ID_PAT + r")\]$") | ||
| 24 | |||
| 25 | -SUBAUTHORITY_PAT = (u"^(?:(.*)@)?(%s|%s|%s)(?::([0-9]{0,5}))?$") % ( | ||
| 26 | +_HOST_PORT_PAT = ("^(%s|%s|%s)(?::([0-9]{0,5}))?$") % ( | ||
| 27 | REG_NAME_PAT, | ||
| 28 | IPV4_PAT, | ||
| 29 | IPV6_ADDRZ_PAT, | ||
| 30 | ) | ||
| 31 | -SUBAUTHORITY_RE = re.compile(SUBAUTHORITY_PAT, re.UNICODE | re.DOTALL) | ||
| 32 | +_HOST_PORT_RE = re.compile(_HOST_PORT_PAT, re.UNICODE | re.DOTALL) | ||
| 33 | |||
| 34 | UNRESERVED_CHARS = set( | ||
| 35 | "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789._-~" | ||
| 36 | @@ -368,7 +368,9 @@ def parse_url(url): | ||
| 37 | scheme = scheme.lower() | ||
| 38 | |||
| 39 | if authority: | ||
| 40 | - auth, host, port = SUBAUTHORITY_RE.match(authority).groups() | ||
| 41 | + auth, _, host_port = authority.rpartition("@") | ||
| 42 | + auth = auth or None | ||
| 43 | + host, port = _HOST_PORT_RE.match(host_port).groups() | ||
| 44 | if auth and normalize_uri: | ||
| 45 | auth = _encode_invalid_chars(auth, USERINFO_CHARS) | ||
| 46 | if port == "": | ||
| 47 | diff --git a/test/test_util.py b/test/test_util.py | ||
| 48 | index a5b68a084b..88409e2d6c 100644 | ||
| 49 | --- a/test/test_util.py | ||
| 50 | +++ b/test/test_util.py | ||
| 51 | @@ -425,6 +425,16 @@ class TestUtil(object): | ||
| 52 | query="%0D%0ASET%20test%20failure12%0D%0A:8080/test/?test=a", | ||
| 53 | ), | ||
| 54 | ), | ||
| 55 | + # Tons of '@' causing backtracking | ||
| 56 | + ("https://" + ("@" * 10000) + "[", False), | ||
| 57 | + ( | ||
| 58 | + "https://user:" + ("@" * 10000) + "example.com", | ||
| 59 | + Url( | ||
| 60 | + scheme="https", | ||
| 61 | + auth="user:" + ("%40" * 9999), | ||
| 62 | + host="example.com", | ||
| 63 | + ), | ||
| 64 | + ), | ||
| 65 | ] | ||
| 66 | |||
| 67 | @pytest.mark.parametrize("url, expected_url", url_vulnerabilities) | ||
