Open code423n4 opened 1 year ago
dmvt marked the issue as duplicate of #251
RedVeil marked the issue as sponsor confirmed
dmvt marked the issue as not a duplicate
dmvt changed the severity to QA (Quality Assurance)
dmvt marked the issue as grade-b
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#L191-L202
Vulnerability details
Impact
Owners have the freedom to choose any token as the reward token, including arbitrary tokens. Some ERC20 tokens, such as USDC, only have 6 decimal places. When tokens with less than 18 decimal places, such as USDC, are used as the reward token, there is a likelihood that the user will not be able to claim rewards if the fees are too small.
User may not be able to claim rewards for a period of time depending on the
rewardsPerSecond
and theescrowPercentage
.Proof of Concept
Suppose the owner adds a reward token with only 6 decimal places and selects 1e11 as the
escrowPercentage
, potentially due to a mistake or for any other reason. Users who are accruing tokens are unable to call theclaimRewards()
function if their accrued rewards are not more than 2e6.For example, when the rewardAmount is
0.9e6
, the user calls theclaimRewards()
function. The_lockToken()
function is executed, but the escrowed amount will be 0 as0.9e6 * 1e11 / 1e18
rounds down to 0 after calculation.This results in the user being unable to call the
claimRewards()
function, as it will revert when theMultiRewardEscrow.sol
calls thelock()
function due toif (amount == 0) revert ZeroAmount()
condition.This issue becomes even more pronounced when the fees are small and the accrued rewards rate is slow.
Tools Used
Manual Review
Recommended Mitigation Steps
Consider adding a minimum fee to the function
addRewardToken()
forescrowPercentage()
.