Skip to content

Commit ff17aaa

Browse files
committed
updated CRS + vpatch docs
1 parent 8a6f89d commit ff17aaa

File tree

2 files changed

+47
-66
lines changed

2 files changed

+47
-66
lines changed

crowdsec-docs/docs/appsec/advanced_deployments.md renamed to crowdsec-docs/docs/appsec/advanced_deployments.mdx

Lines changed: 47 additions & 66 deletions
Original file line numberDiff line numberDiff line change
@@ -37,22 +37,22 @@ CrowdSec WAF supports multiple deployment strategies that can be implemented pro
3737

3838
### 1. Basic Virtual Patching (Quickstart)
3939
**Current State**: Blocking protection against known CVEs
40-
- Collections: `crowdsecurity/appsec-virtual-patching`
40+
- Collections: [`crowdsecurity/appsec-virtual-patching`](https://app.crowdsec.net/hub/author/crowdsecurity/collections/appsec-virtual-patching)
4141
- Mode: In-band (blocking)
4242
- Coverage: Known vulnerabilities only
4343
- False Positives: Minimal
4444

4545
### 2. Enhanced Detection (Out-of-band CRS)
4646
**Next Step**: Add comprehensive attack detection without performance impact
47-
- Add: `crowdsecurity/appsec-crs` (out-of-band) alongside existing virtual patching
47+
- Add: [`crowdsecurity/appsec-crs-inband`](https://app.crowdsec.net/hub/author/crowdsecurity/collections/appsec-crs-inband) (out-of-band) alongside existing virtual patching
4848
- Mode: Non-blocking analysis + behavioral banning
4949
- Coverage: OWASP Top 10 + comprehensive attack patterns + specific CVE protection
5050
- Performance: No latency impact ⚡
5151
- Security: Layered approach - virtual patching + generic attack detection
5252

5353
### 3. Maximum Protection (In-band CRS)
5454
**Advanced**: Full blocking protection with comprehensive coverage
55-
- Modify: Configure CRS for in-band (blocking) mode while keeping virtual patching
55+
- Modify: Use [`crowdsecurity/appsec-crs-inband`](https://app.crowdsec.net/hub/author/crowdsecurity/collections/appsec-crs-inband) for blocking CRS while keeping virtual patching
5656
- Mode: Immediate blocking of all detected attacks (both generic and CVE-specific)
5757
- Coverage: Maximum protection with instant response 🛡️
5858
- Security: Dual-layer blocking - virtual patching handles specific vulnerabilities, CRS covers generic attack patterns
@@ -68,15 +68,15 @@ Enhance your existing virtual patching deployment by adding comprehensive attack
6868
sudo cscli collections install crowdsecurity/appsec-crs
6969
```
7070

71-
The `crowdsecurity/appsec-crs` collection includes:
71+
The [`crowdsecurity/appsec-crs`](https://app.crowdsec.net/hub/author/crowdsecurity/collections/appsec-crs) collection includes:
7272
- **crowdsecurity/crs**: AppSec config that loads CRS rules in out-of-band mode
7373
- **crowdsecurity/crowdsec-appsec-outofband**: Scenario that bans IPs after 5+ out-of-band rule violations
7474

7575
Update your WAF acquisition configuration to include both rule sets:
7676

7777
```yaml title="/etc/crowdsec/acquis.d/appsec.yaml"
7878
appsec_configs:
79-
- crowdsecurity/virtual-patching # Virtual patching rules (in-band blocking)
79+
- crowdsecurity/appsec-default # Virtual patching rules (in-band blocking)
8080
- crowdsecurity/crs # OWASP CRS rules (out-of-band detection)
8181
labels:
8282
type: appsec
@@ -114,74 +114,71 @@ Expected result: These requests should be immediately blocked with HTTP 403 Forb
114114

115115
**Test 2: CRS Out-of-band Detection Layer**
116116

117-
The `crowdsecurity/crowdsec-appsec-outofband` scenario monitors for multiple attack attempts and bans IPs after 5+ out-of-band rule violations within the configured timeframe. Test with various attack patterns:
117+
The `crowdsecurity/crs` collection brings general detection for OWASP top10 attacks, which can be tested:
118118

119119
```bash
120120
# Replace with your application URL
121121
TARGET="http://your-app.com"
122122

123123
# SQL injection attempts (trigger multiple CRS rules)
124124
curl "$TARGET/?id=1'+OR+'1'='1"
125-
curl "$TARGET/?id=1+UNION+SELECT+*+FROM+users"
126-
curl "$TARGET/?search='+OR+1=1--"
127-
curl "$TARGET/?filter=admin'/**/OR/**/'1'='1"
128-
129-
# XSS attempts
130-
curl "$TARGET/?q=<script>alert('xss')</script>"
131-
curl "$TARGET/?comment=<img src=x onerror=alert(1)>"
125+
```
132126

133-
# Command injection attempts
134-
curl "$TARGET/?cmd=; cat /etc/passwd"
135-
curl "$TARGET/?exec=|whoami"
127+
Expected results:
136128

137-
# Additional malicious patterns to reach the 5+ threshold
138-
curl "$TARGET/?test=../../../etc/passwd"
139-
curl "$TARGET/?file=....//....//etc/hosts"
129+
- Detailed Alert is created (see `cscli alerts list`)
140130

141-
# Wait 10-15 seconds for the scenario to process and ban the IP
142-
sleep 15
131+
<details>
132+
<summary>`cscli alerts list` output</summary>
143133

144-
# Test if IP is now banned
145-
curl "$TARGET/" # This should now be blocked
134+
```yaml
135+
+-------+--------------------+--------------------------------------------------------------+---------+------------------------------+-----------+----------------------+
136+
| ID | value | reason | country | as | decisions | created_at |
137+
+-------+--------------------+--------------------------------------------------------------+---------+------------------------------+-----------+----------------------+
138+
| 62419 | Ip:xxx.xx.xx.xx | anomaly score out-of-band: sql_injection: 10, anomaly: 10, | FR | 5410 Bouygues Telecom SA | | 2025-09-09T14:41:07Z |
139+
...
146140
```
141+
</details>
147142

148-
**Expected behavior:**
149-
1. **First 1-4 requests**: Pass through to your application (out-of-band mode)
150-
2. **After 5+ violations**: CrowdSec processes the violations (may take up to 10 seconds)
151-
3. **After ~10 seconds**: IP gets banned by the `crowdsec-appsec-outofband` scenario
152-
4. **Subsequent requests**: Blocked at CrowdSec level before reaching your application
153143

154-
:::info Processing Delay
155-
The out-of-band scenario processes violations asynchronously, so there's typically a 5-10 second delay between reaching the violation threshold and the IP ban taking effect. This is normal behavior for out-of-band detection.
156-
:::
144+
- Detailed Alert is visible in console
157145

158-
**Test 3: Verify Out-of-band Alerts (Optional)**
146+
<details>
147+
<summary>Alert Console view</summary>
148+
![timeline](/img/console-appsec-oob.png)
149+
</details>
159150

160-
To see individual out-of-band rule triggers (not just the ban), add a dedicated appsec config:
151+
**Test 3: Verify Scenario Behavior**
161152

162-
```yaml title="Add to /etc/crowdsec/acquis.d/appsec.yaml for detailed alerts"
163-
appsec_configs:
164-
- crowdsecurity/virtual-patching # Virtual patching rules (in-band blocking)
165-
- crowdsecurity/crs # OWASP CRS rules (out-of-band detection)
166-
- crowdsecurity/crs-alert # Generate alert for each CRS rule triggered
153+
The `crowdsecurity/crowdsec-appsec-outofband` scenario will ban IPs triggering the CRS on more than 5 distinct requests on a short period, which can be tested:
154+
155+
```bash
156+
for i in {1..6}; do curl "$TARGET/?id=1'+OR+'1'='1"; done
167157
```
168158

169-
This will create individual alerts for each out-of-band rule violation, providing better visibility into attack patterns.
170159

171-
**Verification Commands:**
160+
Expected results:
172161

173-
```bash
174-
# Check for active bans
175-
sudo cscli decisions list
162+
- Alerts are created for each request
163+
- Decision is created by the 6th request
176164

177-
# Review recent alerts (including out-of-band detections)
178-
sudo cscli alerts list --limit 10
165+
<details>
166+
<summary>`cscli alerts list` output</summary>
179167

180-
# Monitor real-time activity
181-
sudo tail -f /var/log/crowdsec.log
182-
```
168+
```yaml
169+
───────┬────────────────────┬──────────────────────────────────────────────────────────────┬─────────┬──────────────────────────────┬───────────┬──────────────────────╮
170+
│ ID │ value │ reason │ country │ as │ decisions │ created_at │
171+
├───────┼────────────────────┼──────────────────────────────────────────────────────────────┼─────────┼──────────────────────────────┼───────────┼──────────────────────┤
172+
│ 62427 │ Ip:xxx.xx.xx.xx │ crowdsecurity/crowdsec-appsec-outofband │ FR │ 5410 Bouygues Telecom SA │ ban:1 │ 2025-09-09T14:51:11Z │
173+
│ 62426 │ Ip:xxx.xx.xx.xx │ anomaly score out-of-band: sql_injection: 10, anomaly: 10, │ FR │ 5410 Bouygues Telecom SA │ │ 2025-09-09T14:51:12Z │
174+
│ 62425 │ Ip:xxx.xx.xx.xx │ anomaly score out-of-band: sql_injection: 10, anomaly: 10, │ FR │ 5410 Bouygues Telecom SA │ │ 2025-09-09T14:51:11Z │
175+
│ 62424 │ Ip:xxx.xx.xx.xx │ anomaly score out-of-band: sql_injection: 10, anomaly: 10, │ FR │ 5410 Bouygues Telecom SA │ │ 2025-09-09T14:51:11Z │
176+
│ 62423 │ Ip:xxx.xx.xx.xx │ anomaly score out-of-band: sql_injection: 10, anomaly: 10, │ FR │ 5410 Bouygues Telecom SA │ │ 2025-09-09T14:51:11Z │
177+
│ 62422 │ Ip:xxx.xx.xx.xx │ anomaly score out-of-band: sql_injection: 10, anomaly: 10, │ FR │ 5410 Bouygues Telecom SA │ │ 2025-09-09T14:51:11Z │
178+
│ 62421 │ Ip:xxx.xx.xx.xx │ anomaly score out-of-band: sql_injection: 10, anomaly: 10, │ FR │ 5410 Bouygues Telecom SA │ │ 2025-09-09T14:51:11Z │
183179

184-
<!-- ![Screenshot placeholder: CrowdSec Console showing out-of-band detection alerts and IP bans](placeholder-outofband-alerts.png) -->
180+
```
181+
</details>
185182
186183
### Step 3: CRS In-band (Blocking Mode)
187184
@@ -197,7 +194,7 @@ Modify your acquisition to use the in-band CRS configuration:
197194

198195
```yaml title="/etc/crowdsec/acquis.d/appsec.yaml"
199196
appsec_configs:
200-
- crowdsecurity/virtual-patching # Virtual patching rules (in-band blocking)
197+
- crowdsecurity/appsec-default # Virtual patching rules (in-band blocking)
201198
- crowdsecurity/crs-inband # OWASP CRS rules (in-band blocking)
202199
labels:
203200
type: appsec
@@ -221,7 +218,6 @@ Verify virtual patching continues to work:
221218
```bash
222219
# These should still be immediately blocked
223220
curl -v "http://your-app.com/.env"
224-
curl -v "http://your-app.com/.git/config"
225221
```
226222

227223
Expected result: HTTP 403 Forbidden immediately.
@@ -251,21 +247,6 @@ curl -v "$TARGET/?file=../../../etc/passwd"
251247
- **No delay**: Unlike out-of-band mode, blocking is instant
252248
- **Dual protection**: Both virtual patching AND CRS rules provide immediate blocking
253249

254-
**Verification Commands:**
255-
256-
```bash
257-
# Check for immediate decisions (should see blocks right after requests)
258-
sudo cscli decisions list
259-
260-
# Review alerts (should see both virtual patching and CRS alerts)
261-
sudo cscli alerts list --limit 5
262-
263-
# Monitor real-time blocking
264-
sudo tail -f /var/log/crowdsec.log
265-
```
266-
267-
<!-- ![Screenshot placeholder: CrowdSec Console showing immediate in-band CRS blocks](placeholder-inband-blocks.png) -->
268-
269250
:::warning Important Considerations
270251
In-band CRS blocking provides maximum protection but requires:
271252
- **Thorough testing** in a staging environment
40.8 KB
Loading

0 commit comments

Comments
 (0)