fix(security): Stop blocking legitimate clients on their first request#176
Merged
Conversation
The auto-blocker treated general-purpose HTTP clients as attack scanners and blocked them on sight, so a visitor using curl, a Go or Python script, an uptime monitor, or a webhook sender was locked out on its very first request, no repeated probing needed. Scanner detection now fires only on tools that identify themselves as attack scanners; ordinary clients are held to the same volumetric thresholds as everyone else, so they are blocked only if they actually probe. Every auto-block now records why it happened: the rule that tripped, the count, and the paths involved, instead of one fixed "suspicious activity" string. An operator reviewing a blocked IP can see the trace that led to the block.
Code Review SummaryThe PR successfully implements a more nuanced blocking strategy and adds traceability to security events. It fixes the reported issue of legitimate tools being blocked on their first request. However, one intended scanner was accidentally removed from the immediate blocklist. 🚀 Key Improvements
💡 Minor Suggestions
🚨 Critical Issues
|
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.
The security module classified any request from a general-purpose HTTP client (curl, wget, python-requests, go-http-client, httpx) as a scanner, and a scanner is blocked immediately on the first event with no threshold. So a visitor using curl, a Go or Python script, an uptime monitor, or a webhook sender was locked out on a first request. That is what #153 reports as blocking after a single 404: the 404 is what surfaced the request to the analyzer, and the user-agent is what escalated it straight to a block.
Scanner detection now matches only tools that name themselves as attack scanners (nikto, sqlmap, nuclei, and the like). General-purpose clients fall through to the existing volumetric thresholds, so they are blocked only if they actually probe: repeated 404s, auth failures, or path scanning.
The issue also asked for a trace on each blocked IP. Auto-blocks all recorded the same fixed "suspicious activity" string; they now record which rule tripped, the count, and the paths involved. Alongside the existing per-IP event log, an operator can see what led to the block.
Regression tests drive the real ingest path: a single 404 from curl or a Go/Python client is not blocked, a named scanner still is, and the stored block reason carries the trigger.
UI counterpart: flatrun/ui#83 surfaces the per-IP event trace behind a block.