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

15 stars 10 forks source link

TricryptoNativeStrategy `compound` function is prone to MEV sandwich attack -- accrued rewards can be MEV'd (bad slippage control) #290

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#L169-L171

Vulnerability details

Impact

TricryptoNativeStrategy compound function is prone to MEV sandwich attack. Specifically, during the swap, the output amount from swapping rewards to the wrapped native tokens can be MEV'd and get almost 0 value out.

Proof of Concept

Specifically, the attacker can flashloan and make the underlying pool imbalance (making the reward tokens really cheap), and invoke compound function -- trying to swap all the accrued reward tokens. The compound function will then try to sell the tokens, and by the bad slippage control described above, the check will pass and the output wrapped asset will be of minimal value. The attacker can then swap back the pool and just profit.

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