Skip to content
Merged
Show file tree
Hide file tree
Changes from 5 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 7 additions & 3 deletions .claude-plugin/marketplace.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,13 @@
"url": "https://github.com/crowdsecurity"
},
"metadata": {
"description": "CrowdSec skills and tooling \u2014 operational automation for installing, configuring, and debugging CrowdSec, plus a Service API skill for the premium Console cloud API."
"description": "CrowdSec skills and tooling \u2014 operational automation for installing, configuring, and debugging CrowdSec, a hub authoring skill for writing and reviewing crowdsecurity/hub items, plus a Service API skill for the premium Console cloud API."
},
"plugins": [
{
"name": "crowdsec",
"source": "./",
"description": "CrowdSec skills: an operational skill (engine, cscli, hub, bouncers, WAF/AppSec and bot detection across bare-metal, Docker, Kubernetes) and a Service API skill (premium Console cloud API \u2014 blocklists, allowlists, firewall integrations, metrics, decisions).",
"description": "CrowdSec skills: an operational skill (engine, cscli, hub, bouncers, WAF/AppSec and bot detection across bare-metal, Docker, Kubernetes), a hub authoring skill (parsers, scenarios, whitelists, collections, WAF rules and hubtest tests for crowdsecurity/hub) and a Service API skill (premium Console cloud API \u2014 blocklists, allowlists, firewall integrations, metrics, decisions).",
"version": "0.3.0",
"author": {
"name": "CrowdSec",
Expand All @@ -35,7 +35,11 @@
"service-api",
"sapi",
"blocklist",
"integration"
"integration",
"hub",
"parser",
"scenario",
"hubtest"
]
}
]
Expand Down
11 changes: 8 additions & 3 deletions .claude-plugin/plugin.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,10 @@
"version": "0.3.0",
"skills": [
"./skills/crowdsec",
"./skills/crowdsec-service-api"
"./skills/crowdsec-service-api",
"./skills/crowdsec-hub-authoring"
],
"description": "CrowdSec skills: an operational skill (install/configure/operate/debug the engine, cscli, bouncers, WAF and bot detection across bare-metal/Docker/Kubernetes) and a Service API skill (drive the premium Console cloud API \u2014 blocklists, allowlists, firewall integrations, metrics, decisions).",
"description": "CrowdSec skills: an operational skill (install/configure/operate/debug the engine, cscli, bouncers, WAF and bot detection across bare-metal/Docker/Kubernetes), a hub authoring skill (write, test and review parsers, scenarios, whitelists, collections and WAF rules for crowdsecurity/hub) and a Service API skill (drive the premium Console cloud API \u2014 blocklists, allowlists, firewall integrations, metrics, decisions).",
"author": {
"name": "CrowdSec",
"url": "https://github.com/crowdsecurity"
Expand All @@ -28,6 +29,10 @@
"cloud",
"bot-detection",
"bot-management",
"challenge"
"challenge",
"hub",
"parser",
"scenario",
"hubtest"
]
}
6 changes: 4 additions & 2 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -97,9 +97,10 @@ jobs:
- name: Build web-uploadable skill archive
run: |
# claude.ai's web skill uploader needs SKILL.md at the archive root,
# so zip the *contents* of skills/crowdsec/ (not the folder itself).
# so zip the *contents* of each skill folder (not the folder itself).
VERSION="${{ steps.ver.outputs.version }}"
( cd skills/crowdsec && zip -r "../../crowdsec-skill-v${VERSION}.zip" . )
( cd skills/crowdsec-hub-authoring && zip -r "../../crowdsec-hub-authoring-skill-v${VERSION}.zip" . )

- name: Attach archive to the release
if: github.event_name == 'release'
Expand All @@ -108,7 +109,8 @@ jobs:
run: |
VERSION="${{ steps.ver.outputs.version }}"
gh release upload "${{ github.event.release.tag_name }}" \
"crowdsec-skill-v${VERSION}.zip" --clobber
"crowdsec-skill-v${VERSION}.zip" \
"crowdsec-hub-authoring-skill-v${VERSION}.zip" --clobber

- name: Commit bumped files
run: |
Expand Down
9 changes: 8 additions & 1 deletion .github/workflows/validate.yml
Original file line number Diff line number Diff line change
Expand Up @@ -35,4 +35,11 @@ jobs:
# stale or missing records. Gaps and staleness are informational and do
# not fail the build; a malformed `verified:` block does.
- name: Verification coverage report
run: python3 skills/crowdsec/scripts/check-verification.py
run: |
rc=0
for skill in skills/*/; do
echo "### ${skill}"
python3 skills/crowdsec/scripts/check-verification.py --root "$skill" || rc=1
echo
done
exit $rc
8 changes: 8 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,12 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
## [Unreleased]

### Added
- `skills/crowdsec-hub-authoring/` — new skill for writing, testing and reviewing
crowdsecurity/hub items: parsers, scenarios, whitelists/postoverflows, collections and
contexts, AppSec rules/virtual patches, `cscli hubtest` tests and a PR review checklist.
Registered in `plugin.json`. Every reference doc is verified (`env: hubtest`, CrowdSec
1.8.2) by running its examples through `cscli hubtest` / `cscli explain`.
- Release workflow attaches `crowdsec-hub-authoring-skill-vX.Y.Z.zip` for the claude.ai uploader.
- `references/appsec/bot-detection/` — bot detection / AppSec challenge mode (CrowdSec 1.8):
`overview.md` (PoW + fingerprint model, challenge envelope, event vocabulary, bouncer
support), `deploy.md` (bundle choice, glob acquisition, bouncer wiring, four-step smoke
Expand All @@ -19,6 +25,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
- `README.md` — **Reference docs** index linking each `references/` area.

### Changed
- `check-verification.py` accepts `hubtest` as a canonical env; the validate workflow runs it
on every skill under `skills/`, not only `skills/crowdsec`.
- `SKILL.md` — bot-detection routing rows, boundary row, trigger phrases in `description`,
and a new **Step 1.6 — Feature compatibility** table holding minimum engine versions and
feature prerequisites in one place.
Expand Down
31 changes: 28 additions & 3 deletions CLAUDE.md
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,9 @@ If you are uncertain about any fact, statistic, date, or piece of technical info

## Content structure

The plugin ships **two skills** under `skills/`: `crowdsec` (operational — local
engine/cscli/bouncers/WAF) and `crowdsec-service-api` (the premium Console cloud REST API). Each has
The plugin ships **three skills** under `skills/`: `crowdsec` (operational — local
engine/cscli/bouncers/WAF), `crowdsec-service-api` (the premium Console cloud REST API) and
`crowdsec-hub-authoring` (writing and reviewing crowdsecurity/hub items). Each has
its own router `SKILL.md` and `references/`. The layout below describes the `crowdsec` skill; the
`crowdsec-service-api` layout follows in its own subsection.

Expand Down Expand Up @@ -98,6 +99,29 @@ on the user's behalf, every mutating one gated behind explicit confirmation. Ver
`env: sapi` in the `verified:` block. When you add/rename a resource file here, update this table in
the same change.

### `crowdsec-hub-authoring` skill layout

`SKILL.md` is the router plus the hub's non-negotiables. `references/` is organized by **hub item
type**, one file each, plus a cross-cutting overview and review checklist:

| File | Covers |
|---|---|
| `overview.md` | Hub repo layout, naming/author rules, what gets rejected, CI gates. |
| `parsers.md` | Stages, grok/JSON parsing, `source_ip`, timestamps, filters. |
| `scenarios.md` | Bucket types and tuning, labels/behaviors/MITRE taxonomy. |
| `whitelists-postoverflows.md` | App-level false-positive suppression in the hub. |
| `collections-and-docs.md` | Collections, contexts, item `.md` docs, acquisition examples. |
| `testing.md` | `cscli hubtest`, assert files, CI failures. |
| `appsec-rules.md` | WAF rules, virtual patches, nuclei tests. |
| `review-checklist.md` | PR review / self-review checklist. |

No platform axis: the environment is a hub checkout plus `cscli hubtest`. Claims cite upstream docs,
hub CI/lint code or the hub PRs where maintainers enforced them (by PR number). Verification uses
`env: hubtest`: run the doc's example items and commands with `cscli hubtest` (and `cscli explain`)
in a hub checkout, with a user-owned CrowdSec instance passed via `-c`; AppSec tests need the hub's
`docker/appsec` target and `nuclei`. When you add/rename a
file here, update this table in the same change.

## Testing

- **Nothing ships unverified.** Every command and every expected outcome must have been
Expand Down Expand Up @@ -140,7 +164,8 @@ Rules:
- Use ISO 8601 dates so the checker can sort and age them.
- Don't pre-seed unverified docs with empty blocks; absence *is* the "never verified" signal.

`skills/crowdsec/scripts/check-verification.py` (stdlib-only, safe to run locally) reports coverage,
`skills/crowdsec/scripts/check-verification.py --root skills/<skill>` (stdlib-only, safe to run
locally; CI runs it on every skill) reports coverage,
lists docs with no block, flags entries older than 180 days, and fails on a malformed block.


21 changes: 19 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ component — across bare-metal/systemd, Docker, pfSense/OPNsense, and Kubernete

---

This plugin bundles **two [Agent Skills](https://docs.claude.com/en/docs/claude-code/skills)**:
This plugin bundles **three [Agent Skills](https://docs.claude.com/en/docs/claude-code/skills)**:

- **`crowdsec`** — a hands-on CrowdSec operator. Stand up an engine, wire a
bouncer, enable the WAF, or figure out why nothing's getting blocked. It knows
Expand All @@ -29,6 +29,10 @@ This plugin bundles **two [Agent Skills](https://docs.claude.com/en/docs/claude-
on your behalf with your API key: create and populate blocklists/allowlists,
wire firewall/appliance integrations, pull remediation ROI metrics, and manage
org-level decisions — every state change gated behind an explicit confirmation.
- **`crowdsec-hub-authoring`** — writes, tests and reviews items for
[crowdsecurity/hub](https://github.com/crowdsecurity/hub): parsers, scenarios,
whitelists/postoverflows, collections, contexts, AppSec rules and their
`cscli hubtest` tests, following the conventions maintainers enforce in review.


## What it covers
Expand All @@ -55,6 +59,18 @@ This plugin bundles **two [Agent Skills](https://docs.claude.com/en/docs/claude-
| **Metrics** | remediation ROI (traffic dropped, bytes/egress saved, attacks prevented) |
| **Decisions** | org-level decisions + aggregated (read/manage) |

**`crowdsec-hub-authoring` (hub contributions):**

| Area | Covered |
|---|---|
| **Parsers** | stages s00/s01/s02 · grok / `UnmarshalJSON` · `source_ip` · timestamps |
| **Scenarios** | leaky/trigger buckets · `capacity` / `leakspeed` / `blackhole` · labels & taxonomy |
| **False positives** | app whitelists · postoverflows |
| **Packaging** | collections · contexts · same-name `.md` docs · acquisition examples |
| **AppSec rules** | WAF rules · `vpatch-CVE-…` virtual patches · nuclei tests |
| **Testing** | `cscli hubtest` · `parser.assert` / `scenario.assert` · CI gates |
| **Review** | PR review checklist · naming · why hub PRs get rejected |

## Install

The skill loads automatically once installed. Just talk to
Expand Down Expand Up @@ -84,7 +100,8 @@ skill-installer crowdsecurity/crowdsec-skill

**On Claude.ai (web)**

Download `crowdsec-skill-vX.Y.Z.zip` from the
Download `crowdsec-skill-vX.Y.Z.zip` (and, for hub contributors,
`crowdsec-hub-authoring-skill-vX.Y.Z.zip`) from the
[latest release](https://github.com/crowdsecurity/crowdsec-skill/releases/latest)
and upload it in the web skill uploader.

Expand Down
37 changes: 37 additions & 0 deletions skills/crowdsec-hub-authoring/SKILL.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
---
name: crowdsec-hub-authoring
description: Use when writing, testing, or reviewing CrowdSec hub items for crowdsecurity/hub — parsers (s00/s01/s02), scenarios, parser whitelists and postoverflows, collections, contexts, AppSec (WAF) rules and virtual patches, their same-name .md docs, and cscli hubtest tests (.tests/, .appsec-tests/, parser.assert, scenario.assert). Also use to contribute a hub PR or review one (hub conventions, naming, labels/taxonomy, CI gates, why PRs get rejected). Complements the operational `crowdsec` skill, which covers installing and running CrowdSec.
---

# CrowdSec hub authoring

Writing and reviewing items for [crowdsecurity/hub](https://github.com/crowdsecurity/hub).
Distilled from the CrowdSec docs, the hub's CI and lint code, and maintainer
Comment thread
sabban marked this conversation as resolved.
Resolved
review comments on merged and closed hub PRs.

Every `#N` in this skill and its references is a **crowdsecurity/hub** pull request
(`gh pr view N --repo crowdsecurity/hub`), cited as the evidence for a rule.

For installing, configuring or debugging a running CrowdSec, use the `crowdsec` skill.

## Route by task

| Task / cue | Read |
|---|---|
| "contribute to the hub", "open a hub PR", repo layout, naming, what gets rejected, CI | [references/overview.md](./references/overview.md) |
| "write a parser", "new log format", grok, `UnmarshalJSON`, `source_ip`, timestamps | [references/parsers.md](./references/parsers.md) |
| "write a scenario", `capacity` / `leakspeed` / `blackhole`, labels, behavior, MITRE | [references/scenarios.md](./references/scenarios.md) |
| "false positive in app X — fix it in the hub", app whitelist, postoverflow | [references/whitelists-postoverflows.md](./references/whitelists-postoverflows.md) |
| collection, context, item `.md`, acquisition example | [references/collections-and-docs.md](./references/collections-and-docs.md) |
| `cscli hubtest`, asserts, test fails in CI, running tests without root | [references/testing.md](./references/testing.md) |
| WAF rule, `vpatch-CVE-…`, nuclei test | [references/appsec-rules.md](./references/appsec-rules.md) |
| "review PR #N", self-review before opening a PR | [references/review-checklist.md](./references/review-checklist.md) |

## Non-negotiables

- Search the hub and open PRs first — extend an existing parser/scenario rather than adding a second one.
- Author dir = name prefix = `author:`; never the `crowdsecurity/` namespace for external items; items can't be renamed.
- Parsers: `filter` on `evt.Parsed.program`, `apply_on: message`, real peer as `source_ip`, anchored patterns around client-controlled text.
- Every item has tests (generated asserts, private IPs, scenario tests that actually overflow) and a same-name `.md`.
- No `debug: true`, no YAML anchors, no `.index.json` / version bumps (CI does it).
- Prove review findings with `cscli hubtest` or `cscli explain` on a crafted line before reporting them.
114 changes: 114 additions & 0 deletions skills/crowdsec-hub-authoring/references/appsec-rules.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,114 @@
---
verified:
- date: 2026-11-27
version: "1.8.2"
env: hubtest
notes: "example vpatch rule + hubtest create/run --appsec with the hub docker/appsec OpenResty target and nuclei; negative control fails; crowdsec-local-mcp 0.9.3 tools (fetch, validate, lint, run_waf_tests positive + negative, prepare_waf_pr)"
---

# Authoring — AppSec (WAF) rules

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we also need to mention the companion .md

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Added (0b2230d).


Canonical docs: create <https://docs.crowdsec.net/docs/next/appsec/create_rules> · syntax <https://docs.crowdsec.net/docs/next/appsec/rules_syntax> · contributing <https://docs.crowdsec.net/docs/next/contributing/hub/appsec_rules>

For deploying/operating the WAF, use the `crowdsec` skill (`references/appsec/`).
Comment thread
sabban marked this conversation as resolved.
Resolved

To draft and pre-test a rule, use the [crowdsec-local-mcp](https://github.com/crowdsecurity/crowdsec-local-mcp) MCP server (`uvx --from crowdsec-local-mcp init claude-code`):

- `generate_waf_rule` / `generate_waf_tests` return prompts; you write the rule.
- `fetch_nuclei_exploit <CVE>` pulls the nuclei template from projectdiscovery.
- `validate_waf_rule` checks the schema, `lint_waf_rule` gives hints.
- `run_waf_tests` runs the nuclei template against a Docker CrowdSec + OpenResty stack
and fails if the request isn't blocked.

It doesn't replace the rules below: validation accepts a rule that matches every request
(`.*`, no labels). `prepare_waf_pr` needs `rule_filename` as `appsec-rules/<author>/<name>.yaml`
(a bare name lands at the hub root), overwrites an existing test's `config.yaml`, and adds
neither the `.md` nor the collection entry.

## Naming

| Prefix | For |
|---|---|
| `vpatch-CVE-YYYY-NNNN` | one vulnerability; test named `CVE-YYYY-NNNN`/`vpatch-CVE-…` |
| `crs-` | OWASP CRS bridge |
| `generic-` | behavioral, not tied to one CVE |
| `experimental-` | detects, never blocks (loaded out of band) |

Ship a same-name `.md` next to the rule (`appsec-rules/<author>/<name>.md`): what it
detects, the CVE or advisory link, affected versions. Most existing `vpatch-*` rules
lack one; new rules include it. Format: [collections-and-docs.md](./collections-and-docs.md).

## Rule skeleton

```yaml
name: crowdsecurity/vpatch-CVE-2025-49113
description: 'Detects RCE via PHP object deserialization in Roundcube'
rules:
- and:
- zones: [METHOD]
match: {type: equals, value: POST}
- zones: [ARGS]
variables: [_action]
transform: [urldecode, lowercase]
match: {type: equals, value: upload}
- zones: [ARGS]
variables: [_from]
transform: [urldecode, lowercase]
match: {type: regex, value: "[^\\w.-]"}
labels:
type: exploit
service: http
confidence: 3
spoofable: 0
behavior: 'http:exploit'
label: "Roundcube - RCE"
classification:
- cve.CVE-2025-49113
- attack.T1190
- cwe.CWE-502
```

## What reviewers check

- **Precision over breadth**: scope to the vulnerable endpoint/parameter of the
vulnerable product. Prefer "value contains characters a legit value never has"
(`[^a-z0-9]`, negative regex) over matching one exploit string (#1737, #1738, #1739).
Consider `libinjection` helpers for injection classes (#1299, #1236).
- If the rule **can't tell an attacker from a legit request** (auth bypass with a
valid-looking token, legit admin actions), it is closed, not merged (#1604, #1488, #1483, #1486, #1491).
- Apply `transform` (`urldecode`, `lowercase`) before matching; check body vs args zones.
- `label`: "Product - Vulnerability class" ("Cacti RCE", "F5 BIG-IP iControl REST - Authentication Bypass"),
no "Attempt" (#885, #1347, #1011).
- `classification` must match the CVE; disclosure-only rules shouldn't share the
RCE CVE bucket unintentionally (#1714).
- Metadata (product names, versions, URLs) must match what the rule actually covers.

## Test (`.appsec-tests/<test>/`)

```yaml
# config.yaml
appsec-rules:
- ./appsec-rules/crowdsecurity/base-config.yaml
- ./appsec-rules/crowdsecurity/vpatch-CVE-2025-49113.yaml
nuclei_template: vpatch-CVE-2025-49113.yaml
```

The nuclei template sends the exploit request(s) and expects `403` (blocked).
Capture real requests with `nc -lvp 4245` + the PoC. Run:

```bash
cscli hubtest create vpatch-CVE-YYYY-NNNN --appsec
cscli hubtest run vpatch-CVE-YYYY-NNNN --appsec
```

Add a test when matching logic, transforms or exclusions change.

## Collections and CI

- New `vpatch-*` rules must be listed in `collections/crowdsecurity/appsec-virtual-patching.yaml`
(`appsec_vpatch_lint` comments otherwise); product-specific ones may go in a product
vpatch collection (e.g. WordPress) (#1737–#1739).
- Adding a rule to an appsec-config is not enough for it to be downloaded — it must be
in a collection (#1393); `generic-*` collections need `crowdsecurity/base-config` (#1011).
- `waf-check` replays legitimate traffic and fails on false positives even if the rule's
own test passes.
Loading