Skip to content
Business logic Audit finding Intermediate

_harvest has no slippage protection when swapping auraBAL for AURA

The _harvest function performs token swaps without any slippage or deadline protection, making it vulnerable to sandwich attacks and other MEV exploits. An attacker could exploit this to cause significant loss of yield.

Picodes Follow

Originally disclosed on Code4rena

Submitted by Picodes, also found by 0x1f8b, 0x52, berndartmueller, cccz, Chom, defsec, georgypetrov, GimelSec, hyh, IllIllI, kenzo, minhquanym, oyc109, scaraven, and unforgiven_

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

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

Impact

Single swaps of _harvest contains no slippage or deadline, which makes it vulnerable to sandwich attacks, MEV exploits and may lead to significant loss of yield.

Proof of Concept

When using BALANCER_VAULT.swap here and here, there is no slippage protection. Therefore a call to _harvest generating swaps could be exploited for sandwich attacks or other MEV exploits such as JIT.

The scenario would be: A authorized actor calls harvest, leading to a swap of say x auraBAL to BAL/ETH BPT and then y WETH to BAL.

Then while the transaction is in the mempool, it is exploited for example like in https://medium.com/coinmonks/defi-sandwich-attack-explain-776f6f43b2fd

Recommended Mitigation Steps

The easiest mitigation would be to pass a minimum amount of AURA that the swap is supposed to get in harvest. It should not add security issues as callers of harvest are trusted.

Another solution would be to do like here to use Cowswap for example, or any other aggregator.

Alex the Entreprenerd (BadgerDAO) commented:

I love how the warden linked my code to integrate cowswap XD

jack-the-pug (judge) validated

Alex the Entreprenerd (BadgerDAO) confirmed and commented:

Confirmed and mitigated in 2 ways:

  • We do use Private Transactions to Harvest (reduce change of front-run can still be sandwiched).
  • We Refactored to have a slippage tollerance

The original report as published on Code4rena, by Picodes. Images and videos are our own copies; raw HTML is shown as text. View it on Code4rena.

Not written yet. The AI write-up for this report has not been written yet. The Original tab links to the source.

How it worked

Root cause

The swap calls in _harvest lack a minimum output amount and deadline, so they are susceptible to price manipulation.

Impact

The swaps could be sandwiched or otherwise exploited for MEV, potentially causing significant loss of yield; the project later mitigated by using private transactions and adding slippage tolerance.

What the attacker needed

Authorised actor calls harvest; transaction visible in mempool

The fix

The project mitigated by using private transactions for harvest and refactoring to include a slippage tolerance.

How it was found

  1. An authorised actor calls harvest, which triggers swaps of auraBAL to BAL/ETH BPT and WETH to BAL.
  2. While the transaction is in the mempool, an attacker exploits it, for example via a sandwich attack.

Explained by bugbounty.wiki with AI from the original and checked against quotes from it; it can still be wrong. Read the original before relying on a detail.

Not written yet. The AI write-up for this report has not been written yet. The Original tab links to the source.

When a smart contract swaps tokens, it can be attacked by someone who sees the transaction and places their own trades before and after to profit from the price change. This is called a sandwich attack. Here, the contract did not set a minimum amount to receive, so it could be forced to accept a very bad trade.

What is Business logic?

The application works as coded but not as intended: a negative price, a skipped payment step, a limit that can be crossed.

More by Picodes

View all

17 more disclosed reports, best first.

More from eBTC Zap Router

View all

The newest disclosed reports for this program.

Similar reports

View all

Same bug class and techniques, clearest first.

Business logic flaws

The lesson behind this report.

The application works as coded but not as intended: a negative price, a skipped payment step, a limit that can be crossed.