feat(edge): reputation ladder policy - rung table + rung-3 slow budget (NCFG#1991) #2996
No reviewers
Labels
No labels
backlog
bug
enhancement
in-progress
library
needs-rebase
review
todo
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
ymrtech/nix-config!2996
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "kb/NCFG-1991-reputation-ladder-policy"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Card nix-config#1991, decomposed from #1984. Builds on the merged scorer from #2949 (that PR is the propose-only daemon; this is the policy it proposes into).
What this adds
fleet.crowdsec.enforcement.reputation(hosts/common/optional/crowdsec.nix) - the ladder as one table (rungs[]= score threshold, action, duration,enabled), plus one LAPI profile generated per enabled ban rung.<scenario>/rung-<n>(fleet/request-shape-reputation/rung-4|5|6). One scenario name can carry only one duration, so a ladder written as scenarios would flatten 15m/1h/6h into whichever profile matched first. Derived names also make the rung legible incscli decisions list.banRungsandscenariosare read-only derived options so the ladder is inspectable fromnix evalwithout reading the file.BANDSinpackages/reputation-ladder/reputation_ladder.pyare the same numbers written twice, and they agree as shipped.fleet.edgeLimits.slowRung(hosts/common/global/edge-limits.nix) - rung 3's budget: 250ms-1500ms added latency on 35% of matching requests, rendered intoblockFornext to the rate limit, exposed asdirectiveso the exact Caddyfile line is readable from eval.It ships
enable = false, on evidence. The pinned caddy 2.11.4 build carries no delay handler -caddy list-modules | grep http.handlerson/nix/store/r2sqdbgkfp2vmnmg4kx0vv1pi9qgbwh8-caddy-2.11.4:acme_server, authentication, copy_response, copy_response_headers, encode, error, file_server, headers, intercept, invoke, log_append, map, metrics, push, request_body, reverse_proxy, rewrite, static_response, subroute, templates, tracing, vars. Nodelay/delay_random. Turning the option on without that module inservices.caddy.packagefailscaddy validateat deploy, so the budget is declared with its single consumer and the gap is written on the option.Also documented on that option, because it is the trap: the budget is uniform. Caddy cannot see a caller's reputation score, so a per-source rung 3 needs a bouncer that answers "is this IP slowed" (crowdsec's caddy bouncer is not installed) or a per-request lookup. Enabling this does not make the ladder reach Caddy.
hosts/vpn/default.nix-enforcement.reputation.enable = trueon the LAPI. A rung ban is written by a profile and profiles are the LAPI's; the module renders the list on every host but only the LAPI's engine turns an alert into a decision. The table itself is not restated there.Safety
The chain that keeps a reputation ban off our own infrastructure is the existing postoverflow whitelist (
fleet/whitelist-own-infrastructure-> mesh, loopback,fleet.publicAddresses), which sets remediation false before any profile is consulted. An eval assertion refusesreputation.enableunless11.0.0.0/24is still inwhitelistCidrs, so the guarantee cannot be edited away silently.Nothing can fire today: the scorer is dry-run and posts no alerts. What this installs is the profile set.
Eval evidence (base
5c18dd0f, ownerhermes)Toplevel drvPath forces every assertion on both hosts; the five new ones evaluate
trueonpublicandvpn.Live verification (after deploy)
ssh vpn cscli profiles list->fleet_reputation_rung_4/5/6present with 15m/1h/6h; norung_7/rung_8.cscli decisions add --ip 192.0.2.199 --duration 1m --scenario fleet/request-shape-reputation-> appears incscli decisions list -o jsonwith that scenario;cscli decisions delete --ip 192.0.2.199removes it.11.0.0.1must never hold a decision (whitelist + assertion above).Out of scope, stated
--enforcestill refuses) - the remaining half of enforcement, and it needs a machine credential decision from the owner.