-
Notifications
You must be signed in to change notification settings - Fork 596
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
Fix for ReDoS vulnerability #7943
Merged
Merged
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
mjambon
changed the title
Potential fix for ReDoS vulnerability
Fix for ReDoS vulnerability
Jun 3, 2023
mjambon
requested review from
a team,
ihji and
emjin
and removed request for
a team
June 3, 2023 00:55
5 tasks
mjambon
added a commit
that referenced
this pull request
Jun 6, 2023
…1024 (#7955) This fixes more of the same problems as #7943 test plan: * CI for correctness * For performance, follow these steps: ``` ~/semgrep/cli/src $ python3 Python 3.8.10 (default, Mar 13 2023, 10:26:41) [GCC 9.4.0] on linux Type "help", "copyright", "credits" or "license" for more information. >>> from semgrep.meta import get_repo_name_from_repo_url >>> get_repo_name_from_repo_url('0' * 1024) Traceback (most recent call last): File "<stdin>", line 1, in <module> File "/home/martin/semgrep/cli/src/semgrep/meta.py", line 60, in get_repo_name_from_repo_url result = p.parse() File "/home/martin/semgrep/cli/src/semgrep/external/git_url_parser.py", line 123, in parse raise ParserError(msg) semgrep.external.git_url_parser.ParserError: Invalid URL '0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000' ``` should fail instantly by Python standards. The following should fail even faster with a different error message: ``` >>> get_repo_name_from_repo_url('0' * 1025) Traceback (most recent call last): File "<stdin>", line 1, in <module> File "/home/martin/semgrep/cli/src/semgrep/meta.py", line 60, in get_repo_name_from_repo_url result = p.parse() File "/home/martin/semgrep/cli/src/semgrep/external/git_url_parser.py", line 115, in parse raise ParserError(msg) semgrep.external.git_url_parser.ParserError: URL exceeds maximum supported length of 1024: 00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 ``` PR checklist: - [x] Purpose of the code is [evident to future readers](https://semgrep.dev/docs/contributing/contributing-code/#explaining-code) - [x] Tests included or PR comment includes a reproducible test plan - [x] Documentation is up-to-date - [x] A changelog entry was [added to changelog.d](https://semgrep.dev/docs/contributing/contributing-code/#adding-a-changelog-entry) for any user-facing change - [ ] Change has no security implications (otherwise, ping security team) If you're unsure about any of this, please see: - [Contribution guidelines](https://semgrep.dev/docs/contributing/contributing-code)! - [One of the more specific guides located here](https://semgrep.dev/docs/contributing/contributing/) --------- Co-authored-by: Martin Jambon <martin@semgrep.com>
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
test plan:
The last command
get_repo_name_from_repo_url(payl)
should return (and fail) instantly as shown below. It should not get stuck in a long computation.PR checklist:
If you're unsure about any of this, please see: