Skip to content

Commit a96555f

Browse files
authored
Merge branch 'main' into cscli-setup
2 parents c6204a3 + 741ce6e commit a96555f

File tree

12 files changed

+255
-163
lines changed

12 files changed

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

0 commit comments

Comments
 (0)