Skip to content

Commit e3ab680

Browse files
committed
revamp the waf doc
1 parent 2d45f36 commit e3ab680

File tree

11 files changed

+227
-156
lines changed

11 files changed

+227
-156
lines changed

crowdsec-docs/docs/appsec/alerts_and_scenarios.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
---
22
id: alerts_and_scenarios
3-
title: AppSec Alerts & Scenarios
3+
title: Alerts & Scenarios
44
sidebar_position: 5
55
---
66

crowdsec-docs/docs/appsec/benchmark.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
---
22
id: benchmark
3-
title: CrowdSec WAF / AppSec Component Benchmark
3+
title: WAF Component Benchmark
44
sidebar_position: 80
55
---
66

crowdsec-docs/docs/appsec/configuration.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
---
22
id: configuration
3-
title: AppSec Configuration Files
3+
title: Configurations Files
44
sidebar_position: 6
55
---
66

crowdsec-docs/docs/appsec/installation.md

Lines changed: 0 additions & 141 deletions
This file was deleted.

crowdsec-docs/docs/appsec/protocol.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
---
22
id: protocol
3-
title: AppSec Component Communication Protocol
3+
title: WAF / Bouncer Communication Protocol
44
sidebar_position: 5
55
---
66

Lines changed: 198 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,198 @@
1+
---
2+
id: general_setup
3+
title: General Setup
4+
---
5+
6+
7+
8+
import Tabs from '@theme/Tabs';
9+
import TabItem from '@theme/TabItem';
10+
import CodeBlock from '@theme/CodeBlock';
11+
import UnderlineTooltip from '@site/src/components/underline-tooltip';
12+
13+
14+
# CrowdSec WAF General Setup
15+
16+
This guide covers the core CrowdSec AppSec Component setup that applies to all web servers and reverse proxies. After completing these steps, you'll need to configure your specific remediation component (bouncer) to forward requests to the AppSec Component.
17+
18+
## Prerequisites
19+
20+
- **CrowdSec Security Engine** (>= 1.5.6) installed and running
21+
- A compatible remediation component (bouncer) for your web server or reverse proxy
22+
23+
## AppSec Component Setup
24+
25+
### Collection Installation
26+
27+
Install the essential AppSec collections that provide virtual patching rules and generic attack detection:
28+
29+
```bash
30+
sudo cscli collections install crowdsecurity/appsec-virtual-patching crowdsecurity/appsec-generic-rules
31+
```
32+
33+
These collections include:
34+
- **Virtual Patching Rules**: Protection against known vulnerabilities (CVEs)
35+
- **Generic Attack Detection**: Common web attack patterns
36+
- **AppSec Configuration**: Default configuration linking rules together
37+
- **CrowdSec Parsers & Scenarios**: For processing AppSec events and creating alerts
38+
39+
### Acquisition Configuration
40+
41+
Configure CrowdSec to expose the AppSec Component by creating an acquisition file:
42+
43+
1. Create the acquisition directory (if it doesn't exist):
44+
```bash
45+
sudo mkdir -p /etc/crowdsec/acquis.d/
46+
```
47+
48+
2. Create the AppSec acquisition configuration:
49+
```bash
50+
sudo cat > /etc/crowdsec/acquis.d/appsec.yaml << EOF
51+
appsec_config: crowdsecurity/appsec-default
52+
labels:
53+
type: appsec
54+
listen_addr: 127.0.0.1:7422
55+
source: appsec
56+
name: myAppSecComponent
57+
EOF
58+
```
59+
60+
**Configuration explained:**
61+
- `appsec_config`: Uses the default configuration from the installed collections
62+
- `listen_addr`: The IP and port where the AppSec Component will listen (default: 127.0.0.1:7422)
63+
- `source`: Identifies this as an AppSec data source
64+
- `name`: A friendly name for your AppSec component
65+
66+
:::warning Security Note
67+
Do not expose the AppSec Component to the internet. It should only be accessible from your web server or reverse proxy.
68+
:::
69+
70+
### Start the AppSec Component
71+
72+
Restart CrowdSec to activate the AppSec Component:
73+
74+
```bash
75+
sudo systemctl restart crowdsec
76+
```
77+
78+
## Testing WAF Component
79+
80+
### Testing Configuration
81+
82+
Check that the AppSec Component is running:
83+
84+
<Tabs
85+
defaultValue="netstat"
86+
groupId="listening-ports"
87+
values={[
88+
{label: 'Netstat', value: 'netstat'},
89+
{label: 'SS', value: 'ss'},
90+
]}>
91+
92+
<TabItem value="netstat">
93+
<CodeBlock className="language-bash">sudo netstat -tlpn | grep 7422</CodeBlock>
94+
</TabItem>
95+
96+
<TabItem value="ss">
97+
<CodeBlock className="language-bash">sudo ss -tlpn | grep 7422</CodeBlock>
98+
</TabItem>
99+
</Tabs>
100+
101+
<details>
102+
103+
<summary>Output example</summary>
104+
105+
```bash
106+
tcp 0 0 127.0.0.1:7422 0.0.0.0:* LISTEN 12345/crowdsec
107+
```
108+
109+
:::note
110+
The output may look differently depending on which command you used but as long as you see the port and the process `crowdsec`, it means the AppSec Component is running.
111+
:::
112+
113+
</details>
114+
115+
Check CrowdSec logs for successful startup:
116+
```bash
117+
sudo tail -f /var/log/crowdsec.log
118+
```
119+
120+
Look for messages like:
121+
```
122+
INFO[...] Starting Appsec server on 127.0.0.1:7422/
123+
INFO[...] Appsec Runner ready to process event
124+
```
125+
126+
### Testing Detection
127+
128+
If you've enabled an AppSec-capable bouncer with CrowdSec WAF, you can trigger the crowdsecurity/appsec-generic-test dummy scenario.
129+
This scenario will not lead to decision but is a great way to ensure that your setup is functional.
130+
131+
We'll trigger the dummy scenario crowdsecurity/appsec-generic-test by accessing a probe path on your web server.
132+
133+
1️⃣ Access your service URL with this path: `/crowdsec-test-NtktlJHV4TfBSK3wvlhiOBnl`
134+
135+
```bash
136+
curl -I https://<your-service-url>/crowdsec-test-NtktlJHV4TfBSK3wvlhiOBnl
137+
```
138+
139+
2️⃣ Confirm the alert has triggered for the scenario crowdsecurity/appsec-generic-test
140+
141+
```bash
142+
sudo cscli alerts list | grep crowdsecurity/appsec-generic-test
143+
```
144+
145+
3️⃣ The alert will also appear in the console alerts
146+
147+
![appsec-generic-test console view](/img/appsec-generic-test-console.png)
148+
149+
150+
:::info
151+
This scenario can only be triggered again after a 1-minute delay.
152+
:::
153+
154+
## Next Steps
155+
156+
Now that the AppSec Component is configured and running, you need to:
157+
158+
1. **Configure your remediation component** to forward requests to `http://127.0.0.1:7422`
159+
2. **Test the setup** by triggering a rule (e.g., accessing `/.env`)
160+
3. **Monitor alerts** with `sudo cscli alerts list` or in the [CrowdSec Console](https://app.crowdsec.net)
161+
162+
For specific remediation component configuration, see:
163+
- [Nginx/OpenResty Setup](/appsec/quickstart/nginxopenresty.mdx)
164+
- [Traefik Setup](/appsec/quickstart/traefik.mdx)
165+
- [WordPress Setup](/appsec/quickstart/wordpress.mdx)
166+
167+
## Optional: Advanced Configuration
168+
169+
### Multiple AppSec Configurations
170+
171+
You can load multiple AppSec configurations for different rule sets:
172+
173+
```yaml
174+
# /etc/crowdsec/acquis.d/appsec.yaml
175+
appsec_configs:
176+
- crowdsecurity/appsec-default # Virtual patching rules (in-band)
177+
- crowdsecurity/crs # OWASP CRS rules (out-of-band)
178+
labels:
179+
type: appsec
180+
listen_addr: 127.0.0.1:7422
181+
source: appsec
182+
name: myAppSecComponent
183+
```
184+
185+
### Custom Port Configuration
186+
187+
To use a different port, update the `listen_addr` in your acquisition file and ensure your remediation component points to the same address.
188+
189+
## Troubleshooting
190+
191+
If the AppSec Component fails to start:
192+
193+
1. **Check port availability**: Ensure port 7422 isn't already in use
194+
2. **Verify collections**: Run `sudo cscli collections list` to confirm installation
195+
3. **Check configuration syntax**: Validate your `appsec.yaml` file
196+
4. **Review logs**: Check `/var/log/crowdsec.log` for error messages
197+
198+
For detailed troubleshooting, see the [AppSec Troubleshooting Guide](/appsec/troubleshooting).

0 commit comments

Comments
 (0)