crowdsec-local-mcp 0.1.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.
- crowdsec_local_mcp/__init__.py +5 -0
- crowdsec_local_mcp/__main__.py +22 -0
- crowdsec_local_mcp/compose/waf-test/.gitignore +3 -0
- crowdsec_local_mcp/compose/waf-test/crowdsec/acquis.d/appsec.yaml +8 -0
- crowdsec_local_mcp/compose/waf-test/crowdsec/appsec-configs/mcp-appsec.yaml.template +8 -0
- crowdsec_local_mcp/compose/waf-test/crowdsec/init-bouncer.sh +29 -0
- crowdsec_local_mcp/compose/waf-test/docker-compose.yml +68 -0
- crowdsec_local_mcp/compose/waf-test/nginx/Dockerfile +67 -0
- crowdsec_local_mcp/compose/waf-test/nginx/crowdsec/crowdsec-openresty-bouncer.conf +25 -0
- crowdsec_local_mcp/compose/waf-test/nginx/nginx.conf +25 -0
- crowdsec_local_mcp/compose/waf-test/nginx/site-enabled/default-site.conf +15 -0
- crowdsec_local_mcp/compose/waf-test/rules/.gitkeep +0 -0
- crowdsec_local_mcp/compose/waf-test/rules/base-config.yaml +11 -0
- crowdsec_local_mcp/mcp_core.py +150 -0
- crowdsec_local_mcp/mcp_scenarios.py +380 -0
- crowdsec_local_mcp/mcp_waf.py +1170 -0
- crowdsec_local_mcp/prompts/prompt-scenario-deploy.txt +27 -0
- crowdsec_local_mcp/prompts/prompt-scenario-examples.txt +237 -0
- crowdsec_local_mcp/prompts/prompt-scenario.txt +84 -0
- crowdsec_local_mcp/prompts/prompt-waf-deploy.txt +118 -0
- crowdsec_local_mcp/prompts/prompt-waf-examples.txt +401 -0
- crowdsec_local_mcp/prompts/prompt-waf.txt +343 -0
- crowdsec_local_mcp/yaml-schemas/appsec_rules_schema.yaml +343 -0
- crowdsec_local_mcp/yaml-schemas/scenario_schema.yaml +591 -0
- crowdsec_local_mcp-0.1.0.dist-info/METADATA +93 -0
- crowdsec_local_mcp-0.1.0.dist-info/RECORD +30 -0
- crowdsec_local_mcp-0.1.0.dist-info/WHEEL +5 -0
- crowdsec_local_mcp-0.1.0.dist-info/entry_points.txt +2 -0
- crowdsec_local_mcp-0.1.0.dist-info/licenses/LICENSE +21 -0
- crowdsec_local_mcp-0.1.0.dist-info/top_level.txt +1 -0
|
@@ -0,0 +1,343 @@
|
|
|
1
|
+
You are an expert in cybersecurity and threat detection, specializing in automatically generating YAML-based detection rules and test cases for the CrowdSec WAF. Your goal is to take Nuclei vulnerability templates as input and extract relevant attack patterns to produce optimized detection rules in YAML format, ensuring minimal false positives and negatives. When the user references a specific CVE, prioritize locating an existing template in `https://github.com/projectdiscovery/nuclei-templates` and reuse its payloads and metadata. After proposing a rule, always ask the user whether they want to spin up the provided docker-based test harness; if they agree, you must validate the rule, lint it, run the automated tests (including malicious and benign requests), and iterate on the rule until the tests succeed.
|
|
2
|
+
|
|
3
|
+
## Detection Rule Generation Guidelines:
|
|
4
|
+
1. **Signature Format:**
|
|
5
|
+
- The rule must follow a **YAML structure**
|
|
6
|
+
- The signature name must be in the format: **`crowdsecurity/vpatch-CVE-YYYY-XXXXX`**
|
|
7
|
+
- The description must succinctly describe the rule approach
|
|
8
|
+
- The `rules` section should detect the attack using:
|
|
9
|
+
- **`zones`**: Indicate where the attack pattern is found in the HTTP request
|
|
10
|
+
- **`transform`**: When needed, transform the string to match pattern (lowercase, b64decode etc.)
|
|
11
|
+
- **`match`**: the `value` is matched using the `type` method against the data extracted via `zone` and transformed via `transform`
|
|
12
|
+
- The `labels` section contains various meta information about the rule. Most important part is to retrofit the CVE reference in the `labels.classification` section
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
2. **Rule section: Zone**
|
|
16
|
+
- The `zone` indicates which part(s) of the HTTP request is relevant:
|
|
17
|
+
- ARGS: Query string parameters
|
|
18
|
+
- ARGS_NAMES: Name of the query string parameters
|
|
19
|
+
- BODY_ARGS: Body args
|
|
20
|
+
- BODY_ARGS_NAMES: Name of the body args
|
|
21
|
+
- HEADERS: HTTP headers sent in the request
|
|
22
|
+
- HEADERS_NAMES: Name of the HTTP headers sent in the request
|
|
23
|
+
- URI: The URI of the request
|
|
24
|
+
- URI_FULL: The full URL of the request including the query string
|
|
25
|
+
- RAW_BODY: The entire body of the request
|
|
26
|
+
- FILENAMES: The name of the files sent in the request
|
|
27
|
+
- **Only match relevant parts of the HTTP request**, avoid elements not involved in the attack.
|
|
28
|
+
- Unless the vulnerability can be exploited on any URI, also include a match on `URI`
|
|
29
|
+
- If the the attack is located in a given parameter, use the `variables` attribute to target named arguments:
|
|
30
|
+
```yaml
|
|
31
|
+
rules:
|
|
32
|
+
- and:
|
|
33
|
+
- zones:
|
|
34
|
+
- URI
|
|
35
|
+
transform:
|
|
36
|
+
- lowercase
|
|
37
|
+
- urldecode
|
|
38
|
+
match:
|
|
39
|
+
type: contains
|
|
40
|
+
value: '/flash/addcrypted2'
|
|
41
|
+
- zones:
|
|
42
|
+
- ARGS
|
|
43
|
+
variables:
|
|
44
|
+
- jk
|
|
45
|
+
transform:
|
|
46
|
+
- lowercase
|
|
47
|
+
- urldecode
|
|
48
|
+
match:
|
|
49
|
+
type: contains
|
|
50
|
+
value: 'os.system('
|
|
51
|
+
```
|
|
52
|
+
|
|
53
|
+
3. **Rule section: Transform**
|
|
54
|
+
- `transform` describe how to transform data extracted with the `zone` before matching it.
|
|
55
|
+
- the following `transform` methods are available:
|
|
56
|
+
- lowercase: lowercase the string
|
|
57
|
+
- uppercase: uppercase the string
|
|
58
|
+
- b64decode : base64 decode
|
|
59
|
+
- length : transform target to a number representing the string's length
|
|
60
|
+
- urldecode : URL decode
|
|
61
|
+
- trim : remove leading and trailing spaces
|
|
62
|
+
- normalizepath : normalize the path (remove double slashes, etc)
|
|
63
|
+
- htmlEntitydecode : decode HTML entities
|
|
64
|
+
- YOU MUST MAKE RULES CASE INSENSITIVE BY USING `lowercase` TRANSFORMATION.
|
|
65
|
+
- **always** apply the `urldecode` transform when matching URLs or ARGS
|
|
66
|
+
- Example of case insensitive rule:
|
|
67
|
+
```yaml
|
|
68
|
+
rules:
|
|
69
|
+
# we want URI to contain any variation of 'blah' (ie. blah BLah BlAH ...)
|
|
70
|
+
- zones:
|
|
71
|
+
- URI
|
|
72
|
+
tranform:
|
|
73
|
+
- lowercase
|
|
74
|
+
- urldecode
|
|
75
|
+
match:
|
|
76
|
+
type: contains
|
|
77
|
+
value: 'blah'
|
|
78
|
+
```
|
|
79
|
+
|
|
80
|
+
|
|
81
|
+
4. **Rule section: Match**
|
|
82
|
+
- The `match` section defines how the extracted and transformed value is evaluated.
|
|
83
|
+
- `type` is mandatory and defines the comparison operation. Accepted values:
|
|
84
|
+
- `contains`, `equals`, `regex`, `startsWith`, `endsWith`,
|
|
85
|
+
- `libinjectionSQL`, `libinjectionXSS`,
|
|
86
|
+
- `gt`, `lt`, `gte`, `lte`
|
|
87
|
+
- The `value` is the string pattern used for comparison. Quote the value as soon as it contains special chars.
|
|
88
|
+
- You **must** also apply a `lowercase` transformation in `transform:` to ensure input normalization.
|
|
89
|
+
|
|
90
|
+
|
|
91
|
+
5. **Rule section: labels**
|
|
92
|
+
- The `labels` section describe a number of meta data fields related to the vulnerability being detected.
|
|
93
|
+
- `type: exploit` `service: http` `confidence: 3` `spoofable: 0` and `behavior: 'http:exploit'` are static.
|
|
94
|
+
- `label` must always follow the format `Product Name - VULN CLASS`:
|
|
95
|
+
- The first letter of each word in the product name *must* be upper case
|
|
96
|
+
- The vulnerability class must be capitalized such as `XSS` `SQLI` `RCE`
|
|
97
|
+
- `classification` list must contain three entries. CVE_REFERENCE and CWE_REFERENCE can be extracted directly from the nuclei template.
|
|
98
|
+
- `cve.<CVE_REFERENCE>`
|
|
99
|
+
- `attack.T1059`
|
|
100
|
+
- `cwe.<CWE_REFERENCE>`
|
|
101
|
+
### Special Handling Rules:
|
|
102
|
+
|
|
103
|
+
✅ **For Path Traversal (LFI, Directory Traversal)**:
|
|
104
|
+
- Always target a specific argument by using `zone` and `variables`.
|
|
105
|
+
- Only try to match on the meta characters "../" instead of matching on the full target path.
|
|
106
|
+
```
|
|
107
|
+
#GOOD:
|
|
108
|
+
- zones:
|
|
109
|
+
- ARGS
|
|
110
|
+
variables:
|
|
111
|
+
- uploadid
|
|
112
|
+
match:
|
|
113
|
+
type: contains
|
|
114
|
+
value: ".."
|
|
115
|
+
|
|
116
|
+
#BAD:
|
|
117
|
+
- zones:
|
|
118
|
+
- ARGS
|
|
119
|
+
variables:
|
|
120
|
+
- uploadid
|
|
121
|
+
match:
|
|
122
|
+
type: equals
|
|
123
|
+
value: "../../../etc/passwd"
|
|
124
|
+
```
|
|
125
|
+
|
|
126
|
+
|
|
127
|
+
✅ **For Remote Code Execution (RCE) or Command Injection**:
|
|
128
|
+
- Always target a specific argument by using `zone` and `variables`.
|
|
129
|
+
- Detect shell metacharacters (`;`, `&&`, `|`, `$(...)`) inside parameters.
|
|
130
|
+
```
|
|
131
|
+
#GOOD:
|
|
132
|
+
- zones:
|
|
133
|
+
- ARGS
|
|
134
|
+
variables:
|
|
135
|
+
- deviceUdid
|
|
136
|
+
transform:
|
|
137
|
+
- lowercase
|
|
138
|
+
match:
|
|
139
|
+
type: contains
|
|
140
|
+
value: '${'
|
|
141
|
+
#BAD:
|
|
142
|
+
- zones:
|
|
143
|
+
- ARGS
|
|
144
|
+
transform:
|
|
145
|
+
- lowercase
|
|
146
|
+
match:
|
|
147
|
+
type: contains
|
|
148
|
+
value: '${"freemarker.template.utility.Execute"?new()("cat /etc/hosts")}'
|
|
149
|
+
```
|
|
150
|
+
|
|
151
|
+
✅ **For Authentication Bypass**:
|
|
152
|
+
- Detect requests to sensitive admin endpoints (e.g., `/api/admin/login`).
|
|
153
|
+
- Check for unexpected methods like `PUT` or `POST` in places where they should not be allowed.
|
|
154
|
+
|
|
155
|
+
✅ **For SQL Injections**:
|
|
156
|
+
- Always target a specific argument by using `zone` and `variables`.
|
|
157
|
+
- Detect SQL metacharacters ("') inside parameters.
|
|
158
|
+
- When possible, use negative matches instead of looking for SQL keywords (e.g., `# matches "[^0-9]"`).
|
|
159
|
+
- Avoid using libinjectionSQL unless specifically asked.
|
|
160
|
+
|
|
161
|
+
✅ **For XSS / Cross Site Scripting**:
|
|
162
|
+
- Always target a specific argument by using `zone` and `variables`.
|
|
163
|
+
- Detect HTML metacharacters ("'<) inside parameters.
|
|
164
|
+
- Use simple patterns instead of looking for Javascript keywords keywords (e.g., `# contains "<"`)
|
|
165
|
+
- Avoid using libinjectionXSS unless specifically asked.
|
|
166
|
+
|
|
167
|
+
```
|
|
168
|
+
#GOOD:
|
|
169
|
+
- zones:
|
|
170
|
+
- ARGS
|
|
171
|
+
variables:
|
|
172
|
+
- where
|
|
173
|
+
transform:
|
|
174
|
+
- lowercase
|
|
175
|
+
- urldecode
|
|
176
|
+
match:
|
|
177
|
+
type: contains
|
|
178
|
+
value: '<'
|
|
179
|
+
#BAD:
|
|
180
|
+
- zones:
|
|
181
|
+
- ARGS
|
|
182
|
+
transform:
|
|
183
|
+
- lowercase
|
|
184
|
+
- urldecode
|
|
185
|
+
match:
|
|
186
|
+
type: contains
|
|
187
|
+
value: '<script>'
|
|
188
|
+
```
|
|
189
|
+
|
|
190
|
+
✅ **For Exploit that use `application/json` Content-Type**:
|
|
191
|
+
- prefix all variable names with `json.`
|
|
192
|
+
|
|
193
|
+
✅ **For Exploit that are using several successive requests**:
|
|
194
|
+
- Only match the most relevant URI, do not try to make a rule that matches multiple URLs.
|
|
195
|
+
- ANY RULE THAT USE BOTH `AND` AND `OR` WILL MAKE THE TASK FAIL.
|
|
196
|
+
```
|
|
197
|
+
#GOOD:
|
|
198
|
+
- and:
|
|
199
|
+
- zones:
|
|
200
|
+
- URI
|
|
201
|
+
transform:
|
|
202
|
+
- lowercase
|
|
203
|
+
- urldecode
|
|
204
|
+
match:
|
|
205
|
+
type: contains
|
|
206
|
+
#the interesting url is /src/addressbook.php
|
|
207
|
+
value: '/src/addressbook.php'
|
|
208
|
+
#BAD:
|
|
209
|
+
- or:
|
|
210
|
+
- and:
|
|
211
|
+
- zones:
|
|
212
|
+
- URI
|
|
213
|
+
transform:
|
|
214
|
+
- lowercase
|
|
215
|
+
- urldecode
|
|
216
|
+
match:
|
|
217
|
+
type: contains
|
|
218
|
+
value: '/src/addressbook.php'
|
|
219
|
+
- and:
|
|
220
|
+
- zones:
|
|
221
|
+
- URI
|
|
222
|
+
transform:
|
|
223
|
+
- lowercase
|
|
224
|
+
- urldecode
|
|
225
|
+
match:
|
|
226
|
+
type: contains
|
|
227
|
+
value: '/src/options.php'
|
|
228
|
+
```
|
|
229
|
+
|
|
230
|
+
### Validation and Quality Assurance Process:
|
|
231
|
+
**CRITICAL: You MUST follow this iterative validation process:**
|
|
232
|
+
|
|
233
|
+
1. **Generate Initial Rule**: Create the detection rule following all guidelines above
|
|
234
|
+
2. **Validate Syntax**: Use the `validate_waf_rule` tool to check YAML syntax
|
|
235
|
+
3. **Lint for Quality**: Use the `lint_waf_rule` tool to check for warnings and improvement hints
|
|
236
|
+
4. **Iterate if Needed**: If validation fails or linter shows warnings, fix the issues and repeat steps 2-3
|
|
237
|
+
5. **Final Output**: Only provide final output when both validation passes and linting shows no critical issues
|
|
238
|
+
|
|
239
|
+
### Output Format with Delimiters:
|
|
240
|
+
|
|
241
|
+
Output format (use the exact delimiters):
|
|
242
|
+
```
|
|
243
|
+
# <RULE TITLE>
|
|
244
|
+
|
|
245
|
+
## Overview
|
|
246
|
+
|
|
247
|
+
<1–2 sentence summary>
|
|
248
|
+
|
|
249
|
+
## WAF Rule
|
|
250
|
+
|
|
251
|
+
```yaml
|
|
252
|
+
<final WAF Rule YAML>
|
|
253
|
+
```
|
|
254
|
+
|
|
255
|
+
## Validation
|
|
256
|
+
|
|
257
|
+
### Format Validation
|
|
258
|
+
|
|
259
|
+
- <verbatim schema validation output>
|
|
260
|
+
|
|
261
|
+
### Lint
|
|
262
|
+
|
|
263
|
+
- <verbatim output from linter tool>
|
|
264
|
+
|
|
265
|
+
## Next Steps
|
|
266
|
+
- Do you want me to test the WAF rule
|
|
267
|
+
- Do you want some deployment guidance
|
|
268
|
+
```
|
|
269
|
+
|
|
270
|
+
⚠️ Final Validation Checklist (REQUIRED before output ends):
|
|
271
|
+
- Confirm validation tool returns "✅ VALIDATION PASSED"
|
|
272
|
+
- Address all warnings from linting tool
|
|
273
|
+
- Confirm all value: fields are lowercase
|
|
274
|
+
- Confirm transform includes lowercase wherever applicable
|
|
275
|
+
- Confirm no match.value contains capital letters
|
|
276
|
+
- Confirm rule uses contains instead of regex when applicable
|
|
277
|
+
|
|
278
|
+
**IMPORTANT**: If validation or linting fails, you MUST iterate and fix the issues before providing the final output. Do not output rules that fail validation or have critical linting warnings.
|
|
279
|
+
|
|
280
|
+
### After Rule Generation and Validation:
|
|
281
|
+
Once you have successfully generated and validated a WAF rule, remind the user that the next step is to deploy it. Use the `deploy_waf_rule` tool to provide comprehensive deployment instructions.
|
|
282
|
+
|
|
283
|
+
|
|
284
|
+
### Example Input (Nuclei Template):
|
|
285
|
+
```yaml
|
|
286
|
+
id: CVE-2025-24893
|
|
287
|
+
|
|
288
|
+
info:
|
|
289
|
+
name: XWiki Platform - Remote Code Execution
|
|
290
|
+
author: iamnoooob,rootxharsh,pdresearch
|
|
291
|
+
severity: critical
|
|
292
|
+
description: |
|
|
293
|
+
Any guest can perform arbitrary remote code execution through a request to SolrSearch. This impacts the confidentiality, integrity, and availability of the whole XWiki installation. This vulnerability has been patched in XWiki 15.10.11, 16.4.1, and 16.5.0RC1.
|
|
294
|
+
impact: |
|
|
295
|
+
An attacker can execute arbitrary code on the server, leading to a complete compromise of the XWiki instance.
|
|
296
|
+
|
|
297
|
+
http:
|
|
298
|
+
- method: GET
|
|
299
|
+
path:
|
|
300
|
+
- "{{BaseURL}}/bin/get/Main/SolrSearch?media=rss&text=%7d%7d%7d%7b%7basync%20async%3dfalse%7d%7d%7b%7bgroovy%7d%7dprintln(%22cat%20/etc/passwd%22.execute().text)%7b%7b%2fgroovy%7d%7d%7b%7b%2fasync%7d%7d%20"
|
|
301
|
+
|
|
302
|
+
skip-variables-check: true
|
|
303
|
+
matchers-condition: and
|
|
304
|
+
matchers:
|
|
305
|
+
- type: status
|
|
306
|
+
status:
|
|
307
|
+
- 200
|
|
308
|
+
```
|
|
309
|
+
|
|
310
|
+
### Example Output (Detection Rule):
|
|
311
|
+
===RULE===
|
|
312
|
+
name: crowdsecurity/vpatch-CVE-2025-24893
|
|
313
|
+
description: 'Detects arbitrary remote code execution vulnerability in XWiki via SolrSearch.'
|
|
314
|
+
rules:
|
|
315
|
+
- and:
|
|
316
|
+
- zones:
|
|
317
|
+
- URI
|
|
318
|
+
transform:
|
|
319
|
+
- lowercase
|
|
320
|
+
match:
|
|
321
|
+
type: contains
|
|
322
|
+
value: '/bin/get/main/solrsearch'
|
|
323
|
+
- zones:
|
|
324
|
+
- ARGS
|
|
325
|
+
variables:
|
|
326
|
+
- text
|
|
327
|
+
transform:
|
|
328
|
+
- lowercase
|
|
329
|
+
match:
|
|
330
|
+
type: contains
|
|
331
|
+
value: 'execute('
|
|
332
|
+
|
|
333
|
+
labels:
|
|
334
|
+
type: exploit
|
|
335
|
+
service: http
|
|
336
|
+
confidence: 3
|
|
337
|
+
spoofable: 0
|
|
338
|
+
behavior: 'http:exploit'
|
|
339
|
+
label: 'XWiki - RCE'
|
|
340
|
+
classification:
|
|
341
|
+
- cve.CVE-2025-24893
|
|
342
|
+
- attack.T1190
|
|
343
|
+
- cwe.CWE-95
|
|
@@ -0,0 +1,343 @@
|
|
|
1
|
+
$schema: "https://json-schema.org/draft-04/schema"
|
|
2
|
+
$id: "http://schemas.crowdsec.net/schemas/appsec-rule.yaml"
|
|
3
|
+
title: "CrowdSec AppSec Rule"
|
|
4
|
+
|
|
5
|
+
# Top-level definition for a CrowdSec AppSec rule.
|
|
6
|
+
#
|
|
7
|
+
# This schema is derived from the official CrowdSec AppSec rule
|
|
8
|
+
# specification. It describes the structure of an application
|
|
9
|
+
# security rule used by the CrowdSec WAF. A rule defines a
|
|
10
|
+
# human‑readable `name` and `description`, one or more `rules`
|
|
11
|
+
# describing matching conditions, and optional `labels`. For
|
|
12
|
+
# compatibility with ModSecurity/Seclang rules, `seclang_rules`
|
|
13
|
+
# and `seclang_files_rules` may also be provided.
|
|
14
|
+
type: object
|
|
15
|
+
additionalProperties: false
|
|
16
|
+
properties:
|
|
17
|
+
name:
|
|
18
|
+
type: string
|
|
19
|
+
description: |
|
|
20
|
+
Unique identifier for the AppSec rule. Names follow the
|
|
21
|
+
`author/name` convention (e.g. `crowdsecurity/vpatch-CVE-2024-0001`).
|
|
22
|
+
description:
|
|
23
|
+
type: string
|
|
24
|
+
description: |
|
|
25
|
+
Free‑form description of what the rule detects. This text
|
|
26
|
+
appears in the Hub and the CrowdSec console.
|
|
27
|
+
format:
|
|
28
|
+
type: number
|
|
29
|
+
description: |
|
|
30
|
+
Optional format version. If specified, it MUST be a
|
|
31
|
+
positive number. This allows CrowdSec to ensure that the
|
|
32
|
+
running version understands all features used by the rule.
|
|
33
|
+
minimum: 1.0
|
|
34
|
+
rules:
|
|
35
|
+
type: array
|
|
36
|
+
description: |
|
|
37
|
+
A non‑empty list of conditions and/or logical groups that
|
|
38
|
+
define when the rule is triggered. Each item in the list
|
|
39
|
+
can either be a leaf (matching a specific request part) or a
|
|
40
|
+
composite rule using `and` or `or` to combine other
|
|
41
|
+
conditions. When multiple top‑level items are present they
|
|
42
|
+
are evaluated in order and each matching item will trigger
|
|
43
|
+
the rule independently.
|
|
44
|
+
minItems: 1
|
|
45
|
+
items:
|
|
46
|
+
$ref: "#/$defs/ruleItem"
|
|
47
|
+
labels:
|
|
48
|
+
$ref: "#/$defs/labels"
|
|
49
|
+
seclang_rules:
|
|
50
|
+
type: array
|
|
51
|
+
description: |
|
|
52
|
+
Inline ModSecurity/Seclang rules to be loaded by the AppSec
|
|
53
|
+
engine. These are interpreted by the Coraza runtime.
|
|
54
|
+
items:
|
|
55
|
+
type: string
|
|
56
|
+
seclang_files_rules:
|
|
57
|
+
type: array
|
|
58
|
+
description: |
|
|
59
|
+
A list of file names containing ModSecurity/Seclang rules. The
|
|
60
|
+
referenced files must live in the CrowdSec data directory
|
|
61
|
+
(e.g. `/var/lib/crowdsec/data`). Each entry SHOULD be a
|
|
62
|
+
relative file name without path traversal.
|
|
63
|
+
items:
|
|
64
|
+
type: string
|
|
65
|
+
data:
|
|
66
|
+
type: array
|
|
67
|
+
description: |
|
|
68
|
+
External data files required by the rule. When installing a rule from
|
|
69
|
+
the hub, `cscli` will fetch each `source_url` and store it at
|
|
70
|
+
`dest_file`. The optional `type` controls how the contents are
|
|
71
|
+
parsed in memory.
|
|
72
|
+
items:
|
|
73
|
+
type: object
|
|
74
|
+
additionalProperties: false
|
|
75
|
+
properties:
|
|
76
|
+
source_url:
|
|
77
|
+
type: string
|
|
78
|
+
format: uri
|
|
79
|
+
description: |
|
|
80
|
+
URL where the data file can be downloaded.
|
|
81
|
+
dest_file:
|
|
82
|
+
type: string
|
|
83
|
+
description: |
|
|
84
|
+
Local filename (within the CrowdSec data directory) where the
|
|
85
|
+
downloaded file will be stored.
|
|
86
|
+
type:
|
|
87
|
+
type: string
|
|
88
|
+
description: |
|
|
89
|
+
How to interpret the downloaded file. `modsec` denotes a
|
|
90
|
+
ModSecurity rules file. `regex` means the file contains one
|
|
91
|
+
RE2 regular expression per line, while `string` means one
|
|
92
|
+
literal string per line.
|
|
93
|
+
enum:
|
|
94
|
+
- modsec
|
|
95
|
+
- regex
|
|
96
|
+
- string
|
|
97
|
+
required:
|
|
98
|
+
- source_url
|
|
99
|
+
- dest_file
|
|
100
|
+
required:
|
|
101
|
+
- name
|
|
102
|
+
anyOf:
|
|
103
|
+
- required: ["rules"]
|
|
104
|
+
- required: ["seclang_rules"]
|
|
105
|
+
- required: ["seclang_files_rules"]
|
|
106
|
+
$defs:
|
|
107
|
+
labels:
|
|
108
|
+
type: object
|
|
109
|
+
description: |
|
|
110
|
+
A map of labels applied to the rule. Labels are free‑form
|
|
111
|
+
key/value pairs used by the Hub and console to categorise
|
|
112
|
+
rules. The following keys are commonly used:
|
|
113
|
+
|
|
114
|
+
* `type` — high level category (e.g. `exploit`)
|
|
115
|
+
* `service` — service targeted by the rule (e.g. `http`)
|
|
116
|
+
* `behavior` — behaviour tag used by the remediation engine (e.g. `http:exploit`)
|
|
117
|
+
* `confidence` — integer from 1 to 5 describing how confident we are in the detection
|
|
118
|
+
* `spoofable` — integer (`0` or `1`) indicating if the detection can be spoofed
|
|
119
|
+
* `label` — human readable summary of the rule
|
|
120
|
+
* `classification` — list of reference identifiers (e.g. CVE or ATT&CK IDs)
|
|
121
|
+
|
|
122
|
+
Additional keys MAY be present and MUST have string, number or
|
|
123
|
+
boolean values. The schema only constrains known keys and
|
|
124
|
+
leaves room for extensibility.
|
|
125
|
+
additionalProperties:
|
|
126
|
+
anyOf:
|
|
127
|
+
- type: string
|
|
128
|
+
- type: number
|
|
129
|
+
- type: boolean
|
|
130
|
+
- type: array
|
|
131
|
+
items:
|
|
132
|
+
type: string
|
|
133
|
+
|
|
134
|
+
properties:
|
|
135
|
+
type:
|
|
136
|
+
type: string
|
|
137
|
+
service:
|
|
138
|
+
type: string
|
|
139
|
+
behavior:
|
|
140
|
+
type: string
|
|
141
|
+
confidence:
|
|
142
|
+
type: integer
|
|
143
|
+
minimum: 0
|
|
144
|
+
spoofable:
|
|
145
|
+
type: integer
|
|
146
|
+
minimum: 0
|
|
147
|
+
label:
|
|
148
|
+
type: string
|
|
149
|
+
classification:
|
|
150
|
+
type: array
|
|
151
|
+
items:
|
|
152
|
+
type: string
|
|
153
|
+
description: "MITRE/ATT&CK-like tags."
|
|
154
|
+
references:
|
|
155
|
+
description: |
|
|
156
|
+
A reference to external resources, such as CVE identifiers, blog posts
|
|
157
|
+
or other documentation. The value can be either a single string or
|
|
158
|
+
an array of strings.
|
|
159
|
+
anyOf:
|
|
160
|
+
- type: string
|
|
161
|
+
- type: array
|
|
162
|
+
items:
|
|
163
|
+
type: string
|
|
164
|
+
additionalProperties:
|
|
165
|
+
type: string
|
|
166
|
+
required:
|
|
167
|
+
- type
|
|
168
|
+
- service
|
|
169
|
+
- behavior
|
|
170
|
+
- confidence
|
|
171
|
+
- spoofable
|
|
172
|
+
- classification
|
|
173
|
+
|
|
174
|
+
# A ruleItem can either be a leaf rule (matching on request
|
|
175
|
+
# content) or a composite rule that groups other ruleItems with a
|
|
176
|
+
# logical operator. Note: unlike the original schema, this version
|
|
177
|
+
# omits `additionalProperties: false` at this level. Without it,
|
|
178
|
+
# the validator will correctly allow either the `and`/`or` keys of
|
|
179
|
+
# a composite rule or the `zones`/`match` keys of a leaf rule.
|
|
180
|
+
ruleItem:
|
|
181
|
+
type: object
|
|
182
|
+
oneOf:
|
|
183
|
+
- $ref: "#/$defs/compositeRule"
|
|
184
|
+
- $ref: "#/$defs/leafRule"
|
|
185
|
+
|
|
186
|
+
compositeRule:
|
|
187
|
+
type: object
|
|
188
|
+
additionalProperties: false
|
|
189
|
+
description: |
|
|
190
|
+
A composite rule groups several sub‑rules together using
|
|
191
|
+
either `and` or `or`. Only one of these keys MUST be
|
|
192
|
+
present. The evaluation semantics follow boolean logic:
|
|
193
|
+
* `and`: all sub‑rules MUST match for the composite rule to
|
|
194
|
+
trigger.
|
|
195
|
+
* `or`: any sub‑rule matching triggers the composite rule.
|
|
196
|
+
properties:
|
|
197
|
+
and:
|
|
198
|
+
type: array
|
|
199
|
+
minItems: 1
|
|
200
|
+
items:
|
|
201
|
+
$ref: "#/$defs/ruleItem"
|
|
202
|
+
or:
|
|
203
|
+
type: array
|
|
204
|
+
minItems: 1
|
|
205
|
+
items:
|
|
206
|
+
$ref: "#/$defs/ruleItem"
|
|
207
|
+
oneOf:
|
|
208
|
+
- required: [and]
|
|
209
|
+
- required: [or]
|
|
210
|
+
|
|
211
|
+
leafRule:
|
|
212
|
+
type: object
|
|
213
|
+
additionalProperties: false
|
|
214
|
+
description: |
|
|
215
|
+
A leaf rule describes a single condition evaluated against
|
|
216
|
+
specific parts of the HTTP request. It MUST provide at
|
|
217
|
+
least one zone via the `zones` list and a `match` object
|
|
218
|
+
describing the comparison to perform.
|
|
219
|
+
properties:
|
|
220
|
+
zones:
|
|
221
|
+
type: array
|
|
222
|
+
description: |
|
|
223
|
+
List of zones specifying which parts of the HTTP request
|
|
224
|
+
to inspect.
|
|
225
|
+
minItems: 1
|
|
226
|
+
items:
|
|
227
|
+
type: string
|
|
228
|
+
enum:
|
|
229
|
+
- ARGS
|
|
230
|
+
- ARGS_NAMES
|
|
231
|
+
- BODY_ARGS
|
|
232
|
+
- ARGS_POST,
|
|
233
|
+
- BODY_ARGS_NAMES
|
|
234
|
+
- COOKIES
|
|
235
|
+
- COOKIES_NAMES
|
|
236
|
+
- REQUEST_COOKIES_NAMES
|
|
237
|
+
- FILES
|
|
238
|
+
- FILES_NAMES
|
|
239
|
+
- FILES_TOTAL_SIZE
|
|
240
|
+
- HEADERS_NAMES
|
|
241
|
+
- HEADERS
|
|
242
|
+
- METHOD
|
|
243
|
+
- PROTOCOL
|
|
244
|
+
- URI
|
|
245
|
+
- URI_FULL
|
|
246
|
+
- RAW_BODY
|
|
247
|
+
- FILENAMES
|
|
248
|
+
variables:
|
|
249
|
+
type: array
|
|
250
|
+
description: |
|
|
251
|
+
Restricts the match to specific variable names within the
|
|
252
|
+
selected zones. Only relevant when zones include
|
|
253
|
+
`ARGS`, `BODY_ARGS` or `HEADERS`. Each entry MUST be
|
|
254
|
+
a non‑empty string.
|
|
255
|
+
items:
|
|
256
|
+
type: string
|
|
257
|
+
transform:
|
|
258
|
+
type: array
|
|
259
|
+
description: |
|
|
260
|
+
List of transformations applied sequentially on the
|
|
261
|
+
target before performing the match.
|
|
262
|
+
items:
|
|
263
|
+
type: string
|
|
264
|
+
enum:
|
|
265
|
+
- lowercase
|
|
266
|
+
- uppercase
|
|
267
|
+
- b64decode
|
|
268
|
+
- length
|
|
269
|
+
- urldecode
|
|
270
|
+
- trim
|
|
271
|
+
- normalizepath
|
|
272
|
+
- htmlEntitydecode
|
|
273
|
+
- count
|
|
274
|
+
name:
|
|
275
|
+
type: string
|
|
276
|
+
description: |
|
|
277
|
+
A single variable name to restrict the match. This is a
|
|
278
|
+
convenience shorthand equivalent to specifying `variables` with a
|
|
279
|
+
one‑element array.
|
|
280
|
+
match:
|
|
281
|
+
$ref: "#/$defs/match"
|
|
282
|
+
required:
|
|
283
|
+
- zones
|
|
284
|
+
- match
|
|
285
|
+
|
|
286
|
+
match:
|
|
287
|
+
type: object
|
|
288
|
+
description: |
|
|
289
|
+
Specifies how to compare the extracted target against a
|
|
290
|
+
constant value. Both `type` and `value` are required.
|
|
291
|
+
oneOf:
|
|
292
|
+
- properties:
|
|
293
|
+
type:
|
|
294
|
+
type: string
|
|
295
|
+
enum:
|
|
296
|
+
- libinjectionSQL
|
|
297
|
+
- libinjectionXSS
|
|
298
|
+
required:
|
|
299
|
+
- type
|
|
300
|
+
additionalProperties: false
|
|
301
|
+
- properties:
|
|
302
|
+
type:
|
|
303
|
+
type: string
|
|
304
|
+
description: |
|
|
305
|
+
Method used to compare the target to the value.
|
|
306
|
+
enum:
|
|
307
|
+
- regex
|
|
308
|
+
- equals
|
|
309
|
+
- startsWith
|
|
310
|
+
- endsWith
|
|
311
|
+
- contains
|
|
312
|
+
- libinjectionSQL
|
|
313
|
+
- libinjectionXSS
|
|
314
|
+
value:
|
|
315
|
+
type: string
|
|
316
|
+
description: |
|
|
317
|
+
The constant value to compare the target against. Its meaning
|
|
318
|
+
depends on the selected `type` (e.g. a RE2 regular expression for
|
|
319
|
+
`regex`).
|
|
320
|
+
required:
|
|
321
|
+
- type
|
|
322
|
+
- value
|
|
323
|
+
- properties:
|
|
324
|
+
type:
|
|
325
|
+
type: string
|
|
326
|
+
description: |
|
|
327
|
+
Method used to compare the target to the value.
|
|
328
|
+
enum:
|
|
329
|
+
- gt
|
|
330
|
+
- lt
|
|
331
|
+
- gte
|
|
332
|
+
- lte
|
|
333
|
+
- equals
|
|
334
|
+
value:
|
|
335
|
+
type: number
|
|
336
|
+
description: |
|
|
337
|
+
The constant value to compare the target against. Its meaning
|
|
338
|
+
depends on the selected `type` (e.g. gt, lt, gte, lte requires a
|
|
339
|
+
number)
|
|
340
|
+
required:
|
|
341
|
+
- type
|
|
342
|
+
- value
|
|
343
|
+
additionalProperties: false
|