During wild swing in prices miners can decide to save transactions like this for sometime till the transactions incurs maximum slippage loss and MEV gain for the miner through front-running bots.
Below is the exactInput function of uniswap that has deadline protection through the checkDeadline modifier
The deadline allows users pass the unix literal time in the future where the transaction should revert.
This will protect the users from keeping their swap transactions "for later" till it incurs maximum slippage loss benefiting frontrunning bots.
Tools Used
Manaul review
Recommended Mitigation Steps
Implement the checkDeadline modifier in the ZetaTokenConsumerTrident.strategy.sol and the ZetaTokenConsumerTrident.strategy.sol contracts and add the checkDeadline modifier to the swap function in order to add deadline protection for swap transactions so that transaction is reverted when deadline is exceeded.
Lines of code
https://github.com/code-423n4/2023-11-zetachain/blob/b237708ed5e86f12c4bddabddfd42f001e81941a/repos/protocol-contracts/contracts/evm/tools/ZetaTokenConsumerPancakeV3.strategy.sol#L110-L120 https://github.com/code-423n4/2023-11-zetachain/blob/b237708ed5e86f12c4bddabddfd42f001e81941a/repos/protocol-contracts/contracts/evm/tools/ZetaTokenConsumerPancakeV3.strategy.sol#L138-L145 https://github.com/code-423n4/2023-11-zetachain/blob/b237708ed5e86f12c4bddabddfd42f001e81941a/repos/protocol-contracts/contracts/evm/tools/ZetaTokenConsumerPancakeV3.strategy.sol#L162-L172 https://github.com/code-423n4/2023-11-zetachain/blob/b237708ed5e86f12c4bddabddfd42f001e81941a/repos/protocol-contracts/contracts/evm/tools/ZetaTokenConsumerPancakeV3.strategy.sol#L196-L203 https://github.com/code-423n4/2023-11-zetachain/blob/b237708ed5e86f12c4bddabddfd42f001e81941a/repos/protocol-contracts/contracts/evm/tools/ZetaTokenConsumerTrident.strategy.sol#L84-L93 https://github.com/code-423n4/2023-11-zetachain/blob/b237708ed5e86f12c4bddabddfd42f001e81941a/repos/protocol-contracts/contracts/evm/tools/ZetaTokenConsumerTrident.strategy.sol#L121-L130 https://github.com/code-423n4/2023-11-zetachain/blob/b237708ed5e86f12c4bddabddfd42f001e81941a/repos/protocol-contracts/contracts/evm/tools/ZetaTokenConsumerTrident.strategy.sol#L150-L159 https://github.com/code-423n4/2023-11-zetachain/blob/b237708ed5e86f12c4bddabddfd42f001e81941a/repos/protocol-contracts/contracts/evm/tools/ZetaTokenConsumerTrident.strategy.sol#L188-L197
Vulnerability details
Impact
Loss of fund to sandwich attack at maximum slippage due to deadline protection.
Proof of Concept
The main issue is that Pancake and Trident are both forks of Uniswap AMM WITHOUT the
deadline
protection.The
deadline
property according to Uniswap docs is "the unix time after which a swap will fail, to protect against long-pending transactions and wild swings in prices" ref: https://docs.uniswap.org/contracts/v3/guides/swaps/single-swaps#swap-input-parametersDuring wild swing in prices miners can decide to save transactions like this for sometime till the transactions incurs maximum slippage loss and MEV gain for the miner through front-running bots.
Below is the
exactInput
function of uniswap that has deadline protection through thecheckDeadline
modifierAnd below is Pancakeswap's
exactInput
function without the deadline protectionThe deadline allows users pass the unix literal time in the future where the transaction should revert.
This will protect the users from keeping their swap transactions "for later" till it incurs maximum slippage loss benefiting frontrunning bots.
Tools Used
Manaul review
Recommended Mitigation Steps
Implement the
checkDeadline
modifier in the ZetaTokenConsumerTrident.strategy.sol and the ZetaTokenConsumerTrident.strategy.sol contracts and add thecheckDeadline
modifier to the swap function in order to add deadline protection for swap transactions so that transaction is reverted when deadline is exceeded.Then in for example
getTokenFromZeta
function you add thecheckDeadline
modifier and acceptdeadline
as input literalAssessed type
MEV