Skip to content
Smart contracts Audit finding Intermediate

# Controller is vulnerable to sandwich attack

The controller contract calls Curve (crv) swaps without specifying a minimum return amount, leaving trades open to sandwich attacks. An attacker could front-run and back-run the swap to profit from the price impact, potentially draining user funds.

jonah1005 Follow

Originally disclosed on Code4rena

Submitted by jonah1005

Impact

The protocol frequently interacts with crv a lot. However, the contract doesn’t specify the minimum return amount. Given the fact that there’s a lot of MEV searchers, calling swap without specifying the minimum return amount really puts user funds in danger.

For example, controller’s withdrawAll is designed to transfer all the funds in a strategy.Controller.sol#L360 The arbitrage space is enough for a searcher to sandwich this trade.

Proof of Concept

Manager.sol#L442-L452

Controller.sol#L273

Recommended Mitigation Steps

Always calculates an estimate return when calling to crv.

transferAndCall (yAxis) acknowledged

GalloDaSballo (judge) commented:

Agree with finding, agree with severity as this allows to “leak value”

The original report as published on Code4rena, by jonah1005. 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 contract does not specify a minimum return amount when calling Curve's swap function.

Impact

An attacker could sandwich the trade and leak value from user funds.

What the attacker needed

Access to mempool; ability to trade on Curve

The fix

The contract should always calculate an estimated return and pass it as a minimum when calling Curve.

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 contract trades on a decentralised exchange without setting a minimum amount it will accept, an attacker can buy just before the trade (pushing the price up) and sell just after (profiting from the inflated price). This is called a sandwich attack and it steals value from the original trade.

What is Smart contracts?

Flaws in on-chain code that let an attacker drain funds, freeze them or break the protocol's accounting.

More by jonah1005

View all

39 more disclosed reports, best first.

More from yAxis contest

View all

The newest disclosed reports for this program.

Similar reports

View all

Same bug class and techniques, clearest first.

Smart contract vulnerabilities

The lesson behind this report.

Flaws in on-chain code that let an attacker drain funds, freeze them or break the protocol's accounting.