Skip to content
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

Vulnerable Regular Expression in utils.py #3811

Closed
yetingli opened this issue Sep 3, 2020 · 1 comment
Closed

Vulnerable Regular Expression in utils.py #3811

yetingli opened this issue Sep 3, 2020 · 1 comment

Comments

@yetingli
Copy link
Contributor

yetingli commented Sep 3, 2020

Type of Issue
Potential Regex Denial of Service (ReDoS)

Description
The vulnerable regular expressions are located in

https://github.com/PyCQA/pylint/blob/2261844748be0f881719963d2fb5932dd4e4a2e2/pylint/pyreverse/utils.py#L54

https://github.com/PyCQA/pylint/blob/2261844748be0f881719963d2fb5932dd4e4a2e2/pylint/pyreverse/utils.py#L55

The ReDOS vulnerabilities of the regex are mainly due to the sub-pattern [^\W_]+\w* and can be exploited with the following string
"__"+"1"*5000 + "!"

I think you can limit the input length or modify these regexes.

@hippo91
Copy link
Contributor

hippo91 commented Sep 6, 2020

@yetingli thanks for the report.
It is very interesting. I am not at ease with security problems but very interested in. Can you develop a bit more what the problem is and how an attacker could exploit it. If it is not secure to develop more on this channel, feel free to send me a private mail.
As i understand, those regex could take a very long time to execute thus yielding to a DoS. Thats it?

@Pierre-Sassoulas Pierre-Sassoulas linked a pull request Sep 6, 2020 that will close this issue
Pierre-Sassoulas pushed a commit to Pierre-Sassoulas/pylint that referenced this issue Sep 9, 2020
yetingli pushed a commit to yetingli/pylint that referenced this issue Sep 10, 2020
The ambiguity of vulnerable regex is eliminated, so that when the fixed regex matches a string, there is only a unique path to match, thereby ensuring that the fixed regex is safer and faster to match.
This related issue addresses pylint-dev#3811
Pierre-Sassoulas pushed a commit to Pierre-Sassoulas/pylint that referenced this issue Sep 10, 2020
Pierre-Sassoulas pushed a commit to Pierre-Sassoulas/pylint that referenced this issue Sep 10, 2020
Pierre-Sassoulas pushed a commit to Pierre-Sassoulas/pylint that referenced this issue Sep 10, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants