Repository navigation
Conversation
added 2 commits
September 29, 2026 12:23
A per-IP flood (DDoS001) now bans the source address for ddos.ban_seconds (default 10m), and an address that keeps producing bot-like requests is banned too. Bans are time-limited, reversible, logged, and raise an alert; loopback and trusted-proxy addresses are never auto-banned. The ban request survives into the final decision — a high accumulated score used to turn a flood into a plain challenge and drop the ban. Missing User-Agent (BOT001) is now challenged instead of only monitored. DDoS and bot thresholds are configurable, and a negative ban value disables auto-ban. The client IP is read from CF-Connecting-IP when the peer is a trusted proxy, so behind Cloudflare the WAF sees the real visitor rather than the Cloudflare edge; rate limits, auto-bans, and the audit log are accurate. Verified live: a 40-request burst through the public host banned the source with "DDoS001 HTTP Flood - IP" for 10m and surfaced it in /api/v1/bans.
The API base is now the relative "/api/v1", so new URL() threw and the CSP became "connect-src 'self' /api/v1" — a path is not a valid CSP source, so the browser logged an error and ignored it. Only add an origin when the base is an absolute URL; a relative base is covered by 'self'.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
A DDoS flood was only answered
429and the source was never banned; bot-like traffic that was clearly not a browser was only monitored. This adds time-limited, reversible auto-banning for both, and fixes the client IP the WAF acts on behind Cloudflare.Type of change
Severity
What changed
DDoS001) bans the source address forddos.ban_seconds(default 10m) instead of only returning429.bot.auto_ban_afterbot-like requests withinbot.auto_ban_window_secis banned forbot.auto_ban_seconds. A missing User-Agent (BOT001) is now challenged, not just monitored.ddos.per_ip_rate/per_endpoint_rate/global_rate/ban_secondsandbot.auto_ban_after/auto_ban_window_sec/auto_ban_seconds. A negative ban value disables auto-ban. Per-IP default lowered from 100/s to 30/s.finalDecisionnow carries the ban request through even when the accumulated threat score would otherwise turn the flood into a generic challenge (which silently dropped the ban).CF-Connecting-IPis read from a trusted peer, so the WAF acts on the real visitor rather than the Cloudflare edge — rate limits, auto-bans, and the audit log are accurate again.Checklist
go build ./...passesgo vet ./...passesgofmt -l -s .shows no issuesAdditional context
New tests cover: DDoS flood/no-false-positive/disabled, bot real-browser/repeat-offender/disabled, client-IP CF-Connecting-IP preference and spoof rejection, and an end-to-end handler test (flood → ban →
BAN001). The browser fuzz suite now excludes the rate limiter, since a 19k-request harness is a flood by definition and the limiter is covered by its own tests.Verified live: a 40-request burst through the public host auto-banned the source with
DDoS001 HTTP Flood - IPfor 10m and it appeared in/api/v1/bans.