Skip to content

Commit

Permalink
Merge pull request #2 from ActiveState/shaunl/cve-2020-8492
Browse files Browse the repository at this point in the history
Fix CVE-2020-8492 runaway regexp
  • Loading branch information
Stephen Reichling authored Sep 29, 2020
2 parents e5c690f + 33e2642 commit d0065ee
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions Lib/urllib2.py
Original file line number Diff line number Diff line change
Expand Up @@ -856,8 +856,16 @@ class AbstractBasicAuthHandler:

# allow for double- and single-quoted realm values
# (single quotes are a violation of the RFC, but appear in the wild)
rx = re.compile('(?:.*,)*[ \t]*([^ \t]+)[ \t]+'
'realm=(["\']?)([^"\']*)\\2', re.I)

rx = re.compile('(?:^|,)' # start of the string or ','
'[ \t]*' # optional whitespaces
'([^ \t]+)' # scheme like "Basic"
'[ \t]+' # mandatory whitespaces
# realm=xxx
# realm='xxx'
# realm="xxx"
'realm=(["\']?)([^"\']*)\\2',
re.I)

# XXX could pre-emptively send auth info already accepted (RFC 2617,
# end of section 2, and section 1.2 immediately after "credentials"
Expand Down

0 comments on commit d0065ee

Please sign in to comment.