Submitted by CertoraInc, also found by 0x1337, cccz, danb, dipp, dirk_y, hubble, jah, and WatchPug
Gravity.sol#L276-L358
The updateValset function dont check that the sum of the powers of the new validators in the new valset is greater than the threshold, which can lead to unwanted behavior.
There are 2 main problems that can occur in that situation:
The second case is less dangerous, because it wont stuck the system in every case (only in specific cases where every sum of validators power is less than the threshold). The first case is very dangerous though. It can lead to the system becoming stuck and to all of the tokens on the cudos chain to become locked for users, because the validators wont have enough power to approve any operation - whether it is transferring tokens or updating the valset.
For the first case, consider the current validators set containing 100 validators with each ones power being equal to 10, and the threshold is 900 (91+ validators are needed for approvement). Now the updateValset function is being called with 100 validators with each ones power being equal to 1. This will lead to a state where no matter how much validators have signed a message, the sum of the powers wont pass the threshold and the action wont be able to be executed. This will cause all the tokens in the cudos blockchain become locked, and will DoS all the actions of the gravity contract - including updating the valset.
For the second case, consider the new validators set will have 128 validators, each validators power is equal to 2**249 and _powerThreshold = 2**256 - 1. In this case the system will be stuck too, because every sum of validators power wont pass the threshold.
Remix and VS Code
Add a check in the updateValset to assure that the sum of the new powers is greater than the threshold.
V-Staykov (Cudos) disputed and commented:
Albert Chon (judge) decreased severity to Medium and commented:
