Skip to content

fix(beacon): add per-nodeID rate limit to Discover endpoint updates (PILOT-334)#14

Open
matthew-pilot wants to merge 1 commit into
mainfrom
openclaw/pilot-334-20260530-032500
Open

fix(beacon): add per-nodeID rate limit to Discover endpoint updates (PILOT-334)#14
matthew-pilot wants to merge 1 commit into
mainfrom
openclaw/pilot-334-20260530-032500

Conversation

@matthew-pilot
Copy link
Copy Markdown
Collaborator

Summary

Add per-nodeID rate limit to Discover endpoint updates to prevent endpoint flapping by an attacker controlling a single registered nodeID.

Problem

handleDiscover() (server.go:504) calls s.nodes.Upsert(nodeID, remote, ...) on every Discover message with zero per-nodeID rate limit. An attacker who controls a registered nodeID can send rapid Discover messages to continuously overwrite the endpoint — confusing the gossip layer until the next reaper pass.

Fix

Mirrors the existing punch-request rate-limit pattern (SEC-026, server.go:538-552):

  • Adds discoverRateMu + discoverRateLast fields to Server struct
  • Constant discoverMinInterval = 30s
  • Rate-limited Discovers still receive the reply with their observed address — only the Upsert is skipped
  • Stale entries cleaned in reapStaleNodes() alongside punch-rate cleanup

Changes

  • 1 file: server.go (+29/-4)

Testing

  • go build ./...
  • go test ./... ✅ (2 pre-existing flaky failures unrelated to this change)
  • Discover-specific tests all pass (TestBeaconDiscoverExact5Bytes, TestBeaconDiscoverLessThan5Bytes, FuzzBeaconHandlePacket)
  • Tier: small (1 file, 33 LoC)

…PILOT-334)

handleDiscover now enforces a minimum 30s interval between endpoint
updates from the same nodeID, preventing a single attacker-controlled
nodeID from flapping its endpoint via rapid Discover messages.

Mirrors the existing punch-request rate-limit pattern (SEC-026):
server.go:59-60 (discoverRateMu + discoverRateLast), constant at
server.go:139 (discoverMinInterval = 30s), and cleanup in
reapStaleNodes() server.go:961-968.

Rate-limited Discovers still receive the reply with their observed
address — only the Upsert is skipped.
@codecov
Copy link
Copy Markdown

codecov Bot commented May 30, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.

📢 Thoughts on this report? Let us know!

@matthew-pilot
Copy link
Copy Markdown
Collaborator Author

🦾 Matthew PR Status — #14

Title: fix(beacon): add per-nodeID rate limit to Discover endpoint updates (PILOT-334)
Status: OPEN | Mergeable: MERGEABLE
Author: @matthew-pilot (matthew-pilot bot)
Created: 2026-05-30T03:38:03Z
Branch: openclaw/pilot-334-20260530-032500main
Changes: +29/-4 across 1 file

Tickets

🔗 PILOT-334

Labels

None

Files Changed

  • server.go (+29/-4)

Next Actions

  • Explain: /pr explain #14 — detailed analysis
  • Canary retry: /pr retry-canary #14 (if CI failed)
  • Fix & update: /pr fix #14 <instructions>
  • Rebase: /pr rebase #14
  • Close: /pr close #14 <reason>

🦾 Auto-generated status check by matthew-pr-worker

@matthew-pilot
Copy link
Copy Markdown
Collaborator Author

🦾 Matthew PR Explain — #14

What this PR does

fix(beacon): add per-nodeID rate limit to Discover endpoint updates (PILOT-334)

Scope

  • Files: 1 file
  • Delta: +29/-4 lines
  • Labels: none
  • Mergeable: MERGEABLE

Tickets

🔗 PILOT-334

Files

  • server.go (+29/-4)

Review Notes

  • This is an automated code-maintenance PR from matthew-pilot
  • Operator review required before merge
  • Check CI status and canary results above

🦾 Auto-generated explain by matthew-pr-worker

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