Skip to content
Business logic Audit finding Beginner

Initial deploy won’t succeed because of too high initialMintAmount for USDC market

The deployment script hardcodes a single initial mint amount of one ether for every token market, which is sensible for WETH but represents an absurdly large quantity of USDC. Because the deployer would not hold that much USDC, the approval and mint calls during initial deployment would fail.

T1MOH Follow with immeas

Originally disclosed on Code4rena

Submitted by T1MOH, also found by immeas

At the time of deploy, deployer initializes token markets with initial amount to prevent exploit. At least USDC and WETH markets will be initialized during deploy. But initialMintAmount is hardcoded to 1e18 which is of for WETH (1,876 USD), but unrealistic for USDC (1,000,000,000,000 USD). Therefore deploy will fail.

Proof of Concept

Here initialMintAmount = 1 ether: https://github.com/code-423n4/2023-07-moonwell/blob/fced18035107a345c31c9a9497d0da09105df4df/test/proposals/Configs.sol#L55

    /// @notice initial mToken mint amount
    uint256 public constant initialMintAmount = 1 ether;

Here this amount is approved to MToken contract and supplied to mint MToken: https://github.com/code-423n4/2023-07-moonwell/blob/fced18035107a345c31c9a9497d0da09105df4df/test/proposals/mips/mip00.sol#L334-L379

            for (uint256 i = 0; i < cTokenConfigs.length; i++) {
                Configs.CTokenConfiguration memory config = cTokenConfigs[i];

                address cTokenAddress = addresses.getAddress(
                    config.addressesString
                );

               ...

                /// Approvals
                _pushCrossChainAction(
                    config.tokenAddress,
                    abi.encodeWithSignature(
                        "approve(address,uint256)",
                        cTokenAddress,
                        initialMintAmount
                    ),
                    "Approve underlying token to be spent by market"
                );

                /// Initialize markets
                _pushCrossChainAction(
                    cTokenAddress,
                    abi.encodeWithSignature("mint(uint256)", initialMintAmount),
                    "Initialize token market to prevent exploit"
                );

                ...
            }

Recommended Mitigation Steps

Specify initialMintAmount for every token separately in config

ElliotFriedman (Moonwell) confirmed, but disagreed with severity and commented:

Valid issue, but we have already fixed this. Probably a low severity issue as this deploy script was only configured to work on local testnets where we control the ERC20 tokens.

alcueca (Judge) commented:

The issue is still valid as Medium with the code and knowledge available to the wardens.


The original report as published on Code4rena, by T1MOH. 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 deployment configuration used a single hardcoded initial mint amount for all token markets instead of a per-token value scaled to each token's decimals and price.

Impact

The initial deployment would fail for the USDC market (and likely others), blocking the protocol from launching; the maintainer noted the script was only intended for local testnets they control, so no funds were at risk.

What the attacker needed

Deployment script run as configured; deployer lacks the huge token amount

The fix

The maintainer said the issue was already fixed; the recommended approach is to set the initial mint amount per token in the configuration.

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 lending market is first set up, the deployer puts in a small starting amount of the token so nobody can exploit an empty market. The script used one fixed number for all tokens, but tokens differ wildly in value: one unit of WETH is worth a lot, while one unit of USDC is worth about a dollar. So the same number meant a tiny sum for one token and a trillion-dollar sum for the other, and the setup would simply fail.

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 T1MOH

View all

11 more disclosed reports, best first.

More from Moonwell

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.