Repository navigation
Conversation
There was a problem hiding this comment.
🟡 Changes recommended
Unresolved cleanup lifetime errors and inspection bypasses prevent safe approval.
7 open findings
Request cleanup retains expired stack address · New Lookup failures bypass AppSec inspection · New AppSec-only configurations skip handle-pool creation · New Body-limit bypass incorrectly triggers AppSec failure · New Narrowed JSON status bypasses range validation · New Body-read errors lose original HTTP status · New Stale AppSec socket persists after HTTP endpoint replacement · New
What changed in this PR
Adds AppSec inspection and bot-detection challenges to the Apache CrowdSec bouncer alongside existing local API decisions.
Changes:
- Adds request forwarding, body capture and replay, and challenge response handling.
- Introduces AppSec configuration and bounded verdict parsing.
- Adds unit and integration coverage with a stub AppSec service.
| File | Description |
|---|---|
| test/unit/t_verdict.c | Tests AppSec verdict parsing and validation. |
| test/README.md | Documents AppSec tests and live-engine checks. |
| test/lib/stub_appsec.py | Simulates AppSec responses and records requests. |
| test/lib/harness.sh | Adds AppSec lifecycle helpers and runtime directory configuration. |
| test/bats/challenge.bats | Tests challenge responses, cookies, and endpoints. |
| test/bats/appsec.bats | Tests forwarding, verdicts, and failure policies. |
| test/bats/appsec-body.bats | Tests body inspection, replay, and limits. |
| mod_crowdsec.c | Integrates AppSec checks and configuration directives. |
| Makefile.am | Includes AppSec sources in the build. |
| crowdsec_verdict.h | Defines AppSec verdict structures and bounds. |
| crowdsec_verdict.c | Parses and validates AppSec responses. |
| crowdsec_config.h | Adds AppSec settings and defaults. |
| crowdsec_appsec.h | Declares AppSec interfaces and request state. |
| crowdsec_appsec.c | Implements inspection, replay, and challenge serving. |
| config/crowdsec-apache2-bouncer.conf | Documents optional AppSec configuration. |
🧠 Review effort: Balanced
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
| if (!sconf->url && !sconf->appsec_url) { | ||
| continue; |
| rem = crowdsec_rem_merge(rem, CROWDSEC_REM_BAN); | ||
| break; | ||
| case CROWDSEC_APPSEC_BADREQ: | ||
| return HTTP_BAD_REQUEST; |
d95f393 to
5031013
Compare
|
You are seeing this message because GitHub Code Scanning has recently been set up for this repository, or this pull request contains the workflow file for the Code Scanning tool. What Enabling Code Scanning Means:
For more information about GitHub Code Scanning, check out the documentation. |
| /* True for the challenge's own assets and submit endpoint. Matched on the | ||
| * decoded path so a traversal cannot dodge it. | ||
| */ | ||
| int crowdsec_is_challenge_path(const char *uri, const char *prefix); |
There was a problem hiding this comment.
check this: it seems fragile. shouldn't we want it to be enabled "server wide" and disabled in some specific location ?
|
|
||
| <Location /> | ||
| Crowdsec On | ||
| CrowdsecAppsec On |
There was a problem hiding this comment.
In documentation we want to suggest to enable the bouncer and appsec globally (per vhost) and just show that you can disable it in specific locations.
| |---|---|---|---| | ||
| | `Crowdsec` | S+D | `Off` | Check requests in this scope. | | ||
| | `CrowdsecBlockedHTTPCode` | S+D | `429` | Status for a blocked client: `429`, `403` or `500`. | | ||
| | `CrowdsecLocation` | S+D | — | Redirect a blocked client here instead. Supports expressions, e.g. `/blocked?ip=%{REMOTE_ADDR}`. | |
There was a problem hiding this comment.
investigate:
- is this an internal redirect ?
- if not, we might want to do the same approach as for nginx bouncer, where the bouncer just serves a static html that the user can override
| |---|---|---|---| | ||
| | `CrowdsecAppsecURL` | S | — | AppSec address: `http://127.0.0.1:7422` or `unix:/run/crowdsec/appsec.sock`. Unset disables AppSec. | | ||
| | `CrowdsecAppsecPath` | S | `/` | Path AppSec listens on. Must match the datasource's `path`. | | ||
| | `CrowdsecAppsec` | S+D | `Off` | Send requests in this scope for inspection. | |
There was a problem hiding this comment.
CrowdsecAppsec should be on by default as long as the AppSecURL is configured
|
|
||
| ## Known limits | ||
|
|
||
| **A gzipped request body is inspected compressed.** The body is captured before |
There was a problem hiding this comment.
investigate : perform a test on live vm, the appsec should decompress the body.


Uh oh!
There was an error while loading. Please reload this page.