Skip to content
Business logic Audit finding Intermediate

Migrator severily underestimates slippage by using underlying instead of shares

The Migrator contract's slippage protection used the underlying token amount instead of the corresponding share amount when minting mTokens. Because the exchange rate is around 0.02, the minimum collateral check was off by at least an order of magnitude, allowing a user to receive far fewer shares than intended during migration.

10ap17 Follow with Angry_Mustache_Man, LeFy and 5 others

Originally disclosed on Sherlock

Source: https://github.com/sherlock-audit/2025-07-malda-judging/issues/91

Found by

10ap17, Angry_Mustache_Man, LeFy, WillyCode20, cergyk, elolpuer, pashap9990, vangrim

Description

Migrator.sol implements a slippage protection:

Migrator.sol#L90-L100:

Solidity
    // 2. Mint mTokens in all v2 markets
    for (uint256 i; i < posLength; ++i) {
        Position memory position = positions[i];
        if (position.collateralUnderlyingAmount > 0) {
            //@audit compute slippage value
            uint256 minCollateral =
                position.collateralUnderlyingAmount - (position.collateralUnderlyingAmount * 1e4 / 1e5);
            ImErc20Host(position.maldaMarket).mintOrBorrowMigration(
                true, position.collateralUnderlyingAmount, msg.sender, address(0), minCollateral
            );
        }
    }

Unfortunately, the slippage value computed uses underlying tokens, whereas the shares amount should be used. Since exchange rate should be close to 0.02, the slippage parameter is wrong by at least an order of magnitude.

Recommendation

Underlying amount should be divided by exchange rate to have a correct slippage value: Migrator.sol#L90-L100:

Diff
    // 2. Mint mTokens in all v2 markets
    for (uint256 i; i < posLength; ++i) {
        Position memory position = positions[i];
        if (position.collateralUnderlyingAmount > 0) {
-            uint256 minCollateral =
-                position.collateralUnderlyingAmount - (position.collateralUnderlyingAmount * 1e4 / 1e5);
+            uint256 minCollateral =
+                div_(position.collateralUnderlyingAmount - (position.collateralUnderlyingAmount * 1e4 / 1e5), _exchangeRate);
            ImErc20Host(position.maldaMarket).mintOrBorrowMigration(
                true, position.collateralUnderlyingAmount, msg.sender, address(0), minCollateral
            );
        }
    }

Discussion

sherlock-admin2

The protocol team fixed this issue in the following PRs/commits: https://github.com/malda-protocol/malda-lending/pull/120

CergyK

Fix looks good, underlying was converted to shares using exchangeRate

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

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

Impact

A user migrating positions could receive significantly fewer shares than expected because the minimum collateral check was too low by at least an order of magnitude.

What the attacker needed

Migration of a position with collateral

The fix

The issue was fixed by converting the underlying amount to shares using the exchange rate before passing it as the minimum collateral value.

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 you deposit tokens into a lending pool, you get pool shares that represent your deposit. The number of shares you get depends on an exchange rate. This code tried to protect users from getting too few shares, but it compared the wrong number (the token amount instead of the share amount), so the protection was far too weak.

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 10ap17

View all

2 more disclosed reports, best first.

More from Malda

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.