Skip to content

Add optional rate-limit on incoming pre-auth connections - #3356

Merged
t-bast merged 1 commit into
masterfrom
incoming-connection-rate-limit
Aug 26, 2026
Merged

Add optional rate-limit on incoming pre-auth connections#3356
t-bast merged 1 commit into
masterfrom
incoming-connection-rate-limit

Conversation

@t-bast

@t-bast t-bast commented Aug 14, 2026

Copy link
Copy Markdown
Member

Peers that open a connection but never complete the BOLT 8 handshake consume resources on our node (memory, file descriptors and CPU).

We now bound how many of those we're willing to keep around, with an eviction mechanism that lets honest peers eventually get connected.

Note that this only affects incoming connections: outgoing connections are not rate-limited, which means that peers with whom we have channels cannot be negatively affected by this mechanism since we'll actively reconnect to them.

This isn't a foolproof DDoS protection at all however: attackers that spam connection attempts can still severely delay or prevent honest new peers from connecting. It should be coupled with a DDoS protection layer at the cloud provider layer, where it is easier to do correctly and more efficient.

This mechanism can be disabled entirely by setting eclair.peer-connection.max-pending-incoming-connections = 0 in eclair.conf. The default values are high enough to have no impact on most deployments.

Disclaimer: this code was created with the help of Claude Opus 5, which was a very good rubber duck, reviewer and wrote most of the unit tests.

@t-bast
t-bast requested a review from pm47 August 14, 2026 13:57
Comment thread eclair-core/src/main/scala/fr/acinq/eclair/io/PeerConnection.scala
Peers that open a connection but never complete the BOLT 8 handshake
consume resources on our node (memory, file descriptors and CPU).

We now bound how many of those we're willing to keep around, with an
eviction mechanism that lets honest peers eventually get connected.

Note that this only affects incoming connections: outgoing connections
are not rate-limited, which means that peers with whom we have channels
cannot be negatively affected by this mechanism since we'll actively
reconnect to them.

This isn't a foolproof DDoS protection at all however: attackers that
spam connection attempts can still severely delay or prevent honest
new peers from connecting. It should be coupled with a DDoS protection
layer at the cloud provider layer, where it is easier to do correctly
and more efficient.
@t-bast
t-bast force-pushed the incoming-connection-rate-limit branch from 53125a9 to f7c5a2a Compare August 21, 2026 11:25
@t-bast

t-bast commented Aug 21, 2026

Copy link
Copy Markdown
Member Author

Trivial rebase to fix the merge conflict (on release notes).

@pm47 pm47 left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

LGTM.

Note that in a cluster setup, the max-pending-incoming-connections value applies independently for each front node.

@t-bast
t-bast merged commit a2fe6c7 into master Aug 26, 2026
1 check passed
@t-bast
t-bast deleted the incoming-connection-rate-limit branch August 26, 2026 13:00
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.

2 participants