File CVE-2020-8492-urllib-ReDoS.patch of Package python (Revision 381d91ea0ab10fc5235c75951d42564a)
Currently displaying revision 381d91ea0ab10fc5235c75951d42564a , Show latest
36
1
From 34e25a97709a05f7c804036dd1e16afda6bdfa33 Mon Sep 17 00:00:00 2001
2
From: Victor Stinner <vstinner@python.org>
3
Date: Thu, 30 Jan 2020 16:13:03 +0100
4
Subject: [PATCH 1/2] bpo-39503: Fix urllib basic auth regex
5
6
The AbstractBasicAuthHandler class of the urllib.request module uses
7
an inefficient regular expression which can be exploited by an
8
attacker to cause a denial of service. Fix the regex to prevent the
9
catastrophic backtracking.
10
11
Vulnerability reported by Matt Schwager.
12
---
13
Lib/urllib2.py | 2 +-
14
Misc/NEWS.d/next/Security/2020-01-30-16-15-29.bpo-39503.B299Yq.rst | 4 ++++
15
2 files changed, 5 insertions(+), 1 deletion(-)
16
create mode 100644 Misc/NEWS.d/next/Security/2020-01-30-16-15-29.bpo-39503.B299Yq.rst
17
18
--- /dev/null
19
+++ b/Misc/NEWS.d/next/Security/2020-01-30-16-15-29.bpo-39503.B299Yq.rst
20
21
+CVE-2020-8492: The :class:`~urllib.request.AbstractBasicAuthHandler` class of the
22
+:mod:`urllib.request` module uses an inefficient regular expression which can
23
+be exploited by an attacker to cause a denial of service. Fix the regex to
24
+prevent the catastrophic backtracking. Vulnerability reported by Matt Schwager.
25
--- a/Lib/urllib2.py
26
+++ b/Lib/urllib2.py
27
28
29
# allow for double- and single-quoted realm values
30
# (single quotes are a violation of the RFC, but appear in the wild)
31
- rx = re.compile('(?:.*,)*[ \t]*([^ \t]+)[ \t]+'
32
+ rx = re.compile('(?:[^,]*,)*[ \t]*([^ \t]+)[ \t]+'
33
'realm=(["\']?)([^"\']*)\\2', re.I)
34
35
# XXX could pre-emptively send auth info already accepted (RFC 2617,
36