Skip to content
This repository has been archived by the owner on May 26, 2023. It is now read-only.

Latest commit

 

History

History
31 lines (18 loc) · 1.4 KB

059.md

File metadata and controls

31 lines (18 loc) · 1.4 KB

RAinUsTa

low

P2P should have a token bucket rate limiter per peer

Summary

Currently, the concurrency of the gossip block validation is set at 4, see code snippet linked. There isn't a per peer rate limit, and the gossip queue is set to size 256. A very gossippy peer can flood the node and hog the 4 block validation spots by sending a variety of different block messages.

A healthy trust worth peer will only gossip message roughly once per block, but a malicious peer can choose to gossip continuously.

Vulnerability Detail

If a malicious peer broadcasts uniquely signed blocks (even if it is not signer) at a rate that exceeds the 4 concurrent block validation's throughput, then it will start clogging the message validation queue of 256, and other peer's messages would be missed.

The usual way to enforce fairness between peers is to have rate limiting so that no single peer can drown out / clog the validation queue.

Impact

When the validation queue is filled up, other good peer's messages will be ignored. Ideally, the messages are processed with fairness across peers.

Code Snippet

https://github.com/sherlock-audit/2023-01-optimism/blob/main/optimism/op-node/p2p/gossip.go#L387-L390

Tool used

Manual Review

Recommendation

Implement a per-peer rate limiter such that each peer is only allowed to broadcast N messages per second, and any additional messages beyond that is ignored as spam.