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
_requireOnlyOperatorOrOwnerOf always returns true, causing permission control to fail.Users can add a position to an NFT even if they do not own it.
Code Snippet
add the following function to MlumStaking.t.sol file.
functiontestAddToPositionAssess()public{// alice and bob mint 2 ethers staking tokenuintMINT_AMOUNT=2ether;_stakingToken.mint(ALICE,MINT_AMOUNT);_stakingToken.mint(BOB,MINT_AMOUNT);// alice create position(1 ether) & mint a nft (tokenId = 1)uintSTART_POSITION_AMOUNT=1ether;vm.startPrank(ALICE);_stakingToken.approve(address(_pool),START_POSITION_AMOUNT);_pool.createPosition(START_POSITION_AMOUNT,1days);vm.stopPrank();skip(43200);MlumStaking.StakingPositionmemoryposition;uinttokenId=1;position=_pool.getStakingPosition(tokenId);// check the onwer of tokenid = 1 is aliceassertEq(_pool.ownerOf(tokenId),ALICE);assertEq(position.amount,START_POSITION_AMOUNT);// bob can still add positon to the pool where tokenId = 1uintADDED_POSITION_AMOUNT=2ether;vm.startPrank(BOB);_stakingToken.approve(address(_pool),ADDED_POSITION_AMOUNT);_pool.addToPosition(tokenId,2ether);vm.stopPrank();// check the position amount after bob add position to the pool where tokenId belongs to aliceposition=_pool.getStakingPosition(tokenId);assertEq(position.amount,START_POSITION_AMOUNT+ADDED_POSITION_AMOUNT);}
run forge test --match-contract MlumStakingTest command
Tool used
foundry
Manual Review
Recommendation
use _requireOnlyApprovedOrOwnerOf instead of _requireOnlyOperatorOrOwnerOf
sherlock-admin4
changed the title
Thankful Quartz Deer - Every user can execute the addToPosition method even if they don't have the nft
luke - Every user can execute the addToPosition method even if they don't have the nft
Jul 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
luke
Medium
Every user can execute the addToPosition method even if they don't have the nft
Summary
addToPosition(uint256 tokenId, uint256 amountToAdd)
lack of controlVulnerability Detail
the
addToPosition
method in the MlumStaking.sol file uses the_requireOnlyOperatorOrOwnerOf
modifier to control permissions. The comment says "Can only be called by lsNFT's owner or operators," but_requireOnlyOperatorOrOwnerOf
doesn't control any permissions.Every user can add position to the nft.https://github.com/sherlock-audit/2024-06-magicsea/blob/main/magicsea-staking/src/MlumStaking.sol#L392-L401
https://github.com/sherlock-audit/2024-06-magicsea/blob/main/magicsea-staking/src/MlumStaking.sol#L140-L143
Impact
_requireOnlyOperatorOrOwnerOf
always returns true, causing permission control to fail.Users can add a position to an NFT even if they do not own it.Code Snippet
add the following function to
MlumStaking.t.sol
file.run
forge test --match-contract MlumStakingTest
commandTool used
foundry
Manual Review
Recommendation
use
_requireOnlyApprovedOrOwnerOf
instead of_requireOnlyOperatorOrOwnerOf
Duplicate of #378
The text was updated successfully, but these errors were encountered: