-
Notifications
You must be signed in to change notification settings - Fork 433
/
Copy pathregular-expression-dos.yaml
53 lines (53 loc) · 1.42 KB
/
regular-expression-dos.yaml
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
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
rules:
- id: regular-expression-dos
severity: WARNING
languages:
- C#
metadata:
cwe:
- 'CWE-1333: Inefficient Regular Expression Complexity'
owasp: 'A01:2017 - Injection'
references:
- https://owasp.org/www-community/attacks/Regular_expression_Denial_of_Service_-_ReDoS
- https://docs.microsoft.com/en-us/dotnet/standard/base-types/regular-expressions#regular-expression-examples
category: security
technology:
- .net
confidence: MEDIUM
subcategory:
- audit
likelihood: LOW
impact: MEDIUM
message: >-
When using `System.Text.RegularExpressions` to process untrusted input, pass a timeout.
A malicious user can provide input to `RegularExpressions` that abuses the backtracking behaviour of this regular expression engine.
This will lead to excessive CPU usage, causing a Denial-of-Service attack
patterns:
- pattern-inside: |
using System.Text.RegularExpressions;
...
- pattern-either:
- pattern: |
public $T $F($X)
{
Regex $Y = new Regex($P);
...
$Y.Match($X);
}
- pattern: |
public $T $F($X)
{
Regex $Y = new Regex($P, $O);
...
$Y.Match($X);
}
- pattern: |
public $T $F($X)
{
... Regex.Match($X, $P);
}
- pattern: |
public $T $F($X)
{
... Regex.Match($X, $P, $O);
}