Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Security: rate-limit outbound messages, Credit: Equilibrium #2153

Closed
3 tasks
Tracked by #3247 ...
teor2345 opened this issue May 14, 2021 · 2 comments
Closed
3 tasks
Tracked by #3247 ...

Security: rate-limit outbound messages, Credit: Equilibrium #2153

teor2345 opened this issue May 14, 2021 · 2 comments
Labels
A-network Area: Network protocol updates or fixes C-security Category: Security issues I-remote-node-overload Zebra can overload other nodes on the network I-unbounded-growth Zebra keeps using resources, without any limit S-blocked Status: Blocked on other tasks S-needs-investigation Status: Needs further investigation

Comments

@teor2345
Copy link
Contributor

teor2345 commented May 14, 2021

TODO before starting

Find good rate-limits, and work out if the rates should be fixed or dynamic.

Motivation

Zebra's message handling code is complex, so it might be possible for it to get stuck in a request-response loop. To limit the impact of these loops, we should rate-limit Zebra's outbound messages to each peer.

A similar issue was reported by Niklas Long of Equilibrium.

Analysis

There are some tricky engineering tradeoffs here:

  • if the limit is too low, then Zebra is very slow to sync
  • if the limit is too high, we're not protected from denial of service
  • the best limit can be different for different message types, depending on how large or important they are

So we need to find good rate-limits, and work out if the rates should be fixed or dynamic.

Suggested Solution

  • Analyse the maximum message rate per peer that Zebra reaches in optimal syncing conditions (Testnet, local network)
  • Calculate a reasonable per-peer rate limit that won't slow down syncing too much
  • Add a rate limit layer to each Client's outbound message queue

Alternatives

We could restrict rate-limiting to identical messages. We'd need to store message contents, hashes, or types.

We could also rate limit inbound messages - they're currently limited via load-shedding.

We could make rate limits dynamic.

We could use different rate-limits for different message types, or for requests and responses.

@teor2345 teor2345 added A-rust Area: Updates to Rust code S-needs-triage Status: A bug report needs triage P-Medium C-security Category: Security issues I-heavy Problems with excessive memory, disk, or CPU usage I-unbounded-growth Zebra keeps using resources, without any limit I-remote-node-overload Zebra can overload other nodes on the network A-network Area: Network protocol updates or fixes labels May 14, 2021
@teor2345 teor2345 changed the title Security: rate-limit outbound messages, credit: Niklas Long of Equilibrium Security: rate-limit outbound messages, Credit: Equilibrium May 14, 2021
@mpguerra mpguerra removed the S-needs-triage Status: A bug report needs triage label May 19, 2021
@teor2345 teor2345 added S-blocked Status: Blocked on other tasks S-needs-investigation Status: Needs further investigation and removed A-rust Area: Updates to Rust code I-heavy Problems with excessive memory, disk, or CPU usage labels Dec 8, 2021
@teor2345
Copy link
Contributor Author

teor2345 commented Dec 8, 2021

Before we start this ticket, we need to find good rate-limits, and work out if the rates should be fixed or dynamic.

@teor2345
Copy link
Contributor Author

Network behaviour is good enough for now.

@teor2345 teor2345 closed this as not planned Won't fix, can't repro, duplicate, stale Aug 26, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-network Area: Network protocol updates or fixes C-security Category: Security issues I-remote-node-overload Zebra can overload other nodes on the network I-unbounded-growth Zebra keeps using resources, without any limit S-blocked Status: Blocked on other tasks S-needs-investigation Status: Needs further investigation
Projects
None yet
Development

No branches or pull requests

2 participants