Closed code423n4 closed 1 year ago
dmvt marked the issue as duplicate of #251
RedVeil marked the issue as sponsor confirmed
dmvt changed the severity to QA (Quality Assurance)
This previously downgraded issue has been upgraded by captainmangoC4
dmvt marked the issue as partial-50
Lines of code
https://github.com/code-423n4/2023-01-popcorn/blob/main/src/utils/MultiRewardStaking.sol#L243-L288 https://github.com/code-423n4/2023-01-popcorn/blob/main/src/utils/MultiRewardStaking.sol#L178-L181 https://github.com/code-423n4/2023-01-popcorn/blob/main/src/utils/MultiRewardStaking.sol#L191-L202
Vulnerability details
Impact
In the MultiRewardStaking contract when the
addRewardToken
function is called by the owner he has the option to set anescrowPercentage
which represent the percentage of rewards locked in the escrow contract when theclaimRewards
function is called, the value ofescrowPercentage
is supposed to be in basis point where1e18
represents 100%.The issue occurs if the owner by accident (or intentionnally) sets the
escrowPercentage
value greater than1e18
, this will cause the function_lockToken
to always revert due to an underflow which will block the rewards withdrawal in the contract.And because the
escrowPercentage
can not be updated after the call toaddRewardToken
, the rewards withdrawal process will remain blocked forever.Proof of Concept
The issue occurs when the
escrowPercentage
value is set in theaddRewardToken
function :File: utils/MultiRewardStaking.sol Line 243-288
As you can see if
useEscrow
is set to true theescrowPercentage
value is set directly without any check on its value which then allows the owner to set it greater than 1e18.When later a user tries to claim its rewards for that given token he will call the
claimRewards
function which contain the following line of code :File: utils/MultiRewardStaking.sol Line 178-181
So if
escrowInfo.escrowPercentage
is greater than zero the internal function_lockToken
is called which in turn contains the following code :File: utils/MultiRewardStaking.sol Line 191-202
The operation which calculate the final payout amount
payout
will underflow because when we haveescrowInfo.escrowPercentage > 1e18
the value ofescrowed
will be greater than therewardAmount
.And thus the function will revert and the user won't be able to claim his rewards.
Finally, because the MultiRewardStaking contract does not contain any function to update the value of
escrowPercentage
for a given token, the users will not be able to claim their rewards forever as the call toclaimRewards
function will always revert.Tools Used
Manual review
Recommended Mitigation Steps
To avoid this issue add a check in the
addRewardToken
function to ensure that the value ofescrowPercentage
is always less or equal to 1e18 :