Skip to content

Commit 2d615ef

Browse files
committed
Fix ReDOS in cpp/ql/src/Security/CWE/CWE-428/UnsafeCreateProcessCall.ql
The sub-regex `(\s|.)*` aims to capture arbitrary string content (in contrast to `.*` which doesn't match newlines), but it is unsafe, since non-newline whitespace can match both alternatives. This caused an evaluator crash in the wild. Replace with `[\s\S]*`, which matches everything in a safe way.
1 parent 768e519 commit 2d615ef

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

cpp/ql/src/Security/CWE/CWE-428/UnsafeCreateProcessCall.ql

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,7 @@ class QuotedCommandInCreateProcessFunctionConfiguration extends DataFlow2::Confi
9393

9494
bindingset[s]
9595
predicate isQuotedOrNoSpaceApplicationNameOnCmd(string s) {
96-
s.regexpMatch("\"([^\"])*\"(\\s|.)*") // The first element (path) is quoted
96+
s.regexpMatch("\"([^\"])*\"[\\s\\S]*") // The first element (path) is quoted
9797
or
9898
s.regexpMatch("[^\\s]+") // There are no spaces in the string
9999
}

0 commit comments

Comments
 (0)