[PR #6917] [management, proxy, self-hosted] Add CrowdSec AppSec request inspection to the reverse proxy #27481

Open
opened 2026-08-05 07:08:47 -04:00 by saavagebueno · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/netbirdio/netbird/pull/6917
Author: @lixmal
Created: 7/27/2026
Status: 🔄 Open

Base: mainHead: reverse-proxy-crowdsec-appsec


📝 Commits (2)

  • 663468e Add CrowdSec AppSec request inspection to the reverse proxy
  • af1f94b Merge branch 'main' into reverse-proxy-crowdsec-appsec

📊 Changes

41 files changed (+3777 additions, -772 deletions)

View changed files

📝 infrastructure_files/getting-started.sh (+31 -2)
📝 management/internals/modules/reverseproxy/domain/domain.go (+3 -0)
📝 management/internals/modules/reverseproxy/domain/manager/api.go (+1 -0)
📝 management/internals/modules/reverseproxy/domain/manager/manager.go (+3 -0)
📝 management/internals/modules/reverseproxy/domain/manager/manager_test.go (+4 -0)
📝 management/internals/modules/reverseproxy/proxy/manager.go (+1 -0)
📝 management/internals/modules/reverseproxy/proxy/manager/manager.go (+8 -0)
📝 management/internals/modules/reverseproxy/proxy/manager/manager_test.go (+3 -0)
📝 management/internals/modules/reverseproxy/proxy/manager_mock.go (+72 -56)
📝 management/internals/modules/reverseproxy/proxy/proxy.go (+4 -0)
📝 management/internals/modules/reverseproxy/service/manager/api.go (+1 -0)
📝 management/internals/modules/reverseproxy/service/manager/manager.go (+2 -0)
📝 management/internals/modules/reverseproxy/service/service.go (+48 -6)
📝 management/internals/modules/reverseproxy/service/service_test.go (+76 -0)
📝 management/internals/shared/grpc/proxy.go (+2 -1)
📝 management/server/store/sql_store.go (+9 -0)
management/server/store/sql_store_proxy_capability_test.go (+119 -0)
📝 management/server/store/sql_store_service_test.go (+39 -0)
📝 management/server/store/store.go (+1 -0)
📝 management/server/store/store_mock.go (+14 -0)

...and 21 more files

📄 Description

Describe your changes

Adds CrowdSec AppSec (WAF) request inspection to the reverse proxy. Where the existing CrowdSec integration asks whether the client IP is known bad, this asks whether the request itself is an attack: each HTTP request on an opted-in service is mirrored to the Security Engine's AppSec endpoint, which answers allow, ban, or captcha. It is off by default and enabled per service.

  • Add an appsec_mode (off/enforce/observe) to service access restrictions, HTTP services only, alongside the existing CrowdSec mode
  • Implement the AppSec protocol in the proxy: request mirroring, verdict handling, capped body buffering that leaves the request forwardable, and a bounded inspection timeout
  • Fail closed in enforce mode when the engine cannot produce a verdict, and record the verdict in the access log in observe mode without blocking
  • Keep credentials the proxy already withholds from backends out of the mirrored request: session cookie, header-auth values, OIDC session token, and password/PIN fields, with only the values replaced so the rest stays inspectable
  • Advertise a supports_appsec cluster capability so the option only appears where an endpoint is configured, which keeps this opt-in for self-hosted and bring-your-own-proxy deployments
  • Share the proxy-wide body-buffering allowance with the agent-network request capture instead of opening a second pool, and record in the access log whenever a body went uninspected
  • Enable the endpoint in the self-hosted setup script when CrowdSec is selected

Stack

Checklist

  • Is it a bug fix
  • Is a typo/documentation fix
  • Is a feature enhancement
  • It is a refactor
  • Created tests that fail without the change (if possible)
  • This change does not modify the public API, gRPC protocols, functionality behavior, CLI / service flags, or introduce a new feature — OR I have discussed it with the NetBird team beforehand (link the issue / Slack thread in the description). See CONTRIBUTING.md.

By submitting this pull request, you confirm that you have read and agree to the terms of the Contributor License Agreement.

Documentation

Select exactly one:

  • I added/updated documentation for this change
  • Documentation is not needed for this change (explain why)

Docs PR URL (required if "docs added" is checked)

Paste the PR link from https://github.com/netbirdio/docs here:

https://github.com/netbirdio/docs/pull/889


View with [code]smith Autofix with [code]smith
Need help on this PR? Tag @codesmith-bot with what you need. Autofix is disabled.

Summary by CodeRabbit

  • New Features

    • Added CrowdSec AppSec (WAF) request inspection for HTTP services with off, observe, and enforce modes (enforce can block; observe records verdicts).
    • Added appsec_mode to access restrictions plus capability reporting (supports_appsec) for proxy clusters and reverse-proxy domains.
    • Added CLI/configuration options for the AppSec endpoint, timeouts, mirrored body limits, and inspection concurrency/budget; proxy advertises AppSec support to services.
  • Bug Fixes

    • Improved safe handling for oversized and upgrade requests to preserve streams correctly.
    • Validation and fail-closed behavior now correctly reject/deny when AppSec isn’t applicable or isn’t available.

🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/netbirdio/netbird/pull/6917 **Author:** [@lixmal](https://github.com/lixmal) **Created:** 7/27/2026 **Status:** 🔄 Open **Base:** `main` ← **Head:** `reverse-proxy-crowdsec-appsec` --- ### 📝 Commits (2) - [`663468e`](https://github.com/netbirdio/netbird/commit/663468e19991842346679896e2a1392518123a6b) Add CrowdSec AppSec request inspection to the reverse proxy - [`af1f94b`](https://github.com/netbirdio/netbird/commit/af1f94bbe9c40e4cd69de1ede08acc4b391018eb) Merge branch 'main' into reverse-proxy-crowdsec-appsec ### 📊 Changes **41 files changed** (+3777 additions, -772 deletions) <details> <summary>View changed files</summary> 📝 `infrastructure_files/getting-started.sh` (+31 -2) 📝 `management/internals/modules/reverseproxy/domain/domain.go` (+3 -0) 📝 `management/internals/modules/reverseproxy/domain/manager/api.go` (+1 -0) 📝 `management/internals/modules/reverseproxy/domain/manager/manager.go` (+3 -0) 📝 `management/internals/modules/reverseproxy/domain/manager/manager_test.go` (+4 -0) 📝 `management/internals/modules/reverseproxy/proxy/manager.go` (+1 -0) 📝 `management/internals/modules/reverseproxy/proxy/manager/manager.go` (+8 -0) 📝 `management/internals/modules/reverseproxy/proxy/manager/manager_test.go` (+3 -0) 📝 `management/internals/modules/reverseproxy/proxy/manager_mock.go` (+72 -56) 📝 `management/internals/modules/reverseproxy/proxy/proxy.go` (+4 -0) 📝 `management/internals/modules/reverseproxy/service/manager/api.go` (+1 -0) 📝 `management/internals/modules/reverseproxy/service/manager/manager.go` (+2 -0) 📝 `management/internals/modules/reverseproxy/service/service.go` (+48 -6) 📝 `management/internals/modules/reverseproxy/service/service_test.go` (+76 -0) 📝 `management/internals/shared/grpc/proxy.go` (+2 -1) 📝 `management/server/store/sql_store.go` (+9 -0) ➕ `management/server/store/sql_store_proxy_capability_test.go` (+119 -0) 📝 `management/server/store/sql_store_service_test.go` (+39 -0) 📝 `management/server/store/store.go` (+1 -0) 📝 `management/server/store/store_mock.go` (+14 -0) _...and 21 more files_ </details> ### 📄 Description ## Describe your changes Adds CrowdSec AppSec (WAF) request inspection to the reverse proxy. Where the existing CrowdSec integration asks whether the client IP is known bad, this asks whether the request itself is an attack: each HTTP request on an opted-in service is mirrored to the Security Engine's AppSec endpoint, which answers allow, ban, or captcha. It is off by default and enabled per service. - Add an `appsec_mode` (off/enforce/observe) to service access restrictions, HTTP services only, alongside the existing CrowdSec mode - Implement the AppSec protocol in the proxy: request mirroring, verdict handling, capped body buffering that leaves the request forwardable, and a bounded inspection timeout - Fail closed in enforce mode when the engine cannot produce a verdict, and record the verdict in the access log in observe mode without blocking - Keep credentials the proxy already withholds from backends out of the mirrored request: session cookie, header-auth values, OIDC session token, and password/PIN fields, with only the values replaced so the rest stays inspectable - Advertise a `supports_appsec` cluster capability so the option only appears where an endpoint is configured, which keeps this opt-in for self-hosted and bring-your-own-proxy deployments - Share the proxy-wide body-buffering allowance with the agent-network request capture instead of opening a second pool, and record in the access log whenever a body went uninspected - Enable the endpoint in the self-hosted setup script when CrowdSec is selected ## Issue ticket number and link ## Stack <!-- branch-stack --> ### Checklist - [ ] Is it a bug fix - [ ] Is a typo/documentation fix - [x] Is a feature enhancement - [ ] It is a refactor - [x] Created tests that fail without the change (if possible) - [x] This change does **not** modify the public API, gRPC protocols, functionality behavior, CLI / service flags, or introduce a new feature — **OR** I have discussed it with the NetBird team beforehand (link the issue / Slack thread in the description). See [CONTRIBUTING.md](https://github.com/netbirdio/netbird/blob/main/CONTRIBUTING.md#discuss-changes-with-the-netbird-team-first). > By submitting this pull request, you confirm that you have read and agree to the terms of the [Contributor License Agreement](https://github.com/netbirdio/netbird/blob/main/CONTRIBUTOR_LICENSE_AGREEMENT.md). ## Documentation Select exactly one: - [x] I added/updated documentation for this change - [ ] Documentation is **not needed** for this change (explain why) ### Docs PR URL (required if "docs added" is checked) Paste the PR link from https://github.com/netbirdio/docs here: https://github.com/netbirdio/docs/pull/889 <!-- codesmith:footer --> --- <a href="https://app.blacksmith.sh/netbirdio/codesmith/netbird/pr/6917"><picture><source media="(prefers-color-scheme: dark)" srcset="https://pr-comments-assets.blacksmith.sh/codesmith/view-with-codesmith-dark-v2.svg"><source media="(prefers-color-scheme: light)" srcset="https://pr-comments-assets.blacksmith.sh/codesmith/view-with-codesmith-light-v2.svg"><img alt="View with [code]smith" src="https://pr-comments-assets.blacksmith.sh/codesmith/view-with-codesmith-dark-v2.svg"></picture></a> <a href="https://backend.blacksmith.sh/track/enable-autofix?expires=1787747000&installation_model_id=427504&pr_number=6917&repository=netbirdio%2Fnetbird&return_to=https%3A%2F%2Fgithub.com%2Fnetbirdio%2Fnetbird%2Fpull%2F6917&signature=21a00a8ca6152a3ddb6ae0adb4fddea52bd7effeb001ccf21506c35385c94eae"><picture><source media="(prefers-color-scheme: dark)" srcset="https://pr-comments-assets.blacksmith.sh/codesmith/autofix-with-codesmith-dark.svg"><source media="(prefers-color-scheme: light)" srcset="https://pr-comments-assets.blacksmith.sh/codesmith/autofix-with-codesmith-light.svg"><img alt="Autofix with [code]smith" src="https://pr-comments-assets.blacksmith.sh/codesmith/autofix-with-codesmith-dark.svg"></picture></a> <sup>Need help on this PR? Tag <code>@codesmith-bot</code> with what you need. Autofix is disabled.</sup> <!-- codesmith:autofix:disabled --> <!-- /codesmith:footer --> <!-- This is an auto-generated comment: release notes by coderabbit.ai --> ## Summary by CodeRabbit * **New Features** * Added CrowdSec AppSec (WAF) request inspection for HTTP services with `off`, `observe`, and `enforce` modes (enforce can block; observe records verdicts). * Added `appsec_mode` to access restrictions plus capability reporting (`supports_appsec`) for proxy clusters and reverse-proxy domains. * Added CLI/configuration options for the AppSec endpoint, timeouts, mirrored body limits, and inspection concurrency/budget; proxy advertises AppSec support to services. * **Bug Fixes** * Improved safe handling for oversized and upgrade requests to preserve streams correctly. * Validation and fail-closed behavior now correctly reject/deny when AppSec isn’t applicable or isn’t available. <!-- end of auto-generated comment: release notes by coderabbit.ai --> --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
saavagebueno added the pull-request label 2026-08-05 07:08:47 -04:00
Sign in to join this conversation.
No Label pull-request
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: DYNR/netbird#27481