The lack of an else condition when checking if the supplycap != uint(256).max can lead to rewards being distributed beyond intended supplyCap.
Proof of Concept
The function preMintHook includes a condition to revert if nextTotalSupply > supplyCap but, this is only if supplyCap != type(uint256).max If supplyCap == type(uint256).max rewards can still be distributed as there is no else condition to revert the function. This will lead to an unexpected amount of tokens being distributed.
Lines of code
https://github.com/code-423n4/2023-05-venus/blob/8be784ed9752b80e6f1b8b781e2e6251748d0d7e/contracts/Comptroller.sol#L262-L269
Vulnerability details
Impact
The lack of an else condition when checking if the
supplycap != uint(256).max
can lead to rewards being distributed beyond intended supplyCap.Proof of Concept
The function preMintHook includes a condition to revert if
nextTotalSupply > supplyCap
but, this is only ifsupplyCap != type(uint256).max
IfsupplyCap == type(uint256).max
rewards can still be distributed as there is no else condition to revert the function. This will lead to an unexpected amount of tokens being distributed.See code block below:
Tools Used
Manual Review
Recommended Mitigation Steps
Add an else condition to ensure tokens are not distributed past type(uint256).max when supplyCap == type(uint256).max
Assessed type
Under/Overflow