RousselTMLEARNING

Observability

CrowdSec: understanding the collaborative firewall

What CrowdSec is, how it detects and blocks attacks: Security Engine, parsers, scenarios, Local API, Central API and bouncers.

1. What CrowdSec is #

The principle in a few minutes.

The problem #

Expose a server on the Internet: within minutes, bots try SSH passwords, look for a .env file or test a known flaw. These attacks show up in your logs, but nobody reads them continuously.

CrowdSec reads these logs for you, recognizes attack behaviors and has the addresses blocked. Its engine is free software (MIT license), written in Go.

Two strong ideas #

  • Separate detection from blocking. The engine decides; other components, the bouncers, enforce the decision where it is useful: firewall, reverse proxy, CDN or application.
  • Share intelligence. Each installation can report the attacks it faces and receive in return a list of addresses recognized as malicious.

2. The architecture #

The components and their role.

Overview #

CrowdSec architecture: logs go through parsers, scenarios, the Local API, then bouncers enforce

ComponentRole
Security EngineThe crowdsec service: it reads logs and detects attacks.
ParsersTurn a log line into a structured event.
ScenariosRecognize a behavior, such as too many failed logins.
Local API (LAPI)Stores alerts and decisions. It listens on port 8080 by default.
Central API (CAPI)CrowdSec's service: receives signals, returns community reputation.
ProfilesTurn an alert into a decision: 4 h ban by default.
BouncersEnforce decisions. They are also called remediation components.
HubCatalog of ready-to-use collections, parsers and scenarios.
cscliThe command-line tool to manage everything.

The full cycle #

Attack cycle: log line, event, bucket, alert, decision, block

Classic mistake. Installing the crowdsec package blocks nothing: you need at least one bouncer. Without it, decisions have no effect.

3. Collaborative intelligence #

What is shared, and how the list stays reliable.

What is sent #

When a scenario triggers, CrowdSec sends a signal to the CAPI: the attacker's address, the scenario and the timestamp. Your logs do not leave your server. In return, the LAPI downloads a list of addresses, visible with the CAPI origin in decisions.

cscli capi status
cscli decisions list --origin CAPI

Avoiding poisoning #

A participatory list could be polluted by false signals. CrowdSec therefore cross-checks signals from many participants and assesses their reliability before publishing an address. Well-known legitimate addresses, such as large DNS resolvers, are excluded through allow lists, for example the crowdsecurity/whitelist-good-actors collection.

Optional. You can turn this sharing off: DISABLE_ONLINE_API=true in Docker, or with no CAPI credentials. Local detection keeps working, without the community list.

Sources #

Related articles

CrowdSec or Fail2ban: what are the differences?

Comparing CrowdSec and Fail2ban: detection, blocking, sharing, performance, multi-server, and how to migrate …

Installing and configuring CrowdSec: packages, Docker, acquisition

Install CrowdSec with packages or Docker, understand its files, declare the logs to read, enroll the console …

CrowdSec collections, parsers and scenarios

The Hub, collections, the parser pipeline and scenarios: install, understand with cscli explain, write your o…

Keep learning

Support us

♥ SUPPORT US

Support RousselTM Learning

Courses, articles, labs and certificates stay free with no intrusive ads. A voluntary contribution, of any amount you choose, pays for hosting, lab environments and new content.

Contribute with PayPal Any amount · card or PayPal accountLearn more
QR code PayPal
Or scan this QR code with your phone

Thank you, every contribution counts!