Closed sherlock-admin3 closed 3 months ago
PR: https://github.com/metropolis-exchange/magicsea-staking/pull/7
We added minimumLockDuration and a check for that on createPosition
This scenario is not a practically feasible attack because a full attack scenario requires 3 tx atomically.
Flashloan transactions are performed within a single transaction and all borrowings and repayments are made before this transaction is completed. Therefore, it is not possible to perform multiple independent transactions using flashloan.So invalid
Patreeciy
High
pool manipulation with flash loan attack
Summary
In the contract https://github.com/sherlock-audit/2024-06-magicsea/blob/main/magicsea-staking/src/MlumStaking.sol If there are no reward tokens in the pool, then when adding them to the pool, using a flash loan attack and front run attack, the attacker can manipulate the pool in such a way as to take away most of the reward tokens
Vulnerability Detail
Several staking token positions have been added to the pool, with lockDuration 365 days and 1 ether staking tokens. having anticipated the transaction of adding a reward token in the mempool, it can create a position with a large value and a lockDuration of 0 seconds, and then remove the position take your profit
Impact
The attacker will take most of the reward tokens
Code Snippet
https://github.com/sherlock-audit/2024-06-magicsea/blob/main/magicsea-staking/src/MlumStaking.sol#L354-L390
Proof of Concept
Tool used
Manual Review
Recommendation
add time management before withdrawal of funds, and distribution of reward token, only at the end of lockDuration
require(lockDuration == 0, "locks disabled");
all time not onlyif (isUnlocked())