Skip to content

fix(security): Stop blocking legitimate clients on their first request#176

Merged
nfebe merged 1 commit into
mainfrom
fix/security-false-block-and-trace
Jul 16, 2026
Merged

fix(security): Stop blocking legitimate clients on their first request#176
nfebe merged 1 commit into
mainfrom
fix/security-false-block-and-trace

Conversation

@nfebe

@nfebe nfebe commented Jul 16, 2026

Copy link
Copy Markdown
Contributor

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.

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.
@sourceant

sourceant Bot commented Jul 16, 2026

Copy link
Copy Markdown

Code Review Summary

The 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

  • Legitimate CLI tools and scripts are no longer blocked after a single event.
  • IP blocks now record the specific trigger (rule, path, and counts) for better troubleshooting.
  • Improved thread safety during detection threshold checks.

💡 Minor Suggestions

  • Optimized slice allocation in the path summarization helper.

🚨 Critical Issues

  • Restore the nuclei scanner to the ScannerUserAgents list in internal/security/rules.go as it was removed unintentionally.

@sourceant sourceant Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Review complete. No specific code suggestions were generated. See the overview comment for a summary.

@nfebe
nfebe merged commit 5d7b7fc into main Jul 16, 2026
6 checks passed
@nfebe
nfebe deleted the fix/security-false-block-and-trace branch July 16, 2026 22:35
@nfebe nfebe mentioned this pull request Jul 16, 2026
42 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant