Skip to content

Commit 5fe6671

Browse files
committed
making it more explicit what character class matching is used for
1 parent 4cc2ac9 commit 5fe6671

File tree

1 file changed

+3
-0
lines changed

1 file changed

+3
-0
lines changed

javascript/ql/src/Security/CWE-116/IncompleteMultiCharacterSanitization.ql

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,9 +67,12 @@ DangerousPrefixSubstring getADangerousMatchedChar(EmptyReplaceRegExpTerm t) {
6767
or
6868
t.getAMatchedString() = result
6969
or
70+
// A substring matched by some character class. This is only used to match the "word" part of a HTML tag (e.g. "iframe" in "<iframe").
7071
exists(ReDoSUtil::CharacterClass cc |
7172
cc = ReDoSUtil::getCanonicalCharClass(t) and
7273
cc.matches(result) and
74+
result.regexpMatch("\\w") and
75+
// excluding character classes that match ">" (e.g. /<[^<]*>/), as these might consume nested HTML tags, and thus prevent the dangerous pattern this query is looking for.
7376
not cc.matches(">")
7477
)
7578
or

0 commit comments

Comments
 (0)