Submitted by eighty, also found by d3e4, eighty, Lambda, and eighty
In contracts/HolographOperator.sol#crossChainMessage, each Operator is selected by:
This creates an unintended bias since the first criterion (the random) is used for both selecting the pod and selecting the Operator, as explained in a previous issue (M001-Biased distribution). In this case, an attacker knowing this flaw can continuously monitor the contracts state and see the current number of pods and Operators. Accordingly to the documentation and provided flow:
Honest Operators may feel compelled to leave the protocol if there are no financial incentives (and lose funds in the process), which can also increase the odds of leaving the end-users at the hands of a malicious Operator.
Consider the following simulation for 10 pods with a varying number of operators follows (X  does not apply):
At this stage, an attacker Mallory joins the protocol and scans the protocol (or interacts with - e.g. getTotalPods, getPodOperatorsLength). As an example, after considering the potential benefits, she chooses pod P9 and sets up some bots [B1, B2, B3]. The number of Operators will determine the odds, so:
And then:
4.1 If she is not chosen, she will assume the position of the chosen Operator, and deploys B2 to maintain the odds of P9 and controls 2/3 of the pod.
4.2 If she is chosen, she chooses between employing another bot or waiting to execute the job to back to the pod (keeping the original odds).
5. She can then iterate multiple times to swap to the remainder of possible indexes via step 4.1.
Alternative timeline (from previous 3.):
There are a lot of ramifications and possible outcomes that Mallory can manipulate to increase the odds of being selected in her favor.
As stated in M001-Biased distribution, use two random numbers for pod and Operator selection. Ideally, an independent source for randomness should be used, but following the assumption that the one used in L499 is safe enough, using the most significant bits (e.g. random >> 128) should guarantee an unbiased distribution. Also, reading the EIP-4399 could be valuable.
Additionally, since randomness in blockchain is always tricky to achieve without an oracle provider, consider adding additional controls (e.g. waiting times before joining each pod) to increase the difficulty of manipulating the protocol.
And finally, in this particular case, removing the swapping mechanism (moving the last index to the chosen operators current index) for another mechanism (shifting could also create conflicts with backup operators?) could also increase the difficulty of manipulating a particular pod.
gzeon (judge) commented:
ACC01ADE (Holograph) confirmed and commented:
gzeon (judge) commented:
Trust (warden) commented:
gzeon (judge) commented:
