-
Notifications
You must be signed in to change notification settings - Fork 2k
Expand file tree
/
Copy pathReDoS.ql
More file actions
23 lines (22 loc) · 942 Bytes
/
ReDoS.ql
File metadata and controls
23 lines (22 loc) · 942 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
/**
* @name Denial of Service from comparison of user input against expensive regex
* @description User input should not be matched against a regular expression that could require
* exponential time on certain input.
* @kind path-problem
* @problem.severity error
* @precision high
* @id cs/redos
* @tags security
* external/cwe/cwe-730
* external/cwe/cwe-400
*/
import csharp
import semmle.code.csharp.security.dataflow.ReDoS::ReDoS
import semmle.code.csharp.frameworks.system.text.RegularExpressions
import semmle.code.csharp.dataflow.DataFlow::DataFlow::PathGraph
from TaintTrackingConfiguration c, DataFlow::PathNode source, DataFlow::PathNode sink
where c.hasFlowPath(source, sink)
// No global timeout set
and not exists(RegexGlobalTimeout r)
select sink.getNode().(Sink), source, sink,
"$@ flows to regular expression operation with dangerous regex.", source.getNode(), "User-provided value"