Skip to content

Commit 467aa64

Browse files
authored
Merge pull request github#6507 from tausbn/python-prevent-polynomial-redos-explosion
Python: Prevent explosion in poly-ReDoS query
2 parents eda7616 + 021e5ff commit 467aa64

File tree

1 file changed

+4
-0
lines changed

1 file changed

+4
-0
lines changed

python/ql/src/semmle/python/security/performance/RegExpTreeView.qll

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,4 +12,8 @@ import semmle.python.RegexTreeView
1212
*/
1313
predicate isExcluded(RegExpParent parent) {
1414
not exists(parent.getRegex().getLocation().getFile().getRelativePath())
15+
or
16+
// Regexes with many occurrences of ".*" may cause the polynomial ReDoS computation to explode, so
17+
// we explicitly exclude these.
18+
count(int i | exists(parent.getRegex().getText().regexpFind("\\.\\*", i, _)) | i) > 10
1519
}

0 commit comments

Comments
 (0)