code-423n4 / 2022-06-badger-findings

0 stars 0 forks source link

Harvest is vulnerable to sandwich attack. #102

Closed code423n4 closed 2 years ago

code423n4 commented 2 years ago

Lines of code

https://github.com/Badger-Finance/vested-aura/blob/b6abb069431518962e1e0b3e516daa46ae3bdd9b/contracts/MyStrategy.sol#L219

Vulnerability details

Impact

Function _harvest() does multiple swaps from auraBAL -> BAL/ETH BPT -> WETH -> AURA using BalancerVault. But it doesn’t use minAmountsOut or have a check for mimimum return amount. It makes this function vulnerable to sandwich attack.

An attacker (which can be a malicious keeper) can front-run swap in BalancerVault before harvest() to make a profit.

Proof of Concept

Please refer to yDai Incident to check the severity of a harvest function without slippage control.

Please refer to Mushrooms-finance-theft to check how likely this kind of attack might happen.

Recommended Mitigation Steps

Should add a min return param or check the slippage.

GalloDaSballo commented 2 years ago

Dup of #155

note that yDAI is Single-Sided-Exposure not the same risk