8000 bpo-38804: Fix REDoS in http.cookiejar by bcaller · Pull Request #17157 · python/cpython · GitHub
[go: up one dir, main page]

Skip to content

bpo-38804: Fix REDoS in http.cookiejar #17157

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 6 commits into from
Nov 22, 2019
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Regression test for http.cookiejar REDoS
If we regress, this test will take a very long time.
  • Loading branch information
bcaller committed Nov 15, 2019
commit 04a3c611563a5fe36bbc83c0d4315a64d73d5847
7 changes: 7 additions & 0 deletions Lib/test/test_http_cookiejar.py
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,13 @@ def test_http2time_garbage(self):
"http2time(%s) is not None\n"
"http2time(test) %s" % (test, http2time(test)))

def test_http2time_redos_regression_actually_completes(self):
# LOOSE_HTTP_DATE_RE was vulnerable to malicious input which caused catastrophic backtracking (REDoS).
# If we regress to cubic complexity, this test will take a very long time to succeed.
# If fixed, it should complete within a fraction of a second.
http2time("01 Jan 1970{}00:00:00 GMT!".format(" " * 10 ** 5))
http2time("01 Jan 1970 00:00:00{}GMT!".format(" " * 10 ** 5))

def test_iso2time(self):
def parse_date(text):
return time.gmtime(iso2time(text))[:6]
Expand Down
0