RPC: Connection limit and fail-ban protection (hardening pt.2) - #684
RPC: Connection limit and fail-ban protection (hardening pt.2)#684SyntheticBird45 wants to merge 1 commit into
Conversation
7ee1e03 to
1296a55
Compare
1296a55 to
6e0ed9a
Compare
|
The counter never decays, so this is a 3s ban every 15th failure over the nodes whole uptime. Maybe worth bounding the strikes to a window of a minute or so? |
3a1c6c3 to
814eff4
Compare
|
@redsh4de , I actually changed the semantic a little bit. There is now two There is no explicit list of what IP addresses are currently banned because looking up into DelayQueue is O(n) while in practice keeping the current HashMap O(1) (in most cases). So an IP address is effectively banned if its failure reached
Constants can be tweaked but at the moment, an IP address will keep its failure count for 5 second, this timer is reset everytime its increased, and erased when the IP is added to the unban queue. |
814eff4 to
9c8c03d
Compare
|
Needs rebase |
9c8c03d to
3943b7e
Compare
|
Rebased |
3aa37e6 to
58d362a
Compare
09b58df to
a8bc571
Compare
a8bc571 to
27a0e50
Compare
| info!( | ||
| restricted, | ||
| address = %address, | ||
| address = %addr, |
There was a problem hiding this comment.
| address = %addr, | |
| address = %addr, | |
| port = %port, |
Add a per-IP connection limit layer to the RPC servers. Every type (public, private or loopback) of IP addresses have a configurable maximum amount of simultaneous connection. The node also have a configurable total maximum amount of simultaneous connections. Whenever one limit is exceeded, the connection is dropped. Add a short-ban mechanism against IP addresses which fails to be served more than 15 times. This is a protection against malicious clients spamming garbage instead of parseable HTTP requests. Co-authored-by: redsh4de <25299353+redsh4de@users.noreply.github.com>
27a0e50 to
a4aceae
Compare
What
This PR follows and is based upon #675
It adds per-IP type simultaneous connection limits similar to monero-project/monero#9765. This PR extends this mitigation by adding a distinction between loopback addresses and private addresses, as well as enabling user to exclude specific IP addresses from any restriction if needed (main production case would be reverse proxies).
This PR also adds a short-term ban mechanism for IP addresses that repeatedly fails to be served by the hyper stack (axum erros are unaccounted). Said banned IP addresses are immediately dropped until they are unbanned.