Security: Limit the number of inbound peer connections in the listener task #1851
Description
Motivation
Zebra has no limit on the number of open inbound connections from other peers. This is a remote distributed denial of service risk, if an attacker can make other nodes connect to Zebra.
We're not currently seeing this attack on the network, but it might be easy for malicious nodes to trigger. So we should fix it soon.
Suggested Design
In accept_inbound_connections
, limit the number of inbound connections to peerset_initial_target_size
. This applies the connection limit as soon as Zebra gets control of the accepted connection from tokio
.
peerset_initial_target_size
is an existing zebra-network
config. It's used to initialise the CandidateSet
's outbound peer connection demand.
Edge Cases
Zebra should check and increase the connection limit as early as possible.
Zebra should drop any resources used by rejected connections as soon as possible.
Activity