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

Unbounded channels and DoS attacks #664

Closed
pavel-kokolemin opened this issue Feb 1, 2023 · 2 comments · Fixed by #1186
Closed

Unbounded channels and DoS attacks #664

pavel-kokolemin opened this issue Feb 1, 2023 · 2 comments · Fixed by #1186
Labels
p2p p2p related issues security Security-related issues
Milestone

Comments

@pavel-kokolemin
Copy link
Contributor

We use unbounded channels in p2p. This makes the node more vulnerable to DoS attacks when the used memory grows without bounds (if peers overload the node with requests). It would be good to do something about this.

Maybe we can can apply back-pressure on the connected peers, when we read from the network socket?
Check how many pending requests there are, and stop reading from the socket until the number is below some threshold.
Something like this:

response = self.cmd_rx.recv() {
    // Request was processed, send response to the peer...
    request_count -= 1;
},
// Read from the socket if only there is some free capacity
request = self.socket.recv(), if request_count < 10 => {
    // New request received, send it to backend...
    request_count += 1;
}
@pavel-kokolemin pavel-kokolemin added the p2p p2p related issues label Feb 1, 2023
@TheQuantumPhysicist
Copy link
Contributor

Another idea is to monitor the size of the channel queues and how big they grow, and test that against DoS attacks.

@pavel-kokolemin
Copy link
Contributor Author

We now use bounded channels to read network messages and send them to the BlockSyncManager tasks (PR #973). I think this should solve most of the problems with the unbounded channels.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
p2p p2p related issues security Security-related issues
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants