Submitted by 0xStalin
If an overflow happens, the computed value of the vault portion will be a totally different value than what should really be; which would end up causing the rewards to disperse and be lower for the draw that was used to compute the vault portion.
Note: Even though the bot reported issues about downcasting variables, it didnt mention this specific unsafe casting; which if an overflow occurs, could cause a huge impact on the calculation of the vault portions.
When computing the vaultPortion to the PrizePool over a specific duration in draw, the values of the vaultContributed & totalContributed variables are computed on the DrawAccumulatorLib library, and they are computed and returned as uint256 values.
The issue is, that in the PrizePool::_getVaultPortion() the vaultContributed & totalContributed variables are unsafely cast from uint256 to int256, which could lead to a silent overflow if any of the two original values dont fit on an int256.
As a result of a silent overflow, the computed value of the vault portion will be a totally different value than what should really be; which would end up causing the rewards to disperse and be lower for the draw that was used to compute the vault portion.
Make sure to implement a safe cast that checks if overflows occur to prevent computing a totally different value than what it should really be. Use OZ safeCast library for this type of operation.
Under/Overflow
asselstine (PoolTogether) confirmed and commented:
PoolTogether mitigated:
Status: Mitigation confirmed. Full details in report from 0xStalin, dirk_y and rvierdiiev.
