This repository has been archived by the owner on Jan 12, 2025. It is now read-only.
_requireOnlyOperatorOrOwnerOf
does not correctly check the owner or the operator of the position leading to anyone can adjust the duration of a LockingPosition
by adding to it.
#665
zarkk01
High
_requireOnlyOperatorOrOwnerOf
does not correctly check the owner or the operator of the position leading to anyone can adjust the duration of aLockingPosition
by adding to it.Vulnerability Detail
The
requireOnlyOperatorOrOwnerOf
function is supposed to check if the caller ofaddPosition
inMlumStaking
contract is, actually, the owner of theLockingPosition
or authorized. However, in the way that the function call of_isAuthorized
call is implemented therequireOnlyOperatorOrOwnerOf
will always return true. We can see the the_isAuthorized
function ofERC721
here :In
MlumStaking
,msg.sender
is passed in bothowner
andspender
params without checking if themsg.sender
is the owner of the NFT as stated in the comments of the_isAuthorized
function ofERC721
. This results to anyone can calladdPosition
function for whichever NFT they want to. By adding to the position, an attacker can adjust the duration of any NFT position and can prevent the actual owner of the NFT to withdraw their funds or vote inVoter
contract.Impact
Anyone can change the duration of a
LockingPosition
can lead to a DoS attack on the actual owner of the position since thelockDuration
of the position was selected by the owner so to serve his needs. By extending or reducing the duration of the position, the attacker can prevent the owner from withdrawing his funds or voting in theVoter
contract among other problems for the actual owner which does not equal the extra amount in the position that the attacker added.Proof of concept
This PoC demonstrates the scenario where an attacker DoS the withdrawal of the actual owner of the
LockingPosition
by adding to it a very tiny amount and extending the duration of it.To understand better this vulnerability, add this test in
MlumStakingTest.sol
and runforge test --mt testWithdrawDOSbyAddingToPosition
:Code Snippet
https://github.com/sherlock-audit/2024-06-magicsea/blob/main/magicsea-staking/src/MlumStaking.sol#L140
Tool used
Manual Review
Recommendation
Consider making this change in the
_requireOnlyOperatorOrOwnerOf
function so to implement correctly the check :Duplicate of #378
The text was updated successfully, but these errors were encountered: