8000 bpo-43075: Fix ReDoS in urllib AbstractBasicAuthHandler (GH-24391) (G… · python/cpython@3fbe961 · GitHub
[go: up one dir, main page]

Skip to content

Commit 3fbe961

Browse files
bpo-43075: Fix ReDoS in urllib AbstractBasicAuthHandler (GH-24391) (GH-25250)
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 7215d1a) Co-authored-by: Yeting Li <liyt@ios.ac.cn>
1 parent 6c472d3 commit 3fbe961

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
@@ -947,7 +947,7 @@ class AbstractBasicAuthHandler:
947947
# (single quotes are a violation of the RFC, but appear in the wild)
948948
rx = re.compile('(?:^|,)' # start of the string or ','
949949
'[ \t]*' # optional whitespaces
950-
'([^ \t]+)' # scheme like "Basic"
950+
'([^ \t,]+)' # scheme like "Basic"
951951
'[ \t]+' # mandatory whitespaces
952952
# realm=xxx
953953
# 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)
0