In the given code snippet for the distributeFees function, there is a potential risk of integer overflow during the calculation of positions[_holder].EUROs += _amount * positions[_holder].TST / tstTotal within the loop iterating over holders. If the product of _amount * positions[_holder].TST exceeds the maximum value that a uint256 can hold, an overflow may occur.
In this example, we set _amount to the maximum representable value of a uint256, which is 2^256 - 1. If holderTST is a sufficiently large value, the multiplication operation _amount * holderTST may exceed the maximum representable value for a uint256, causing an integer overflow.
positions[_holder].TST is a large value, the multiplication _amount * positions[_holder].TST could potentially lead to an overflow, especially when _amount is set to the maximum representable value. The subsequent addition in positions[_holder].EUROs += holderShare might then cause an unexpected result due to the overflow.
https://github.com/Cyfrin/2023-12-the-standard/blob/91132936cb09ef9bf82f38ab1106346e2ad60f91/contracts/LiquidationPool.sol#L192
https://github.com/Cyfrin/2023-12-the-standard/blob/91132936cb09ef9bf82f38ab1106346e2ad60f91/contracts/LiquidationPool.sol#L188
Manual Review
Use safeMath Library
The contest is live. Earn rewards by submitting a finding.
This is your time to appeal against judgements on your submissions.
Appeals are being carefully reviewed by our judges.