Skip to content
Smart contracts Audit finding Advanced

feePool is vulnerable to sandwich attack.

The fee pool contract has a permissionless function that distributes funds without slippage control, allowing an attacker to sandwich the distribution with a flash loan to steal the funds.

jonah1005 Follow

Originally disclosed on Code4rena

Submitted by jonah1005

Impact

There’s a permissionless function distributeMochi in FeePoolV0.sol L55-L62. Since everyone can trigger this function, an attacker can launch a sandwich attack with flashloan to steal the funds.

The devs have mentioned this concern in the comment. An attacker can steal the funds with a flash loan attack.

Attackers can steal all the funds in the pool. I consider this is a high-risk issue.

Proof of Concept

FeePoolV0.sol#L55-L62

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

If the dev wants to make this a permissionless control, the contract should calculate a min return based on TWAP and check the slippage.

Comments:

ryuheimat (Mochi) disputed:

I think this is same case as https://github.com/code-423n4/2021-10-mochi-findings/issues/60

ghoul-sol (judge) commented:

The same attack, different part of the code. I’ll keep them both.

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

Likely the distributeMochi function performs a swap or distribution without any minimum return or slippage check, so an attacker can manipulate the price around it.

Impact

An attacker could steal all the funds in the pool using a flash loan.

What the attacker needed

Permissionless function; flash loan available

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.

A sandwich attack is when someone sees your trade and places their own trades before and after yours to profit from the price change. Here, a function that moves funds can be triggered by anyone, and because it does not check the price, an attacker can use borrowed money (a flash loan) to manipulate the price and take the funds.

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 Mochi 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.