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
No MinimumLockDuration in Mlumstaking.sol lets anyone stake and steal rewards
Summary
Since there is no minimumlockDuration for staking anyone can a create a staking position and claim rewards with very low lockDuration whenever there is large rewardtoken deposit is made
Vulnerability Detail
In Mlumstaking.sol , when a staking position is created, there is no minimumLockDuration check and the reward calculation depends on the amount of rewardtoken deposited and this lets anyone to create a position with very low lockDuration and claim rewards whenever there is large rewardtoken deposit is made.
function createPosition(uint256amount, uint256lockDuration) externaloverride nonReentrant {
// no new lock can be set if the pool has been unlockedif (isUnlocked()) {
require(lockDuration ==0, "locks disabled");
}
_updatePool();
// handle tokens with transfer tax
amount =_transferSupportingFeeOnTransfer(stakedToken, msg.sender, amount);
require(amount !=0, "zero amount"); // createPosition: amount cannot be null// mint NFT position tokenuint256 currentTokenId =_mintNextTokenId(msg.sender);
// calculate bonusesuint256 lockMultiplier =getMultiplierByLockDuration(lockDuration);
uint256 amountWithMultiplier = amount * (lockMultiplier +1e4) /1e4;
// create position
_stakingPositions[currentTokenId] =StakingPosition({
initialLockDuration: lockDuration,
amount: amount,
rewardDebt: amountWithMultiplier * (_accRewardsPerShare) / (PRECISION_FACTOR),
lockDuration: lockDuration,
startLockTime: _currentBlockTimestamp(),
lockMultiplier: lockMultiplier,
amountWithMultiplier: amountWithMultiplier,
totalMultiplier: lockMultiplier
});
// update total lp supply
_stakedSupply = _stakedSupply + amount;
_stakedSupplyWithMultiplier = _stakedSupplyWithMultiplier + amountWithMultiplier;
emitCreatePosition(currentTokenId, amount, lockDuration);
}
The attacker can also exploit a front-running attack , the attacker monitors the blockchain for incoming transactions that would deposit a large amount of reward tokens into the staking pool. Just before the large reward deposit transaction is confirmed, the attacker creates a new position by calling the createPosition function with the amount of staked tokens. Since _updatePool and _harvestPosition functions are called during the reward distribution, the newly created position will be eligible to receive a share of the newly deposited rewards even if the lock duration is very short .The attacker can withdraw shortly after claiming the rewards, thus earning a disproportionate amount of rewards relative to their stake duration.
Impact
Anyone can create a position with very low lockDuration and claim rewards whenever there is large rewardtoken deposit is made.
0xSmartContract
added
High
A High severity issue.
Duplicate
A valid issue that is a duplicate of an issue with `Has Duplicates` label
Medium
A Medium severity issue.
and removed
Excluded
Excluded by the judge without consulting the protocol or the senior
High
A High severity issue.
labels
Jul 26, 2024
sherlock-admin4
changed the title
Special Fuchsia Flamingo - No MinimumLockDuration in Mlumstaking.sol lets anyone stake and steal rewards
LeFy - No MinimumLockDuration in Mlumstaking.sol lets anyone stake and steal rewards
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
LeFy
High
No MinimumLockDuration in Mlumstaking.sol lets anyone stake and steal rewards
Summary
Since there is no minimumlockDuration for staking anyone can a create a staking position and claim rewards with very low lockDuration whenever there is large rewardtoken deposit is made
Vulnerability Detail
In Mlumstaking.sol , when a staking position is created, there is no minimumLockDuration check and the reward calculation depends on the amount of rewardtoken deposited and this lets anyone to create a position with very low lockDuration and claim rewards whenever there is large rewardtoken deposit is made.
Repolink
The attacker can also exploit a front-running attack , the attacker monitors the blockchain for incoming transactions that would deposit a large amount of reward tokens into the staking pool. Just before the large reward deposit transaction is confirmed, the attacker creates a new position by calling the createPosition function with the amount of staked tokens. Since _updatePool and _harvestPosition functions are called during the reward distribution, the newly created position will be eligible to receive a share of the newly deposited rewards even if the lock duration is very short .The attacker can withdraw shortly after claiming the rewards, thus earning a disproportionate amount of rewards relative to their stake duration.
Impact
Anyone can create a position with very low lockDuration and claim rewards whenever there is large rewardtoken deposit is made.
Code Snippet
https://github.com/sherlock-audit/2024-06-magicsea/blob/42e799446595c542eff9519353d3becc50cdba63/magicsea-staking/src/MlumStaking.sol#L354
https://github.com/sherlock-audit/2024-06-magicsea/blob/42e799446595c542eff9519353d3becc50cdba63/magicsea-staking/src/MlumStaking.sol#L442
https://github.com/sherlock-audit/2024-06-magicsea/blob/42e799446595c542eff9519353d3becc50cdba63/magicsea-staking/src/MlumStaking.sol#L574
Tool used
Manual Review
Recommendation
Implement a minimumLockDuration requirement
Duplicate of #74
The text was updated successfully, but these errors were encountered: