Skip to content

Commit 7215d1a

Browse files
authored
bpo-43075: Fix ReDoS in urllib AbstractBasicAuthHandler (GH-24391)
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.
1 parent d36d6a9 commit 7215d1a

File tree

2 files changed

+2
-1
lines changed

2 files changed

+2
-1
lines changed

Lib/urllib/request.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -945,7 +945,7 @@ class AbstractBasicAuthHandler:
945945
# (single quotes are a violation of the RFC, but appear in the wild)
946946
rx = re.compile('(?:^|,)' # start of the string or ','
947947
'[ \t]*' # optional whitespaces
948-
'([^ \t]+)' # scheme like "Basic"
948+
'([^ \t,]+)' # scheme like "Basic"
949949
'[ \t]+' # mandatory whitespaces
950950
# realm=xxx
951951
# realm='xxx'
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
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.

0 commit comments

Comments
 (0)