Skip to content

fix(monitor): a connection attempt the firewall rejects is a WARNING; a burst is HIGH - #1169

Merged
mensfeld merged 4 commits into
masterfrom
fix/52809-rejected-connection-warning
Nov 26, 2026
Merged

mensfeld merged 4 commits into
masterfrom
fix/52809-rejected-connection-warning

Conversation

@coipond-coder

@coipond-coder coipond-coder Bot commented Nov 26, 2026 •

Copy link
Copy Markdown
Contributor

Redmine: 52809

Severity of a flagged network connection now follows the firewall verdict (PermittedDestination), in both monitors. Covers #995.

  • Rejected by the firewall (private address, or outside the allowlist): WARNING, audited and alerted, no pause. Description ends with (rejected by the firewall).
  • Rejected attempts to [monitoring] rejected_burst_threshold (default 10) distinct destinations (ip:port) within rejected_burst_window_sec (default 60): HIGH (pause under auto_pause_on_high).
  • Permitted but unexpected stays HIGH: no verdict available, a TCP socket past SYN_SENT (procfs) or a TCP packet other than a SYN without ACK (nft): its handshake got through, a suspicious port on a permitted destination. CRITICAL checks (metadata, C2 ports) are unchanged.

Shared tracker: monitor.RejectedBurst (process monitor Detector, nft NetworkDetector). The responder dedupe key includes the level, so a burst HIGH after a WARNING for the same destination is not deduplicated.

Tests

  • Unit: single rejected attempt (WARNING, responder with auto-pause does not pause), burst (HIGH), permitted unexpected (HIGH), UDP connected socket, CRITICAL unchanged, window pruning, defaults; nft detector the same.
  • E2e (Incus, CI only): new test_rejected_burst_high.py; test_allowlist_mode_rfc1918_flagged.py (WARNING, container keeps running with auto_pause_on_high = true), test_restricted_mode_rfc1918_flagged.py and nft test_lan_access_flagged_in_restricted_mode expect WARNING now.

Performance impact

Off hot paths (monitor daemons). RejectedBurst.Rate runs once per firewall-rejected attempt. It keeps a FIFO of attempts beside the map and prunes expired ones from its front: O(1) amortized, about 0.5 us per call at 30000 distinct destinations (BenchmarkRejectedBurst_Scan). Memory is bounded by the attempts within the window.

@coipond-coder coipond-coder Bot added bug Something isn't working security Security fixes and hardening labels Nov 26, 2026
@coipond-coder
coipond-coder Bot marked this pull request as ready for review November 26, 2026 17:10
@coipond-coder
coipond-coder Bot requested a review from mensfeld as a code owner November 26, 2026 17:10
@mensfeld
mensfeld merged commit c95af6f into master Nov 26, 2026
32 checks passed
@mensfeld
mensfeld deleted the fix/52809-rejected-connection-warning branch November 26, 2026 18:28
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working security Security fixes and hardening

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant