Naresh - Users will not receive the correct reward tokens when MlumStaking is Under-supplied #133
Labels
Excluded
Excluded by the judge without consulting the protocol or the senior
Non-Reward
This issue will not receive a payout
Naresh
Medium
Users will not receive the correct reward tokens when MlumStaking is Under-supplied
Summary
The
_safeRewardTransfer()
function of the MlumStaking contract. When the contract is undersupplied with reward tokens, it can cause the_harvestPosition()
function to send fewer tokens than needed or revert subsequent activities. This issue arises because the missing tokens are not accounted for, potentially leading to users not receiving the expected rewards.Vulnerability Detail
All calculations are rounded down since a lack of reward tokens in the contracts cannot be attributed to rounding errors. Therefore, the rounding function is redundant.
If the contract is undersupplied with reward tokens, the _harvestPosition() function will send fewer tokens than needed or revert all subsequent activities. This is particularly unsafe because the missing tokens are not accounted for. Consequently, a user who creates a staking position might invoke the
_safeRewardTransfer()
function and not receive the tokens they were supposed to.Past Related Issues:
code-423n4/2022-02-concur-findings#244
code-423n4/2022-05-aura-findings#272
Impact
The functions addToPosition, _withdrawFromPosition,_lockPosition, harvestPosition, harvestPositionTo,harvestPositionsTo will not transfer the correct reward tokens when MlumStaking is undersupplied.
Code Snippet
https://github.com/sherlock-audit/2024-06-magicsea/blob/42e799446595c542eff9519353d3becc50cdba63/magicsea-staking/src/MlumStaking.sol#L739-L749
Tool used
Manual Review
Recommendation
To ensure that the
_safeRewardTransfer()
function only executes when there is a positive reward balance, add the following require statement:Alternatively, use the usual
safeTransfer
instead of_safeRewardTransfer
.The text was updated successfully, but these errors were encountered: