Submitted by gpersoon
Both SumOfTrust.sol and CreditLimitByMedian.sol contain an expensive sort function. This is used by UserManager.sol via the functions getLockedAmount and getCreditLimit.
If the list of stakers would be very long then the sort would take up all the gas and revert.
Attackers could make the list of stakers longer by voting in themselves (as soon as they have 3 accounts voted in), this would result in a griefing attack.
Luckily the number of stakers and borrowers is limited in the function updateTrust by applying a limit of MAX_TRUST_LIMIT.
However this limit is quite high (100), if that amount of stakers would be present then an out of gas error would probably occur with the sort.
Note: there are also other for loops in the code that could have a similar problem, however sort is the most expensive.
Do a test with a MAX_TRUST_LIMIT number of stakers and borrowers and check if the code still works.
Set the MAX_TRUST_LIMIT so that everything still works, probably include a margin for future changes in gas costs.
GeraldHost (Union Finance) acknowledged:
GalloDaSballo (judge) commented:
