-
-
Notifications
You must be signed in to change notification settings - Fork 443
Expand file tree
/
Copy path.semgrep.yml
More file actions
69 lines (68 loc) · 2.74 KB
/
Copy path.semgrep.yml
File metadata and controls
69 lines (68 loc) · 2.74 KB
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
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
# Cacti-aware Semgrep rules.
#
# Taint-mode rules that understand Cacti's own escapers, so findings are
# limited to request input that reaches a browser sink without passing through
# one of them. htmle()/html_escape() run htmlspecialchars(); htmlerv() and
# html_escape_request_var() are their request-var wrappers; sanitize_uri()
# cleans redirect targets. get_request_var() and get_nfilter_request_var()
# both return $_REQUEST values untouched (the filtering variant is
# get_filter_request_var()), so they are unsanitized sources.
rules:
- id: cacti-reflected-xss
mode: taint
languages: [php]
severity: ERROR
message: >-
Request input reaches echo/print without an HTML escaper. Wrap the value
in htmle()/html_escape() (or htmlerv()/html_escape_request_var() for
request vars) before output to prevent reflected XSS.
metadata:
cwe: "CWE-79: Improper Neutralization of Input During Web Page Generation (Cross-site Scripting)"
owasp: "A03:2021 - Injection"
category: security
confidence: MEDIUM
pattern-sources:
- pattern: $_GET[...]
- pattern: $_POST[...]
- pattern: $_REQUEST[...]
- pattern: get_request_var(...)
- pattern: get_nfilter_request_var(...)
pattern-sanitizers:
- pattern: htmle(...)
- pattern: html_escape(...)
- pattern: html_escape_request_var(...)
- pattern: htmlerv(...)
- pattern: sanitize_uri(...)
pattern-sinks:
- pattern: echo $SINK;
- pattern: print $SINK;
- id: cacti-header-injection
mode: taint
languages: [php]
severity: ERROR
message: >-
Request input reaches header() without sanitization. Validate or escape
the value (e.g. sanitize_uri() for redirect targets) before setting a
response header to prevent header injection and open redirects.
metadata:
cwe: "CWE-113: Improper Neutralization of CRLF Sequences in HTTP Headers (HTTP Response Splitting)"
owasp: "A03:2021 - Injection"
category: security
confidence: MEDIUM
# Only raw superglobals are sources here. The get_*_request_var() helpers
# feed the standard redirect idiom (header('Location: page.php?id=' .
# get_request_var('id'))) where 'id' is separately int-validated via
# get_filter_request_var(), so treating them as header sinks is low signal.
# A raw superglobal concatenated into header() is the genuine injection.
pattern-sources:
- pattern: $_GET[...]
- pattern: $_POST[...]
- pattern: $_REQUEST[...]
pattern-sanitizers:
- pattern: htmle(...)
- pattern: html_escape(...)
- pattern: html_escape_request_var(...)
- pattern: htmlerv(...)
- pattern: sanitize_uri(...)
pattern-sinks:
- pattern: header(...)