In _harvest(), when swapping auraBAL to BAL/ETH BPT the limit variable which specifies the minimum amount of tokens that are to be received (when singleSwap.kind=GIVEN_IN) is set to 0. This means that when the swap is made, the transaction can be frontrun and lose a large portion of yield due to slippage.
I believe this a high severity issue because this can cause a large substantial loss of yield thereby rendering the whole purpose of the entire strategy meaningless.
Proof of Concept
Contract tries to swap auraBAL to BAL/ETH BPT and transaction is added to mempool
An attacker sees the transaction on the mempool, frontruns transaction and swaps a large amount of BAL/ETH BPT to auraBAL driving the price of BAL/ETH BPT up
The contracts make an unfavourable swap for a much higher price leading to less tokens received, as limit is 0, the transaction goes through.
Attacker sells auraBAL and makes profit at expense of the contract
Tools Used
VS Code
Recommended Mitigation Steps
Specify a minimum for limit using queryBatchSwap from the BalancerHelpers contract. reference
Lines of code
https://github.com/Badger-Finance/vested-aura/blob/d504684e4f9b56660a9e6c6dfb839dcebac3c174/contracts/MyStrategy.sol#L249
Vulnerability details
Impact
In
_harvest()
, when swappingauraBAL
toBAL/ETH BPT
thelimit
variable which specifies the minimum amount of tokens that are to be received (whensingleSwap.kind=GIVEN_IN
) is set to0
. This means that when the swap is made, the transaction can be frontrun and lose a large portion of yield due to slippage.I believe this a high severity issue because this can cause a large substantial loss of yield thereby rendering the whole purpose of the entire strategy meaningless.
Proof of Concept
auraBAL
toBAL/ETH BPT
and transaction is added to mempoolBAL/ETH BPT
toauraBAL
driving the price ofBAL/ETH BPT
uplimit
is 0, the transaction goes through.auraBAL
and makes profit at expense of the contractTools Used
VS Code
Recommended Mitigation Steps
Specify a minimum for
limit
usingqueryBatchSwap
from theBalancerHelpers
contract. reference