]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
bpo-43075: Fix ReDoS in urllib AbstractBasicAuthHandler (GH-24391)
authorMiss Islington (bot) <31488909+miss-islington@users.noreply.github.com>
Wed, 7 Apr 2021 11:45:05 +0000 (04:45 -0700)
committerGitHub <noreply@github.com>
Wed, 7 Apr 2021 11:45:05 +0000 (04:45 -0700)
Fix Regular Expression Denial of Service (ReDoS) vulnerability in
urllib.request.AbstractBasicAuthHandler. The ReDoS-vulnerable regex
has quadratic worst-case complexity and it allows cause a denial of
service when identifying crafted invalid RFCs. This ReDoS issue is on
the client side and needs remote attackers to control the HTTP server.
(cherry picked from commit 7215d1ae25525c92b026166f9d5cac85fb1defe1)

Co-authored-by: Yeting Li <liyt@ios.ac.cn>
Lib/urllib/request.py
Misc/NEWS.d/next/Security/2021-01-31-05-28-14.bpo-43075.DoAXqO.rst [new file with mode: 0644]

index 550a2732697d94424399b51b269e1fbd9f2939b0..5f67077fb0a5ca96de4f7f4d77dc3ca6dbef7d3b 100644 (file)
@@ -951,7 +951,7 @@ class AbstractBasicAuthHandler:
     # (single quotes are a violation of the RFC, but appear in the wild)
     rx = re.compile('(?:^|,)'   # start of the string or ','
                     '[ \t]*'    # optional whitespaces
-                    '([^ \t]+)' # scheme like "Basic"
+                    '([^ \t,]+)' # scheme like "Basic"
                     '[ \t]+'    # mandatory whitespaces
                     # realm=xxx
                     # realm='xxx'
diff --git a/Misc/NEWS.d/next/Security/2021-01-31-05-28-14.bpo-43075.DoAXqO.rst b/Misc/NEWS.d/next/Security/2021-01-31-05-28-14.bpo-43075.DoAXqO.rst
new file mode 100644 (file)
index 0000000..1c9f727
--- /dev/null
@@ -0,0 +1 @@
+Fix Regular Expression Denial of Service (ReDoS) vulnerability in :class:`urllib.request.AbstractBasicAuthHandler`.  The ReDoS-vulnerable regex has quadratic worst-case complexity and it allows cause a denial of service when identifying crafted invalid RFCs. This ReDoS issue is on the client side and needs remote attackers to control the HTTP server.