Skip to content
Business logic Audit finding Intermediate

Missing a check for minimum sell amount at the make function

The make function calls an offer function that lacks the minimum sell amount (dust) check present in the other offer function. An attacker could create dust offers with very small pay amounts, bypassing the intended minimum.

Evo Follow with said

Originally disclosed on Code4rena

Submitted by Evo, also found by said.

There is a check for _dust amount inside offer function at L835 but not inside the other offer function being called by the make function at L511.

The make function will not avoid dust offers.

Proof of Concept

https://github.com/code-423n4/2023-04-rubicon/blob/main/contracts/RubiconMarket.sol#L511-L562 There is no check for _dust inside offer function. The minimum sell amount should be set for a token to avoid dust offers as the concept applies.

    function offer(
        uint256 pay_amt,
        ERC20 pay_gem,
        uint256 buy_amt,
        ERC20 buy_gem,
        address owner,
        address recipient
    ) public virtual can_offer synchronized returns (uint256 id) {
        require(uint128(pay_amt) == pay_amt);
        require(uint128(buy_amt) == buy_amt);
        require(pay_amt > 0);
        require(pay_gem != ERC20(address(0))); /// @dev Note, modified from: require(pay_gem != ERC20(0x0)) which compiles in 0.7.6
        require(buy_amt > 0);
        require(buy_gem != ERC20(address(0))); /// @dev Note, modified from: require(buy_gem != ERC20(0x0)) which compiles in 0.7.6
        require(pay_gem != buy_gem);

        OfferInfo memory info;
        info.pay_amt = pay_amt;
        info.pay_gem = pay_gem;
        info.buy_amt = buy_amt;
        info.buy_gem = buy_gem;
        info.recipient = recipient;
        info.owner = owner;
        info.timestamp = uint64(block.timestamp);
        id = _next_id();
        offers[id] = info;

        require(pay_gem.transferFrom(msg.sender, address(this), pay_amt));

        emit LogItemUpdate(id);

        /// emit LogMake(
        ///     bytes32(id),
        ///     keccak256(abi.encodePacked(pay_gem, buy_gem)),
        ///     msg.sender,
        ///     pay_gem,
        ///     buy_gem,
        ///     uint128(pay_amt),
        ///     uint128(buy_amt),
        ///     uint64(block.timestamp)
        /// );

        emit emitOffer(
            bytes32(id),
            keccak256(abi.encodePacked(pay_gem, buy_gem)),
            msg.sender,
            pay_gem,
            buy_gem,
            uint128(pay_amt),
            uint128(buy_amt)
        );
    }

As you can see, it is also applied in the other offer function at L835.

   require(_dust[address(pay_gem)] <= pay_amt);

Recommended Mitigation Steps

Add the check condition below to the offer function that called the make function:

   require(_dust[address(pay_gem)] <= pay_amt);

daoio (Rubicon) confirmed


The original report as published on Code4rena, by Evo. 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 offer function called by make is missing the require statement that enforces the minimum sell amount (_dust) for the pay token.

What the attacker needed

None

The fix

Add the same minimum sell amount check to the offer function called by make.

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 smart contract has two ways to create a sell offer. One way checks that the amount you are selling is not too tiny (a 'dust' amount), but the other way does not. This means someone could create offers with extremely small amounts, which the contract was supposed to prevent.

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 Evo

View all

7 more disclosed reports, best first.

More from Rubicon v2

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.