Skip to content
Business logic Audit finding Intermediate

A single emissionCap is not suitable for different tokens reward if they have different underlying decimals

The MultiRewardDistributor contract uses a single emissionCap of 100e18 for all reward tokens, regardless of their decimal places. This means tokens with fewer than 18 decimals (e.g., USDT with 6, GUSD with 2) are effectively not bounded by the cap, while tokens with more than 18 decimals would be practically impossible to emit.

0xWaitress Follow

Originally disclosed on Code4rena

Submitted by 0xWaitress

At MultiRewardDistributor, different rewards token can be set up for each mToken, which is the assetToken or debtToken of the lending protocol. When a reward token is set up, it’s emission speed cannot be bigger than the emissionCap (100 * 1e18 as suggested in the code comment). However since multiple reward tokens may be set up, and they may have different decimal places, for example USDT has a decimal of 6 and GUSD even has a decimal of 2 they are virtually not bounded by such emissionCap.

On the contract, tokens with more than 18 decimal would not be practically emitted. This one-size-fit-all emissionCap might create obstacles for the protocol to effectively manage each rewardTokens.

    /// @notice The emission cap dictates an upper limit for reward speed emission speed configs
    /// @dev By default, is set to 100 1e18 token emissions / sec to avoid unbounded
    ///  computation/multiplication overflows
    uint256 public emissionCap;
    function _updateBorrowSpeed(
        MToken _mToken,
        address _emissionToken,
        uint256 _newBorrowSpeed
    ) external onlyEmissionConfigOwnerOrAdmin(_mToken, _emissionToken) {
        MarketEmissionConfig
            storage emissionConfig = fetchConfigByEmissionToken(
                _mToken,
                _emissionToken
            );

        uint256 currentBorrowSpeed = emissionConfig
            .config
            .borrowEmissionsPerSec;

        require(
            _newBorrowSpeed != currentBorrowSpeed,
            "Can't set new borrow emissions to be equal to current!"
        );
        require(
            _newBorrowSpeed < emissionCap,
            "Cannot set a borrow reward speed higher than the emission cap!"
        );

https://github.com/code-423n4/2023-07-moonwell/blob/main/src/core/MultiRewardDistributor/MultiRewardDistributor.sol#L703-L725

Recommended Mitigation Steps

Consider creating emissionCap for each rewardTokens so they can be adapted based on their own decimals.

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

This is a known issue, the amount of tokens created is bounded 100e18 per second. then, reward speeds will be integration tested to ensure they are properly configured.

alcueca (Judge) commented:

@ElliotFriedman, I’m not sure if you understood the finding. How would you set up the emissions cap if emissions are in USDT (6 decimals) and WETH (18 decimals).

ElliotFriedman (Moonwell) commented:

Valid issue, just a question of is it medium severity. I’ll leave that for judges to decide.

alcueca (Judge) commented:

Function incorrect as to spec would be QA - This means that if the way the code works is wrong but has no real impact in the business it is QA.

Function of the protocol or its availability possibly impacted would be Medium - In certain cases, the emissionsCap will either not work or stop emissions, the protocol is impacted in a non-lethal manner, and the finding is medium.

lyoungblood (Warden) commented:

Good finding - disagree with the severity as the cap is just a safety feature that didn’t exist at all in the original Compound.


The original report as published on Code4rena, by 0xWaitress. 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

Impact

The emission cap may not work for tokens with fewer than 18 decimals, allowing higher-than-intended emissions, or may stop emissions for tokens with more than 18 decimals, impacting the protocol's reward distribution.

What the attacker needed

Multiple reward tokens with different decimals; emission configuration owner or admin role

The fix

The emissionCap should be set per reward token, adapted to each token's decimals.

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 reward token is a cryptocurrency given as a bonus. The contract sets a maximum speed for giving out these bonuses, but it uses the same number for every token. Tokens can have different numbers of decimal places, so the same maximum number means very different things for each token.

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 0xWaitress

View all

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