Skip to content

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

Open
t-bast wants to merge 1 commit into
masterfrom
incoming-connection-rate-limit
Open

Add optional rate-limit on incoming pre-auth connections#3356
t-bast wants to merge 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

when(AUTHENTICATING) {
case Event(TransportHandler.HandshakeCompleted(remoteNodeId), d: AuthenticatingData) =>
cancelTimer(AUTH_TIMER)

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.

What prompted the moving of this to BEFORE_INIT?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Because we may otherwise stay stuck in BEFORE_INIT indefinitely! We need to timeout the connection if we don't move out of BEFORE_INIT as well, the AUTH_TIMER must cover both AUTHENTICATION and BEFORE_INIT.

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).

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