8000 bpo-43075: Fix ReDoS in request by yetingli · Pull Request #24391 · python/cpython · GitHub
[go: up one dir, main page]

Skip to content

bpo-43075: Fix ReDoS in request #24391

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 7 commits into from
Apr 7, 2021
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
Next Next commit
Fix ReDoS
  • Loading branch information
yetingli authored Jan 31, 2021
commit 86664c9405136a4904775c52e6caf100a474ec58
2 changes: 1 addition & 1 deletion Lib/urllib/request.py
Original file line number Diff line number Diff line change
Expand Up @@ -939,7 +939,7 @@ class AbstractBasicAuthHandler:
# (single quotes are a violation of the RFC, but appear in the wild)
rx = re.compile('(?:^|,)' # start of the string or ','
'[ \t]*' # optional whitespaces
'([^ \t]+)' # scheme like "Basic"
'([^ \t,]+)' # scheme like "Basic"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This fix is correct, but can't we be more strict to parse the scheme? Do we really want to accept non-ASCII characters in the scheme? Or Unicode spaces? HTTP is like very conservative and I expect the scheme to be only made of ASCII letters maybe with "_" and "-" characters. Is there a RFC giving the grammar for the HTTP Basic scheme?

'[ \t]+' # mandatory whitespaces
# realm=xxx
# realm='xxx'
Expand Down
0