From 71928fa2280e94532a96c406ea18095f80070a7e Mon Sep 17 00:00:00 2001 From: Duke Date: Tue, 14 Mar 2023 14:42:39 -0400 Subject: [PATCH] Randomize order of processing messages from peers --- src/net.cpp | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/net.cpp b/src/net.cpp index e8f693c11..d84a28710 100644 --- a/src/net.cpp +++ b/src/net.cpp @@ -1945,6 +1945,11 @@ void ThreadMessageHandler() bool fSleep = true; + // Randomize the order in which we process messages from/to our peers. + // This prevents attacks in which an attacker exploits having multiple + // consecutive connections in the vNodes list. + random_shuffle(vNodesCopy.begin(), vNodesCopy.end(), GetRandInt); + BOOST_FOREACH(CNode* pnode, vNodesCopy) { if (pnode->fDisconnect)