p2p: a per-peer guard drops floods and bans peers that send invalid gossip
Per relaying peer and minute: over 1200 messages are dropped unread (no penalty); 20 invalid ones (bad signature, too little work, garbage) ban the peer for an hour, closing the connection and blacklisting it in gossip. Ignored messages (clock trouble, unknown listing) never count. In the simulator the attacker is cut off from every node it reached and honest listings still arrive 50 of 50; the message-flood scenario now uses a second attacker. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01AeFqV96dVeBX94inzcgZKw
This commit is contained in:
+10
-3
@@ -696,9 +696,16 @@ Findings (see "What is left" in SPECS.md for the open ones):
|
||||
changes it; `-1` restores libp2p's default), and the table above shows the
|
||||
result. Not measured: the memory of a seed holding 1000 connections against
|
||||
the 512 MiB limit in `k8s/base/statefulset.yaml`.
|
||||
2. **No peer scoring.** The attacker stayed connected to all 10 nodes it
|
||||
dialed after sending 500 bad messages. Nothing was stored, but each message
|
||||
still cost every node its validation work.
|
||||
2. **Peer limits are crude.** The first run had no peer scoring: the attacker
|
||||
stayed connected to all 10 nodes it dialed after 500 bad messages. Now every
|
||||
node counts, per relaying peer and minute, the messages it gets (over 1200
|
||||
are dropped unread, without penalty) and the invalid ones (20 get the peer
|
||||
banned for an hour: closed connection, gossip blacklist; `internal/p2p/guard.go`).
|
||||
In the sim the attacker was cut off from all 6 nodes it reached and honest
|
||||
listings still arrived 50 of 50. What it does not stop: an attacker with many
|
||||
peer IDs (a ban costs it nothing but a new key), a peer that sends only
|
||||
valid but unwanted records, or one that stays under the limits. The ban is
|
||||
per node, not shared, and covers gossip only, not the sync protocol.
|
||||
3. **The DHT is only as good as its servers.** Only publicly reachable nodes
|
||||
serve it. With every seed gone, a newcomer whose remembered peers are all in
|
||||
another region found nobody (0 of 114 listings), and one that remembers no
|
||||
|
||||
Reference in New Issue
Block a user