This repository has been archived by the owner on Jan 12, 2025. It is now read-only.
araj - Malicious user can frontrun the reward deposit to MlumStaking.sol to steal rewards of honest stakers #136
Labels
Excluded
Excluded by the judge without consulting the protocol or the senior
Non-Reward
This issue will not receive a payout
araj
Medium
Malicious user can frontrun the reward deposit to MlumStaking.sol to steal rewards of honest stakers
Summary
Malicious user can
frontrun
the reward deposit to MlumStaking.sol tosteal
rewards of honest stakersVulnerability Detail
User gets
reward
in MlumStaking.sol for staking token, but the problem is a malicious user canfrontrun
the reward deposit to MlumStaking.sol bycreating
a position with0
lockDuration and withdrawingimmediately
after the rewardDeposit, successfullystealing
rewards of honest stakers//How this works(simple example)
reward
of 10e18(rewardToken) going to bedeposited
in MlumStaking for distributioncreate
a position of 2e18(stakedToken) with0
lockDurationamountWithMultiplier
will be =2e18
(getMultiplierByLockDuration will return0
for 0 lockDuration) &rewardDebt
will beamountWithMultiplier * _accRewardsPerShare / PRECISION_FACTOR
( 2e18 * 1000(suppose) / PRECISION_FACTOR)rewardToken = 10e18
deposited in MlumStaking for distributionwithdrawFromPosition()
which calls _updatePool() thatincreases
the _accRewardsPerShare due toincrease
in rewardToken. Lets say it became 1100(In pt-3 we assume it to be 1000)_harvestPosition()
which calculates thependingAmount
and transfers to user, so pending = (2e18 * 1100 / PRECISION_FACTOR) - (2e18 * 1000 / PRECISION_FACTOR)positive
value due to increase in _accRewardsPerShare & it will be transfered to malicious user, successfully stealing rewards of stakers staking for monthsNote: This pendingAmount can be very high, if amountWithMultiplier & rewardToken is high enough
Impact
Malicious user can steal rewards
Code Snippet
https://github.com/sherlock-audit/2024-06-magicsea/blob/main/magicsea-staking/src/MlumStaking.sol#L354C5-L390C6
https://github.com/sherlock-audit/2024-06-magicsea/blob/main/magicsea-staking/src/MlumStaking.sol#L496C5-L502C6
https://github.com/sherlock-audit/2024-06-magicsea/blob/main/magicsea-staking/src/MlumStaking.sol#L574C4-L591C6
https://github.com/sherlock-audit/2024-06-magicsea/blob/main/magicsea-staking/src/MlumStaking.sol#L674C5-L687C1
Tool used
Manual Review
Recommendation
The text was updated successfully, but these errors were encountered: