crowdsec: request-shape — generate traversal spellings, extend the path families (card #1977) #2942

Merged
hermes merged 1 commit from kb/crowdsec-shape-normalise into main 2026-11-25 15:16:25 -06:00
Collaborator

Card: https://board.ymrtech.com/?controller=TaskViewController&action=show&task_id=1977

What this changes

fleet/http-request-shape (the one real-endpoint detection that is exempt from CrowdSec's simulation flag on public) matched 37.8% of one recorded campaign's requests: source 136.117.218.174, 2026-11-16..21, 3,300 requests across five real vhosts, 33 rotating spoofed crawler user-agents, 233 422s and 179 200s. Two structural causes, both fixed here in hosts/common/optional/crowdsec.nix:

1. Traversal cannot be enumerated by hand. The scenario matches Caddy's raw request.uri (evt.Parsed.request) and the expression language has no percent-decoder, so ..%2F is a different string from ../. The list carried "/../" and "%2e%2e"; the campaign walked past with ..%2F (14 rows on stage alone), .%2e/, ..%5C and %2e%2e%2f. Replaced the two literals with a generated traversalTokens: every spelling of two dots then a separator over a closed alphabet — a dot is . / %2e / overlong %c0%ae, a separator is / / %2f / %5c — each also double-encoded (%25), because a proxy that decodes once hands the origin a second layer. 30 tokens; no spelling of the class can be missing.

2. The families a modern deployment leaks were absent: php probe + php-cgi argument injection, Laravel/Symfony internals, CI/deploy config, credential stores, IaC state, build manifests, model-gateway endpoints (/api/v1/models, /.litellm/, /.config/openai/), LFI sinks (/proc/self/, /fileview?file=, /fs/read?allowoutsideworkspace) and debug handlers.

Measured (scripts/crowdsec-shape-replay.py, added here)

list attacker rows matched 12k legitimate 2xx sample
current (42 tokens) 1,249 / 3,300 = 37.85% 0
this PR (231 tokens) 2,329 / 3,300 = 70.58% 1
  • The single "legit" hit is GET /api/v1/settings/api on git.ymrtech.com — a scanner URI, not a served route.
  • clientsv daily e2e: 0 hits of 178,602 requests from 11.0.0.8 over 7 days (/api/login, /api/devices/*, /account/verify — none matches a token).

Deliberately not added

Each of these is a filename a real service serves, measured against the fleet's own 2xx/3xx traffic:

token real hits / 7d why it is out
/docker-compose. 670 Forgejo serves public repo trees; the repo path is in the URI
/openapi.json 266 same — /ymrtech/ymrtech/src/branch/main/openapi.json
/wp-config. 15 same, inside commit pages
/settings.py 7 same
/swagger, /swagger-ui 6 Forgejo's own /assets/js/swagger-ui.*.js, /swagger.v1.json
/config.json — Element fetches it on every page load (chat vhost)
/api/config, /api/settings — Vaultwarden's live endpoints

This is the price of the code host and the app vhosts sharing one fqdns list: filename-shaped tokens are unsafe, path-shaped tokens are safe. Documented in the option description so the next person does not re-add them.

What remains uncovered, and why it needs a different mechanism

971 of 3,300 (29%) still miss. They are almost all frontend route guessing — /pricing, /settings/billing, /dashboard, /login, /billing — which no path list can take without collateral risk (a real page could legitimately live at /pricing). The recorded campaign sent ~40 such probes per minute; the discriminator there is volume from one source, not path shape.

That escalation is not in this PR on purpose: the published page services/security/perimeter.md states "only the deception profile is enabled", and adding a ban profile for this scenario makes that sentence false. It is an owner decision (ban-on-volume from the shape rule, plus the copy change), recorded on card #1977.

Verification

  • nix eval clean for public, mail, vpn; 231 unique tokens, no duplicates.
  • Behaviour of the filter is unchanged — including maxUriLength and the method list.
  • CI builds all three hosts that declare requestShape.fqdns.
Card: https://board.ymrtech.com/?controller=TaskViewController&action=show&task_id=1977 ## What this changes `fleet/http-request-shape` (the one real-endpoint detection that is exempt from CrowdSec's simulation flag on `public`) matched **37.8%** of one recorded campaign's requests: source `136.117.218.174`, 2026-11-16..21, **3,300 requests** across five real vhosts, **33 rotating spoofed crawler user-agents**, 233 `422`s and 179 `200`s. Two structural causes, both fixed here in `hosts/common/optional/crowdsec.nix`: **1. Traversal cannot be enumerated by hand.** The scenario matches Caddy's raw `request.uri` (`evt.Parsed.request`) and the expression language has no percent-decoder, so `..%2F` is a different string from `../`. The list carried `"/../"` and `"%2e%2e"`; the campaign walked past with `..%2F` (14 rows on `stage` alone), `.%2e/`, `..%5C` and `%2e%2e%2f`. Replaced the two literals with a generated `traversalTokens`: every spelling of *two dots then a separator* over a closed alphabet — a dot is `.` / `%2e` / overlong `%c0%ae`, a separator is `/` / `%2f` / `%5c` — each also **double-encoded** (`%25`), because a proxy that decodes once hands the origin a second layer. 30 tokens; no spelling of the class can be missing. **2. The families a modern deployment leaks were absent**: php probe + php-cgi argument injection, Laravel/Symfony internals, CI/deploy config, credential stores, IaC state, build manifests, model-gateway endpoints (`/api/v1/models`, `/.litellm/`, `/.config/openai/`), LFI sinks (`/proc/self/`, `/fileview?file=`, `/fs/read?allowoutsideworkspace`) and debug handlers. ## Measured (scripts/crowdsec-shape-replay.py, added here) | list | attacker rows matched | 12k legitimate 2xx sample | |---|---|---| | current (42 tokens) | 1,249 / 3,300 = **37.85%** | 0 | | this PR (231 tokens) | 2,329 / 3,300 = **70.58%** | 1 | - The single "legit" hit is `GET /api/v1/settings/api` on `git.ymrtech.com` — a scanner URI, not a served route. - **clientsv daily e2e: 0 hits** of 178,602 requests from `11.0.0.8` over 7 days (`/api/login`, `/api/devices/*`, `/account/verify` — none matches a token). ## Deliberately not added Each of these is a filename a **real service serves**, measured against the fleet's own 2xx/3xx traffic: | token | real hits / 7d | why it is out | |---|---|---| | `/docker-compose.` | **670** | Forgejo serves public repo trees; the repo path is in the URI | | `/openapi.json` | **266** | same — `/ymrtech/ymrtech/src/branch/main/openapi.json` | | `/wp-config.` | 15 | same, inside commit pages | | `/settings.py` | 7 | same | | `/swagger`, `/swagger-ui` | 6 | Forgejo's own `/assets/js/swagger-ui.*.js`, `/swagger.v1.json` | | `/config.json` | — | Element fetches it on every page load (chat vhost) | | `/api/config`, `/api/settings` | — | Vaultwarden's live endpoints | This is the price of the code host and the app vhosts sharing one `fqdns` list: **filename-shaped tokens are unsafe, path-shaped tokens are safe.** Documented in the option description so the next person does not re-add them. ## What remains uncovered, and why it needs a different mechanism 971 of 3,300 (29%) still miss. They are almost all **frontend route guessing** — `/pricing`, `/settings/billing`, `/dashboard`, `/login`, `/billing` — which no path list can take without collateral risk (a real page could legitimately live at `/pricing`). The recorded campaign sent ~40 such probes per minute; the discriminator there is **volume from one source**, not path shape. That escalation is **not in this PR** on purpose: the published page `services/security/perimeter.md` states *"only the deception profile is enabled"*, and adding a ban profile for this scenario makes that sentence false. It is an owner decision (ban-on-volume from the shape rule, plus the copy change), recorded on card #1977. ## Verification - `nix eval` clean for `public`, `mail`, `vpn`; 231 unique tokens, no duplicates. - Behaviour of the filter is unchanged — including `maxUriLength` and the method list. - CI builds all three hosts that declare `requestShape.fqdns`.
crowdsec: request-shape — generate traversal spellings, extend the families
Some checks failed
Policy Gates / Worker-scope reaper worker signature (mutation-tested) (pull_request) Successful in 6s
PR base guard / Base drift / conflict check (pull_request) Successful in 7s
Policy Gates / Kanban pool capacity knob (runtime override + clamp, mutation-tested) (pull_request) Successful in 7s
Secret Scan / gitleaks scan (pull_request) Successful in 11s
Policy Gates / Sentinel pass budget contract (prompt forbids the full board walk, mutation-tested) (pull_request) Successful in 4s
foremerge intent (advisory) 2 of 2 changed path(s) have no live foremerge intent: hosts/common/optional/crowdsec.nix, scripts/crowdsec-shape-replay.py
Policy Gates / CI-scratch reaper class table (mutation-tested) (pull_request) Successful in 6s
Policy Gates / Fleet cache sweep class table (mutation-tested) (pull_request) Successful in 5s
NixOS Build Check / Scope changed deployable hosts (pull_request) Successful in 47s
NixOS Build Check / Flake input regression guard (pull_request) Successful in 6s
Repo Gates / Repo gates (script-only battery) (pull_request) Has been cancelled
Policy Gates / foremerge accept-order contract (real binary) (pull_request) Successful in 1m16s
Policy Gates / Scheduled foremerge reap command line (mutation-tested) (pull_request) Successful in 6s
Policy Gates / .forgejo/tests python suites (hermetic) (pull_request) Successful in 57s
NixOS Build Check / Hermes runtime gates (one eval of vpn's runtime) (pull_request) Successful in 1m37s
Policy Gates / Fleet control ledger (sealed profile fails the build, mutation-tested) (pull_request) Successful in 21s
NixOS Build Check / Build changed host closures (per-host budget) (pull_request) Successful in 3m30s
NixOS Build Check / Gate summary (pull_request) Successful in 0s
2894742824
`fleet/http-request-shape` matched 37.8% of one recorded campaign's requests
(2026-11-16..21, 3,300 requests, one source, 33 rotating spoofed crawler
user-agents). Two causes, both structural rather than a missing string:

1. Touring the traversal list by hand cannot work. The scenario matches
   Caddy's raw `request.uri` and the expression language has no
   percent-decoder, so `..%2F` is not `../`. The list carried `"/../"` and
   `"%2e%2e"` and the campaign walked past with `..%2F`, `.%2e/`, `..%5C`
   and `%2e%2e%2f`. Replace the two literals with `traversalTokens`:
   every spelling of "two dots then a separator" over a closed alphabet
   (`.`, `%2e`, overlong `%c0%ae`; `/`, `%2f`, `%5c`), each also
   double-encoded — 30 tokens, no spelling of the class can be absent.

2. The families the list was missing are the ones a modern deployment
   leaks: php probe and php-cgi argument injection, Laravel/Symfony
   internals, CI and deploy config, credential stores, IaC state, build
   manifests, model-gateway endpoints, LFI sinks, debug handlers and API
   description endpoints.

Deliberately NOT added, each because it is a file a real service serves
(measured against the fleet's own 2xx/3xx traffic): bare repo filenames
(`/docker-compose.` 670, `/openapi.json` 266, `/settings.py` 7,
`/wp-config.` 15 hits in 7 days, all inside Forgejo repo views and commit
pages, whose URIs carry the repo path), Forgejo's own swagger UI assets,
Element's `/config.json`, and Vaultwarden's `/api/config` and
`/api/settings*`.

Measured with scripts/crowdsec-shape-replay.py against the same fixture:
37.85% -> 70.58% of the campaign's requests, with 0 false positives on the
clientsv daily e2e (178,602 requests) and 1 on a 12,000-row 2xx sample (a
scanner's `/api/v1/settings/api`, not a served route). The residual is
frontend route guessing (`/pricing`, `/settings/billing`), which no path
list can take without collateral — that belongs to a volume rule, not to
this list.
Author
Collaborator

foremerge intent coverage (advisory) — 2 of 2 changed path(s) in ymrtech/nix-config#2942 have no live foremerge intent:

  • hosts/common/optional/crowdsec.nix
  • scripts/crowdsec-shape-replay.py

Coverage was decided by reading the repo's foremerge ledger (14 in-flight intent(s) considered) against this PR's changed paths — no branch or session name is involved, so a force-push does not change the answer. Paths that legitimately need no claim (docs, .md, flake.lock) are excluded.

This is advisory and does not block the merge. To clear it, publish intent for the paths above (foremerge intent publish --agent <your agent id> --task <task> --summary <what and why> --scope file:<path>=modify), or ignore it if the work genuinely collides with nobody.

**foremerge intent coverage (advisory)** — 2 of 2 changed path(s) in ymrtech/nix-config#2942 have no live foremerge intent: - `hosts/common/optional/crowdsec.nix` - `scripts/crowdsec-shape-replay.py` Coverage was decided by reading the repo's foremerge ledger (14 in-flight intent(s) considered) against this PR's changed paths — no branch or session name is involved, so a force-push does not change the answer. Paths that legitimately need no claim (docs, `.md`, `flake.lock`) are excluded. This is advisory and does **not** block the merge. To clear it, publish intent for the paths above (`foremerge intent publish --agent <your agent id> --task <task> --summary <what and why> --scope file:<path>=modify`), or ignore it if the work genuinely collides with nobody.
hermes force-pushed kb/crowdsec-shape-normalise from 2894742824
Some checks failed
Policy Gates / Worker-scope reaper worker signature (mutation-tested) (pull_request) Successful in 6s
PR base guard / Base drift / conflict check (pull_request) Successful in 7s
Policy Gates / Kanban pool capacity knob (runtime override + clamp, mutation-tested) (pull_request) Successful in 7s
Secret Scan / gitleaks scan (pull_request) Successful in 11s
Policy Gates / Sentinel pass budget contract (prompt forbids the full board walk, mutation-tested) (pull_request) Successful in 4s
foremerge intent (advisory) 2 of 2 changed path(s) have no live foremerge intent: hosts/common/optional/crowdsec.nix, scripts/crowdsec-shape-replay.py
Policy Gates / CI-scratch reaper class table (mutation-tested) (pull_request) Successful in 6s
Policy Gates / Fleet cache sweep class table (mutation-tested) (pull_request) Successful in 5s
NixOS Build Check / Scope changed deployable hosts (pull_request) Successful in 47s
NixOS Build Check / Flake input regression guard (pull_request) Successful in 6s
Repo Gates / Repo gates (script-only battery) (pull_request) Has been cancelled
Policy Gates / foremerge accept-order contract (real binary) (pull_request) Successful in 1m16s
Policy Gates / Scheduled foremerge reap command line (mutation-tested) (pull_request) Successful in 6s
Policy Gates / .forgejo/tests python suites (hermetic) (pull_request) Successful in 57s
NixOS Build Check / Hermes runtime gates (one eval of vpn's runtime) (pull_request) Successful in 1m37s
Policy Gates / Fleet control ledger (sealed profile fails the build, mutation-tested) (pull_request) Successful in 21s
NixOS Build Check / Build changed host closures (per-host budget) (pull_request) Successful in 3m30s
NixOS Build Check / Gate summary (pull_request) Successful in 0s
to f31d717436
Some checks failed
Secret Scan / gitleaks scan (pull_request) Successful in 17s
PR base guard / Base drift / conflict check (pull_request) Successful in 24s
Policy Gates / Worker-scope reaper worker signature (mutation-tested) (pull_request) Successful in 5s
Policy Gates / Kanban pool capacity knob (runtime override + clamp, mutation-tested) (pull_request) Successful in 4s
Policy Gates / Sentinel pass budget contract (prompt forbids the full board walk, mutation-tested) (pull_request) Successful in 3s
Policy Gates / CI-scratch reaper class table (mutation-tested) (pull_request) Successful in 4s
Policy Gates / Fleet cache sweep class table (mutation-tested) (pull_request) Successful in 4s
NixOS Build Check / Scope changed deployable hosts (pull_request) Successful in 20s
NixOS Build Check / Flake input regression guard (pull_request) Successful in 7s
Policy Gates / foremerge accept-order contract (real binary) (pull_request) Successful in 1m20s
Policy Gates / Scheduled foremerge reap command line (mutation-tested) (pull_request) Successful in 15s
foremerge intent (advisory) 2 of 2 changed path(s) have no live foremerge intent: hosts/common/optional/crowdsec.nix, scripts/crowdsec-shape-replay.py
Policy Gates / .forgejo/tests python suites (hermetic) (pull_request) Successful in 56s
NixOS Build Check / Hermes runtime gates (one eval of vpn's runtime) (pull_request) Successful in 1m44s
Policy Gates / Fleet control ledger (sealed profile fails the build, mutation-tested) (pull_request) Successful in 20s
Repo Gates / Repo gates (script-only battery) (pull_request) Successful in 5m31s
NixOS Build Check / Build changed host closures (per-host budget) (pull_request) Successful in 2m53s
NixOS Build Check / Gate summary (pull_request) Successful in 0s
NixOS Deploy / prep prep verdict for this dispatch (f31d717)
2026-11-25 15:08:36 -06:00
Compare
hermes merged commit e378eba2a6 into main 2026-11-25 15:16:25 -06:00
hermes deleted branch kb/crowdsec-shape-normalise 2026-11-25 15:16:27 -06:00
Sign in to join this conversation.
No reviewers
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
ymrtech/nix-config!2942
No description provided.