AleoNet / snarkOS

A Decentralized Operating System for ZK Applications
http://snarkos.org
Apache License 2.0
4.1k stars 2.57k forks source link

[HackerOne-2485380] Prevent DOS by limiting sent requests to one per peer #3257

Closed raychu86 closed 1 month ago

raychu86 commented 1 month ago

Motivation

This PR aims to solve a DOS vector that is outlined in https://github.com/AleoNet/snarkOS/issues/3243, where a malicious validator can fill up the max_redundant_requests and not respond. This PR adjusts the rules so that we only send one request for that item to a given peer at a time.

This means that max_redundant_requests can only be reached with unique peers. And because max_redundant_requests is based on the availability threshold you can expect at least one node to be honest.

Test Plan

A test has been added to ensure that the functionality of contains_peer_with_sent_request is as intended.

ghostant-1017 commented 1 month ago

LGTM!