Skip to content
Business logic Audit finding Intermediate

regerralFeePool is vulnerable to MEV searcher

The claimRewardAsMochi function in ReferralFeePoolV0 swaps and transfers assets without any slippage limit, so the amount received is not protected. An attacker could sandwich the transaction and take value from the user's reward claim.

jonah1005 Follow

Originally disclosed on Code4rena

Submitted by jonah1005, also found by cmichel

Impact

claimRewardAsMochi in the ReferralFeePoolV0 ignores slippage. This is not a desirable design. There are a lot of MEV searchers in the current network. Swapping assets with no slippage control would get rekted. Please refer to https://github.com/flashbots/pm.

Given the current state of the Ethereum network, users would likely be sandwiched. I consider this is a high-risk issue.

Proof of Concept

ReferralFeePoolV0.sol#L28-L48 Please refer to Mushrooms Finance Theft of Yield Bug Fix Postmortem | by Immunefi | Immunefi | Medium to see a possible attack pattern.

Recommended Mitigation Steps

I recommend adding minReceivedAmount as a parameter.

function claimRewardAsMochi(uint256 _minReceivedAmount) external {
    // original logic here
    require(engine.mochi().balanceOf(address(this)) > _minReceivedAmount, "!min");
    engine.mochi().transfer(
        msg.sender,
        engine.mochi().balanceOf(address(this))
    );
}

Also, the front-end should calculate the min amount with the current price.

ryuheimat (Mochi) confirmed

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 reward-claim function performs a swap and transfer with no minimum-received parameter, so the caller cannot bound the outcome.

Impact

Users claiming rewards would likely be sandwiched by MEV searchers and receive less than they should; the report rates this as high risk.

What the attacker needed

Victim claims a reward; attacker can front-run and back-run

The fix

A minimum-received parameter should be added to the claim function and the front-end should compute it from the current price.

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 or pays out tokens, it should state the least it will accept. Without that limit, someone watching the network can step in front of the trade and change the price, then step back and profit. This is called sandwiching, and the user ends up with less than expected.

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

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.