narvy-cli 1.0.0__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- narvy/__init__.py +3 -0
- narvy/android/__init__.py +0 -0
- narvy/android/source_analyzer.py +268 -0
- narvy/android/split_bundle.py +475 -0
- narvy/android_rule_context.py +196 -0
- narvy/apk_memory_preflight.py +248 -0
- narvy/auth.py +40 -0
- narvy/ci_templates/bitbucket.yml +25 -0
- narvy/ci_templates/github.yml +60 -0
- narvy/ci_templates/gitlab.yml +32 -0
- narvy/cloud/__init__.py +0 -0
- narvy/cloud/aws_scan.py +1188 -0
- narvy/comment_filter.py +134 -0
- narvy/crypto_taint_lite.py +82 -0
- narvy/decompiler.py +337 -0
- narvy/doctor.py +244 -0
- narvy/host/__init__.py +0 -0
- narvy/host/audit.py +157 -0
- narvy/host/host_knowledge.py +982 -0
- narvy/host/lynis_bootstrap.py +400 -0
- narvy/host/lynis_parser.py +358 -0
- narvy/host/narvy_checks.py +789 -0
- narvy/host/report.py +69 -0
- narvy/host/ssh_exec.py +219 -0
- narvy/ios/__init__.py +0 -0
- narvy/ios/binary_analyzer.py +1201 -0
- narvy/ios/plist_checks.py +249 -0
- narvy/ios/source_analyzer.py +301 -0
- narvy/ios/third_party_filter.py +242 -0
- narvy/ios/trust_all_context.py +66 -0
- narvy/main.py +1983 -0
- narvy/native_hardening.py +503 -0
- narvy/reporter.py +151 -0
- narvy/rule_engine.py +57 -0
- narvy/rules/android/config.yml +77 -0
- narvy/rules/android/crypto.yml +34 -0
- narvy/rules/android/secrets.yml +161 -0
- narvy/rules/android/storage.yml +24 -0
- narvy/rules/android/webview.yml +23 -0
- narvy/rules/android.yml +219 -0
- narvy/rules/ios/objc/crypto.yml +56 -0
- narvy/rules/ios/objc/network.yml +67 -0
- narvy/rules/ios/objc/secrets.yml +79 -0
- narvy/rules/ios/objc/storage.yml +45 -0
- narvy/rules/ios/objc/webview.yml +45 -0
- narvy/rules/ios_swift.yml +327 -0
- narvy/rules/web/go.yml +2837 -0
- narvy/rules/web/java.yml +1576 -0
- narvy/rules/web/javascript.yml +3683 -0
- narvy/rules/web/kotlin.yml +413 -0
- narvy/rules/web/local/csharp_narvy/config.yml +61 -0
- narvy/rules/web/local/csharp_narvy/crypto.yml +64 -0
- narvy/rules/web/local/csharp_narvy/deserialization.yml +59 -0
- narvy/rules/web/local/csharp_narvy/injection.yml +122 -0
- narvy/rules/web/local/csharp_narvy/xxe.yml +48 -0
- narvy/rules/web/local/java_narvy/auth_jwt.yml +134 -0
- narvy/rules/web/local/java_narvy/deserialization.yml +108 -0
- narvy/rules/web/local/java_narvy/mybatis.yml +39 -0
- narvy/rules/web/local/java_narvy/snakeyaml.yml +34 -0
- narvy/rules/web/local/java_narvy/spring_authz.yml +32 -0
- narvy/rules/web/local/java_narvy/spring_config.yml +67 -0
- narvy/rules/web/local/java_narvy/spring_hardening.yml +291 -0
- narvy/rules/web/local/java_narvy/sqli.yml +235 -0
- narvy/rules/web/local/java_narvy/xxe.yml +212 -0
- narvy/rules/web/php.yml +1644 -0
- narvy/rules/web/python.yml +3967 -0
- narvy/rules/web/ruby.yml +703 -0
- narvy/rules/web/rust.yml +258 -0
- narvy/rules/web/secrets.yml +1420 -0
- narvy/rules/web/secrets_supplement.yml +383 -0
- narvy/sca/__init__.py +1 -0
- narvy/sca/android_deps.py +349 -0
- narvy/sca/ios_deps.py +578 -0
- narvy/sca/osv_client.py +617 -0
- narvy/sca/web_deps.py +955 -0
- narvy/scope_config.py +195 -0
- narvy/semgrep_engine.py +219 -0
- narvy/stack_protector_evidence.py +96 -0
- narvy/third_party_filter.py +211 -0
- narvy/uploader.py +92 -0
- narvy/weak_prng_context.py +270 -0
- narvy/web/__init__.py +0 -0
- narvy/web/nuclei_binary.py +105 -0
- narvy/web/scan_blocklist.py +96 -0
- narvy/web/scanner.py +842 -0
- narvy/web/source_analyzer.py +714 -0
- narvy/web/ssrf_guard.py +374 -0
- narvy_cli-1.0.0.dist-info/METADATA +165 -0
- narvy_cli-1.0.0.dist-info/RECORD +93 -0
- narvy_cli-1.0.0.dist-info/WHEEL +5 -0
- narvy_cli-1.0.0.dist-info/entry_points.txt +2 -0
- narvy_cli-1.0.0.dist-info/licenses/LICENSE +202 -0
- narvy_cli-1.0.0.dist-info/top_level.txt +1 -0
|
@@ -0,0 +1,212 @@
|
|
|
1
|
+
rules:
|
|
2
|
+
|
|
3
|
+
# Java XXE hardening. The four rule ids below are a stable API - do not rename.
|
|
4
|
+
# Patterns are bounded on both ends (factory creation ... parse/build call); an open trailing `...` can double-match.
|
|
5
|
+
|
|
6
|
+
- id: narvy.java.xxe.documentbuilderfactory-disallow-doctype-decl-missing.documentbuilderfactory-disallow-doctype-decl-missing
|
|
7
|
+
message: >-
|
|
8
|
+
A `DocumentBuilderFactory` is created and used to parse XML without the
|
|
9
|
+
`http://apache.org/xml/features/disallow-doctype-decl` feature disabled.
|
|
10
|
+
Without it, a DOCTYPE declaration in the parsed document can define
|
|
11
|
+
external entities that read local files, reach internal network
|
|
12
|
+
services (SSRF), or exhaust memory (billion-laughs) (CWE-611). Call
|
|
13
|
+
`factory.setFeature("http://apache.org/xml/features/disallow-doctype-decl", true);`
|
|
14
|
+
right after creating the factory.
|
|
15
|
+
severity: ERROR
|
|
16
|
+
languages: [java]
|
|
17
|
+
metadata:
|
|
18
|
+
category: security
|
|
19
|
+
cwe:
|
|
20
|
+
- "CWE-611: Improper Restriction of XML External Entity Reference"
|
|
21
|
+
- "CWE-776: Improper Restriction of Recursive Entity References in DTDs"
|
|
22
|
+
owasp:
|
|
23
|
+
- "A05:2021 - Security Misconfiguration"
|
|
24
|
+
subcategory: [vuln]
|
|
25
|
+
likelihood: LOW
|
|
26
|
+
impact: HIGH
|
|
27
|
+
confidence: MEDIUM
|
|
28
|
+
technology: [java]
|
|
29
|
+
patterns:
|
|
30
|
+
- pattern: |
|
|
31
|
+
$DBF = DocumentBuilderFactory.newInstance();
|
|
32
|
+
...
|
|
33
|
+
$DBF.newDocumentBuilder();
|
|
34
|
+
- pattern-not: |
|
|
35
|
+
$DBF = DocumentBuilderFactory.newInstance();
|
|
36
|
+
...
|
|
37
|
+
$DBF.setFeature("http://apache.org/xml/features/disallow-doctype-decl", true);
|
|
38
|
+
...
|
|
39
|
+
$DBF.newDocumentBuilder();
|
|
40
|
+
|
|
41
|
+
- id: narvy.java.xxe.saxparserfactory-disallow-doctype-decl-missing.saxparserfactory-disallow-doctype-decl-missing
|
|
42
|
+
message: >-
|
|
43
|
+
A `SAXParserFactory` is created without disabling DOCTYPE declarations.
|
|
44
|
+
A crafted DOCTYPE lets an attacker read arbitrary local files, reach
|
|
45
|
+
internal-only network endpoints (SSRF), or trigger a denial of service
|
|
46
|
+
via entity expansion (CWE-611). Call
|
|
47
|
+
`factory.setFeature("http://apache.org/xml/features/disallow-doctype-decl", true);`
|
|
48
|
+
on the factory before parsing.
|
|
49
|
+
severity: ERROR
|
|
50
|
+
languages: [java]
|
|
51
|
+
metadata:
|
|
52
|
+
category: security
|
|
53
|
+
cwe:
|
|
54
|
+
- "CWE-611: Improper Restriction of XML External Entity Reference"
|
|
55
|
+
owasp:
|
|
56
|
+
- "A05:2021 - Security Misconfiguration"
|
|
57
|
+
subcategory: [vuln]
|
|
58
|
+
likelihood: LOW
|
|
59
|
+
impact: HIGH
|
|
60
|
+
confidence: MEDIUM
|
|
61
|
+
technology: [java]
|
|
62
|
+
patterns:
|
|
63
|
+
- pattern: |
|
|
64
|
+
$SPF = SAXParserFactory.newInstance();
|
|
65
|
+
...
|
|
66
|
+
$SPF.newSAXParser();
|
|
67
|
+
- pattern-not: |
|
|
68
|
+
$SPF = SAXParserFactory.newInstance();
|
|
69
|
+
...
|
|
70
|
+
$SPF.setFeature("http://apache.org/xml/features/disallow-doctype-decl", true);
|
|
71
|
+
...
|
|
72
|
+
$SPF.newSAXParser();
|
|
73
|
+
|
|
74
|
+
- id: narvy.java.xxe.transformerfactory-dtds-not-disabled.transformerfactory-dtds-not-disabled
|
|
75
|
+
message: >-
|
|
76
|
+
A `TransformerFactory` (used for XSLT transforms) is created without
|
|
77
|
+
disabling access to external DTDs and stylesheets. An attacker-supplied
|
|
78
|
+
stylesheet or source document can then read local files or reach
|
|
79
|
+
internal network endpoints through an external entity or `document()`
|
|
80
|
+
call (CWE-611). Set `factory.setAttribute(XMLConstants.ACCESS_EXTERNAL_DTD, "");`
|
|
81
|
+
and `factory.setAttribute(XMLConstants.ACCESS_EXTERNAL_STYLESHEET, "");`.
|
|
82
|
+
severity: WARNING
|
|
83
|
+
languages: [java]
|
|
84
|
+
metadata:
|
|
85
|
+
category: security
|
|
86
|
+
cwe:
|
|
87
|
+
- "CWE-611: Improper Restriction of XML External Entity Reference"
|
|
88
|
+
owasp:
|
|
89
|
+
- "A05:2021 - Security Misconfiguration"
|
|
90
|
+
subcategory: [vuln]
|
|
91
|
+
likelihood: LOW
|
|
92
|
+
impact: MEDIUM
|
|
93
|
+
confidence: LOW
|
|
94
|
+
technology: [java]
|
|
95
|
+
patterns:
|
|
96
|
+
- pattern: |
|
|
97
|
+
$TF = TransformerFactory.newInstance();
|
|
98
|
+
...
|
|
99
|
+
$TF.newTransformer();
|
|
100
|
+
- pattern-not: |
|
|
101
|
+
$TF = TransformerFactory.newInstance();
|
|
102
|
+
...
|
|
103
|
+
$TF.setAttribute(XMLConstants.ACCESS_EXTERNAL_DTD, "...");
|
|
104
|
+
...
|
|
105
|
+
$TF.newTransformer();
|
|
106
|
+
|
|
107
|
+
- id: narvy.java.xxe.xmlinputfactory-disallow-doctype-decl-missing.xmlinputfactory-disallow-doctype-decl-missing
|
|
108
|
+
message: >-
|
|
109
|
+
An `XMLInputFactory` (StAX) is created without disabling DTD support or
|
|
110
|
+
external entity resolution. Reading an attacker-supplied document with
|
|
111
|
+
it can read local files, hit internal network endpoints (SSRF), or
|
|
112
|
+
trigger entity-expansion denial of service (CWE-611). Set
|
|
113
|
+
`factory.setProperty(XMLInputFactory.SUPPORT_DTD, false);` and
|
|
114
|
+
`factory.setProperty(XMLInputFactory.IS_SUPPORTING_EXTERNAL_ENTITIES, false);`.
|
|
115
|
+
severity: WARNING
|
|
116
|
+
languages: [java]
|
|
117
|
+
metadata:
|
|
118
|
+
category: security
|
|
119
|
+
cwe:
|
|
120
|
+
- "CWE-611: Improper Restriction of XML External Entity Reference"
|
|
121
|
+
owasp:
|
|
122
|
+
- "A05:2021 - Security Misconfiguration"
|
|
123
|
+
subcategory: [vuln]
|
|
124
|
+
likelihood: LOW
|
|
125
|
+
impact: HIGH
|
|
126
|
+
confidence: MEDIUM
|
|
127
|
+
technology: [java]
|
|
128
|
+
patterns:
|
|
129
|
+
- pattern: |
|
|
130
|
+
$XIF = XMLInputFactory.newInstance();
|
|
131
|
+
...
|
|
132
|
+
$XIF.createXMLStreamReader($SRC);
|
|
133
|
+
- pattern-not: |
|
|
134
|
+
$XIF = XMLInputFactory.newInstance();
|
|
135
|
+
...
|
|
136
|
+
$XIF.setProperty(XMLInputFactory.SUPPORT_DTD, false);
|
|
137
|
+
...
|
|
138
|
+
$XIF.createXMLStreamReader($SRC);
|
|
139
|
+
|
|
140
|
+
- id: narvy.java.xxe.documentbuilderfactory-external-entities-enabled.documentbuilderfactory-external-entities-enabled
|
|
141
|
+
message: >-
|
|
142
|
+
A `DocumentBuilderFactory` explicitly re-enables external general or
|
|
143
|
+
parameter entities (`load-external-dtd`,
|
|
144
|
+
`external-general-entities`, or `external-parameter-entities` set to
|
|
145
|
+
`true`). This defeats any DOCTYPE hardening done elsewhere on the same
|
|
146
|
+
factory and reopens the classic XXE file-read/SSRF path (CWE-611).
|
|
147
|
+
Remove the override, or set it to `false`.
|
|
148
|
+
severity: ERROR
|
|
149
|
+
languages: [java]
|
|
150
|
+
metadata:
|
|
151
|
+
category: security
|
|
152
|
+
cwe:
|
|
153
|
+
- "CWE-611: Improper Restriction of XML External Entity Reference"
|
|
154
|
+
owasp:
|
|
155
|
+
- "A05:2021 - Security Misconfiguration"
|
|
156
|
+
subcategory: [vuln]
|
|
157
|
+
likelihood: LOW
|
|
158
|
+
impact: HIGH
|
|
159
|
+
confidence: HIGH
|
|
160
|
+
technology: [java]
|
|
161
|
+
patterns:
|
|
162
|
+
- pattern-either:
|
|
163
|
+
- pattern: $DBF.setFeature("http://apache.org/xml/features/nonvalidating/load-external-dtd", true)
|
|
164
|
+
- pattern: $DBF.setFeature("http://xml.org/sax/features/external-general-entities", true)
|
|
165
|
+
- pattern: $DBF.setFeature("http://xml.org/sax/features/external-parameter-entities", true)
|
|
166
|
+
|
|
167
|
+
- id: narvy.java.xxe.xstream-unrestricted-fromxml.xstream-unrestricted-fromxml
|
|
168
|
+
message: >-
|
|
169
|
+
An `XStream` instance deserialises XML with `fromXML(...)` and no type
|
|
170
|
+
permission allow-list configured (`xstream.allowTypes(...)` /
|
|
171
|
+
`xstream.setupDefaultSecurity(...)`). Unrestricted XStream deserialises
|
|
172
|
+
arbitrary classes on the classpath, which is both an XXE vector and a
|
|
173
|
+
remote-code-execution gadget-chain vector (CWE-611, CWE-502). Call
|
|
174
|
+
`xstream.allowTypesByWildcard(...)` (or `addPermission`) with an
|
|
175
|
+
explicit allow-list before calling `fromXML`.
|
|
176
|
+
severity: ERROR
|
|
177
|
+
languages: [java]
|
|
178
|
+
metadata:
|
|
179
|
+
category: security
|
|
180
|
+
cwe:
|
|
181
|
+
- "CWE-611: Improper Restriction of XML External Entity Reference"
|
|
182
|
+
- "CWE-502: Deserialization of Untrusted Data"
|
|
183
|
+
owasp:
|
|
184
|
+
- "A08:2021 - Software and Data Integrity Failures"
|
|
185
|
+
subcategory: [vuln]
|
|
186
|
+
likelihood: LOW
|
|
187
|
+
impact: HIGH
|
|
188
|
+
confidence: LOW
|
|
189
|
+
technology: [java]
|
|
190
|
+
patterns:
|
|
191
|
+
- pattern: |
|
|
192
|
+
$XS = new XStream(...);
|
|
193
|
+
...
|
|
194
|
+
$XS.fromXML($SRC);
|
|
195
|
+
- pattern-not: |
|
|
196
|
+
$XS = new XStream(...);
|
|
197
|
+
...
|
|
198
|
+
$XS.allowTypes(...);
|
|
199
|
+
...
|
|
200
|
+
$XS.fromXML($SRC);
|
|
201
|
+
- pattern-not: |
|
|
202
|
+
$XS = new XStream(...);
|
|
203
|
+
...
|
|
204
|
+
$XS.allowTypesByWildcard(...);
|
|
205
|
+
...
|
|
206
|
+
$XS.fromXML($SRC);
|
|
207
|
+
- pattern-not: |
|
|
208
|
+
$XS = new XStream(...);
|
|
209
|
+
...
|
|
210
|
+
$XS.addPermission(...);
|
|
211
|
+
...
|
|
212
|
+
$XS.fromXML($SRC);
|