Open sherlock-admin2 opened 4 months ago
Calling the renewLockPosition
and extendLockPosition
functions may result in rewards being sent to the wrong address.
When an approved actor calls the renewLockPosition
or extendLockPosition
functions, the rewards go to the approved actor who made the call, not the Position Owner.
The protocol team fixed this issue in the following PRs/commits: https://github.com/metropolis-exchange/magicsea-staking/pull/8
The Lead Senior Watson signed off on the fix.
BlockBusters
Medium
Rewards might get stuck when approved actor renews a position
Summary
When an approved actor calls the harvest function, the rewards get sent to the user (staker). However, when the approved actor renews the user’s position, they receive the rewards instead.
If the approved actor is a smart contract (e.g., a keeper), the funds might get stuck forever or go to the wrong user, such as a Chainlink keeper.
Vulnerability Detail
Suppose Alice mints an NFT by creating a position and approves Bob to use it.
harvestPosition
with Alice’stokenId
, Alice will receive the rewards (as intended)renewLockPosition
with Alice’stokenId
, Bob will receive the rewards. The internal function_lockPosition
, which is called byrenewLockPosition
, also harvests the position before updating the lock duration. Unlike the harvest function,_lockPosition
sends the rewards tomsg.sender
instead of the token owner.This bug exists in both
renewLockPosition
andextendLockPosition
, as they both call_lockPosition
, which includes the wrong receiver.PoC
To run this test, add it into
MlumStaking.t.sol
.Impact
Possible loss of reward tokens
Code Snippet
https://github.com/sherlock-audit/2024-06-magicsea/blob/main/magicsea-staking/src/MlumStaking.sol#L710
Tool used
Manual Review, Foundry
Recommendation
Change
_lockPosition()
inMlumStaking.sol
to use the owner of the position instead ofmsg.sender
.