Closed github-actions[bot] closed 1 year ago
Not a security vulnerability.
Invalid anyways. PerpDepository is deployed on OP which doesn't have a mempool and each transaction is it's own block, making sandwich attacks impossible.
Closing based on above comments
Jeiwan
medium
Using
block.timestamp
as deadline exposes users to sandwich attacksSummary
The deadline parameter is set to
block.timestamp
when calling Perpetual Protocol'sClearingHouse.openPosition
and Uniswap'sSwapRouter.exactInputSingle
, which basically disables the transaction execution deadline. As a result, users may lose funds due to sandwich attacks when there's positive slippage.Vulnerability Detail
When opening a position in Perpetual Protocol or swapping tokens in Uniswap, the deadline parameter is set to
block.timestamp
(PerpDepository.sol#L362, Uniswapper.sol#L39). This means that the deadline parameter will be set to the block at which the transaction will be mined, which makes the deadline check useless. This exposes users to sandwich attacks in situations when:The above situation results in a positive slippage, which may be stolen by MEV bots. Consider this exploit scenario:
Impact
Users funds may be stolen by MEV bots as a result of sandwich attacks.
Code Snippet
Uniswapper.sol#L39 PerpDepository.sol#L362
Tool used
Manual Review
Recommendation
Consider letting users set the deadline parameter and consider using a default value when it's not set. For example, Uniswap sets deadline to 5 minutes on L2 networks.