code-423n4 / 2023-07-tapioca-findings

12 stars 9 forks source link

TricryptoNativeStrategy `_withdraw` is prone to MEV sandwich attack (bad slippage control) -- users who want to withdraw can get 0 value out of it. #292

Closed code423n4 closed 1 year ago

code423n4 commented 1 year ago

Lines of code

https://github.com/Tapioca-DAO/tapioca-yieldbox-strategies-audit/blob/05ba7108a83c66dada98bc5bc75cf18004f2a49b/contracts/curve/TricryptoNativeStrategy.sol#L231-L233

Vulnerability details

Impact

TricryptoNativeStrategy withdraw is prone to MEV sandwich attack (bad slippage control) --> users who try to withdraw from the strategy can get MEV'd and get 0 value out of the withdrawal.

Proof of Concept

Specifically, the attacker can flashloan and become a majority of the underlying pool (to reap most of the profits) and also make WETH really expensive in the underlying pool. So, the calcLpToWeth will only return minimal weth amount. So, the user's withdrawal's tx will only get those minimal WETH amount out (at a loss). And the loss will get distributed to the current underlying pool's LPs, which the attack was the majority, so the attacker can reap most of the profits there.

Tools Used

Manual Review

Recommended Mitigation Steps

Assessed type

MEV

c4-pre-sort commented 1 year ago

minhquanym marked the issue as duplicate of #245

c4-judge commented 1 year ago

dmvt marked the issue as duplicate of #158

c4-judge commented 1 year ago

dmvt changed the severity to 2 (Med Risk)

c4-judge commented 1 year ago

dmvt marked the issue as nullified

c4-judge commented 1 year ago

dmvt marked the issue as duplicate of #245