-
Notifications
You must be signed in to change notification settings - Fork 2k
Expand file tree
/
Copy pathOverlyLargeRange.ql
More file actions
27 lines (24 loc) · 969 Bytes
/
OverlyLargeRange.ql
File metadata and controls
27 lines (24 loc) · 969 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
/**
* @name Overly permissive regular expression range
* @description Overly permissive regular expression ranges match a wider range of characters than intended.
* This may allow an attacker to bypass a filter or sanitizer.
* @kind problem
* @problem.severity warning
* @security-severity 4.0
* @precision high
* @id java/overly-large-range
* @tags correctness
* security
* external/cwe/cwe-020
*/
private import semmle.code.java.regex.RegexTreeView::RegexTreeView as TreeView
import codeql.regex.OverlyLargeRangeQuery::Make<TreeView>
TreeView::RegExpCharacterClass potentialMisparsedCharClass() {
// nested char classes are currently misparsed
result.getAChild().(TreeView::RegExpNormalChar).getValue() = "["
}
from TreeView::RegExpCharacterRange range, string reason
where
problem(range, reason) and
not range.getParent() = potentialMisparsedCharClass()
select range, "Suspicious character range that " + reason + "."