An underflow can occur when totalRewards is negative, causing the totalStaked to be an extremely large value. This bug allows for an incorrect calculation, leading to conditions where rewards or fees are not properly distributed.
In the _updateStrategyRewards function, totalRewards is an int256 that accumulates deposit changes across strategies. If totalRewards becomes negative, the line:
casts a potentially negative sum to uint256. This conversion does not throw an underflow error. Instead, it results in a very large number. The problem occurs when this inflated totalStaked value prevents the system from distributing rewards or fees properly, as seen in this line:
if the totalStaked becomes an extremely large number, the condition is always false, blocking the fee distribution and possibly minting incorrect shares.
Fees might not be distributed to receivers. Also can cause imbalances in reward allocations and unfair reward distribution.
Manual Review
Always ensure that the calculation will not result in a negative totalStaked value.
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.