You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository has been archived by the owner on Jan 12, 2025. It is now read-only.
DuplicateA valid issue that is a duplicate of an issue with `Has Duplicates` labelMediumA Medium severity issue.RewardA payout will be made for this issue
Access Control Vulnerability in MlumStaking.sol:addToPosition
Summary
The addToPosition function in the MlumStaking.sol contract allows any user to add tokens to an existing staking position by providing the tokenId of the position. This introduces a significant security risk, as malicious actors can manipulate other users positions.
While if we look at the implementation of _isAuthorized function it is this
// WARNING: This function assumes that `owner` is the actual owner of `tokenId` and does not verify this assumption.function _isAuthorized(addressowner, addressspender, uint256tokenId) internalviewvirtualreturns (bool) {
return
spender !=address(0) &&
(owner == spender ||isApprovedForAll(owner, spender) ||_getApproved(tokenId) == spender);
}
The warning is given above that it actually assumes that owner given is the owner of the tokenId. So here the function fails to protect addToPosition from access control vulnerability.
Impact
There are some impacts as given below :
adding tokens to another user's position, an attacker can manipulate the average stake time, causing the user's position to take longer to unlock.
The unauthorized addition of tokens increases the total amount staked, potentially affecting the user's strategy and plans. The control over one's staking position is compromised, leading to a loss of confidence in the protocol's security.
Function natspec states that it can be also callable by operator , but there is no check for the operator.
sherlock-admin4
changed the title
Acidic Cloth Pigeon - Access Control Vulnerability in MlumStaking.sol:addToPosition
nikhil840096 - Access Control Vulnerability in MlumStaking.sol:addToPositionJul 29, 2024
Sign up for freeto subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Labels
DuplicateA valid issue that is a duplicate of an issue with `Has Duplicates` labelMediumA Medium severity issue.RewardA payout will be made for this issue
nikhil840096
Medium
Access Control Vulnerability in
MlumStaking.sol:addToPosition
Summary
The
addToPosition
function in theMlumStaking.sol
contract allows any user to add tokens to an existing staking position by providing thetokenId
of the position. This introduces a significant security risk, as malicious actors can manipulate other users positions.Vulnerability Detail
addToPosition
function directly depends on function_requireOnlyOperatorOrOwnerOf
for checks, while the function_requireOnlyOperatorOrOwnerOf
is implemented incorrectly and is vulnerable.https://github.com/sherlock-audit/2024-06-magicsea/blob/main/magicsea-staking/src/MlumStaking.sol#L140-L143
requireOnlyOperatorOrOwnerOf
function callsERC721Upgradeable._isAuthorized
with parameter for owner and sender asmsg.sender
andmseg.sender
.While if we look at the implementation of
_isAuthorized
function it is thisThe warning is given above that it actually assumes that owner given is the owner of the tokenId. So here the function fails to protect
addToPosition
from access control vulnerability.Impact
There are some impacts as given below :
Code Snippet
https://github.com/sherlock-audit/2024-06-magicsea/blob/main/magicsea-staking/src/MlumStaking.sol#L140-L142C17
Tool used
Manual Review
Recommendation
requireOnlyOperatorOrOwnerOf
function fortokenId
owner, and also foroperator
Duplicate of #378
The text was updated successfully, but these errors were encountered: