Closed code423n4 closed 2 years ago
wuwe1
https://github.com/code-423n4/2022-01-sherlock/blob/main/contracts/Sherlock.sol#L673
https://github.com/code-423n4/2022-01-sherlock/blob/main/contracts/Sherlock.sol#L488
If malicious arbitrager can get control flow from this expression token.safeTransfer(_receiver, _amount);. He can reentry arbRestake and take more arbReward than expected.
token.safeTransfer(_receiver, _amount);
arbRestake
arbReward
https://github.com/code-423n4/2022-01-sherlock/blob/main/contracts/Sherlock.sol#L467
Arbitrager can reentry arbRestake
https://github.com/code-423n4/2022-01-sherlock/blob/main/contracts/Sherlock.sol#L491
This line will not revert because _stakeShares ≤ stakeShares[_id] * 0.2
_stakeShares ≤ stakeShares[_id] * 0.2
Use ReentrancyGuard to guard arbRestake
there is no reentry on erc20 safetransfer
token is known to be USDC.
token
Handle
wuwe1
Vulnerability details
Proof of Concept
https://github.com/code-423n4/2022-01-sherlock/blob/main/contracts/Sherlock.sol#L673
https://github.com/code-423n4/2022-01-sherlock/blob/main/contracts/Sherlock.sol#L488
If malicious arbitrager can get control flow from this expression
token.safeTransfer(_receiver, _amount);
. He can reentryarbRestake
and take morearbReward
than expected.https://github.com/code-423n4/2022-01-sherlock/blob/main/contracts/Sherlock.sol#L467
Arbitrager can reentry
arbRestake
https://github.com/code-423n4/2022-01-sherlock/blob/main/contracts/Sherlock.sol#L491
This line will not revert because
_stakeShares ≤ stakeShares[_id] * 0.2
Recommended Mitigation Steps
Use ReentrancyGuard to guard
arbRestake