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
An attacker can acquire much share of rewards by sandwiching transaction which transfers rewards to MlumStaking.
Summary
There is no lowest limit of lockDuration in createPosition(). So an attacker can frontrun transfering rewards to MlumStaking with createPosition() and then he can instantly withdraw from that position.
Vulnerability Detail
MlumStaking.sol#createPosition() function which deposits funds and creates position is as follows.
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);
371uint256 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);
}
As we can see above, there is no lowest limit of lockDuration.
And MlumStaking.sol#_updatePool() function which distributes rewards is as follows.
An attacker can see a transaction which transfers much rewards to MlumStaking in mempool. Then, he sandwiches that transaction with createPosition()(much funds) and withdrawFromPosition().
Here, even if lockDuration == 0, amountWithMultiplier = amount on L371.
So he can acquire much share of rewards.
Impact
An attacker can acquire much share of rewards by sandwiching transaction which transfers rewards to MlumStaking.
0xSmartContract
added
Medium
A Medium severity issue.
Duplicate
A valid issue that is a duplicate of an issue with `Has Duplicates` label
and removed
Excluded
Excluded by the judge without consulting the protocol or the senior
labels
Jul 27, 2024
sherlock-admin4
changed the title
Petite Rouge Huskie - An attacker can acquire much share of rewards by sandwiching transaction which transfers rewards to MlumStaking.
dany.armstrong90 - An attacker can acquire much share of rewards by sandwiching transaction which transfers rewards to MlumStaking.
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
dany.armstrong90
Medium
An attacker can acquire much share of rewards by sandwiching transaction which transfers rewards to
MlumStaking
.Summary
There is no lowest limit of
lockDuration
increatePosition()
. So an attacker can frontrun transfering rewards toMlumStaking
with createPosition() and then he can instantly withdraw from that position.Vulnerability Detail
MlumStaking.sol#createPosition()
function which deposits funds and creates position is as follows.As we can see above, there is no lowest limit of
lockDuration
.And
MlumStaking.sol#_updatePool()
function which distributes rewards is as follows.An attacker can see a transaction which transfers much rewards to
MlumStaking
in mempool. Then, he sandwiches that transaction withcreatePosition()
(much funds) andwithdrawFromPosition()
.Here, even if
lockDuration == 0
,amountWithMultiplier = amount
on L371.So he can acquire much share of rewards.
Impact
An attacker can acquire much share of rewards by sandwiching transaction which transfers rewards to
MlumStaking
.Code Snippet
https://github.com/sherlock-audit/2024-06-magicsea/blob/main/magicsea-staking/src/MlumStaking.sol#L354
Tool used
Manual Review
Recommendation
We have to add the lowest limit check of
lockDuration
as follows.Duplicate of #74
The text was updated successfully, but these errors were encountered: