sui icon indicating copy to clipboard operation
sui copied to clipboard

[RPC] Enforce rate limiting

Open 666lcz opened this issue 3 years ago • 9 comments
trafficstars

Rate-limiting by IP address

666lcz avatar Mar 30 '22 16:03 666lcz

@patrickkuo , would you like to take this one for the JSON-RPC server?

666lcz avatar Apr 18 '22 01:04 666lcz

@patrickkuo , assigning this to you for now since you implement the RPC endpoint. We should implement the rate limiting as a middleware. Let me know if you are not the right owner

666lcz avatar Apr 20 '22 20:04 666lcz

What's the priority of this issue? I can work on this after the OpenRPC doc and schema works.

patrickkuo avatar Apr 20 '22 21:04 patrickkuo

I believe this one has a higher priority than the doc and schema, because we don't want the server to be overwhelmed by malicious attackers or a heavy application cc @todd-mystenlabs

666lcz avatar Apr 20 '22 23:04 666lcz

jsonrpsee have build in resource limiting capability, can use this to enforce rate limiting very easily https://github.com/paritytech/jsonrpsee/blob/20e6e5de40214e0b88e475d87bf14e465123eaba/core/src/server/resource_limiting.rs#L54-L86

patrickkuo avatar Apr 21 '22 00:04 patrickkuo

Talk to @bmwill / @mystenmark re: HAproxy.

Talk to @huitseeker re: application-layer rate limiting.

todd-mystenlabs avatar Apr 21 '22 17:04 todd-mystenlabs

For devnet, we need something very simple given the tight time frame. I suggest:

  • have some way to see where a DoS attack is coming from
  • have a script or well-documented method for adding the offending IP(s) to a firewall rule.

mystenmark avatar Apr 21 '22 20:04 mystenmark

Do we want to build this into the JSON-RPC server?

Currently jsonrpsee only support very basic "resource limiting" functionality, it can limit number of concurrent requests but cannot enforce limit by IP, and the middleware api provided does not contain request header/ IP address (looks like they have plan to add it but there are no timeline).

Alternatively can we use something like AWS WAF?

patrickkuo avatar Apr 21 '22 21:04 patrickkuo

I think long-term we want something intelligent that the network can use that would help any operator. Short-term (for devnet launch), we have a few options that will apply to our own running node: (1) we can put HAproxy in front of this (@bmwill / @mystenmark); and (2) we may have additional protection via external means.

todd-mystenlabs avatar Apr 22 '22 14:04 todd-mystenlabs