[3.5] bpo-39503: CVE-2020-8492: Fix AbstractBasicAuthHandler (GH-18284)#19305
[3.5] bpo-39503: CVE-2020-8492: Fix AbstractBasicAuthHandler (GH-18284)#19305larryhastings merged 2 commits intopython:3.5from vstinner:urllib_basic_auth_regex35
Conversation
|
For the backport, I replaced f-string with str.format() in tests. |
The AbstractBasicAuthHandler class of the urllib.request module uses an inefficient regular expression which can be exploited by an attacker to cause a denial of service. Fix the regex to prevent the catastrophic backtracking. Vulnerability reported by Ben Caller and Matt Schwager. AbstractBasicAuthHandler of urllib.request now parses all WWW-Authenticate HTTP headers and accepts multiple challenges per header: use the realm of the first Basic challenge. Co-Authored-By: Serhiy Storchaka <storchaka@gmail.com> (cherry picked from commit 0b297d4)
|
PR rebased on top of commit ed07522 (remove "Codecov patch" job from the CI). |
|
cc @larryhastings: the CI is now green. |
|
@larryhastings: This change is backward incompatible. If a HTTP header contains two Basic challenges, now the first one is used, whereas previously the last one was chosen. IMO the new behavior is more correct than the old one, but I prefer to warn you ;-) |
|
Ping @larryhastings: Would you mind to merge this backport to 3.5 of a security fix? |
|
When you're done making the requested changes, leave the comment: |
I was mistaken, and no changes are needed.
|
@larryhastings: Please replace |
The AbstractBasicAuthHandler class of the urllib.request module uses
an inefficient regular expression which can be exploited by an
attacker to cause a denial of service. Fix the regex to prevent the
catastrophic backtracking. Vulnerability reported by Ben Caller
and Matt Schwager.
AbstractBasicAuthHandler of urllib.request now parses all
WWW-Authenticate HTTP headers and accepts multiple challenges per
header: use the realm of the first Basic challenge.
Co-Authored-By: Serhiy Storchaka storchaka@gmail.com
(cherry picked from commit 0b297d4)
https://bugs.python.org/issue39503