Skip to content
Business logic Audit finding Intermediate

Value can be stuck in Adapters

The marketplace adapter functions are payable and forward a separate value argument to the marketplace without checking that it equals the ETH actually sent. If a caller sends more ETH than the value argument, the excess is not refunded and becomes stuck in the adapter.

gzeon Follow with ayeslick and Dravee

Originally disclosed on Code4rena

Submitted by gzeon, also found by ayeslick and Dravee

https://github.com/code-423n4/2022-11-paraspace/blob/c6820a279c64a299a783955749fdc977de8f0449/paraspace-core/contracts/misc/marketplaces/LooksRareAdapter.sol#L73-L94 https://github.com/code-423n4/2022-11-paraspace/blob/c6820a279c64a299a783955749fdc977de8f0449/paraspace-core/contracts/misc/marketplaces/SeaportAdapter.sol#L93-L107 https://github.com/code-423n4/2022-11-paraspace/blob/c6820a279c64a299a783955749fdc977de8f0449/paraspace-core/contracts/misc/marketplaces/X2Y2Adapter.sol#L88-L102

matchAskWithTakerBid is payable, it calls functionCallWithValue with the value parameter. There are no checks to make sure msg.value == value\, if excess value is sent user will not receive a refund.

Proof of Concept

https://github.com/code-423n4/2022-11-paraspace/blob/c6820a279c64a299a783955749fdc977de8f0449/paraspace-core/contracts/misc/marketplaces/LooksRareAdapter.sol#L73-L94

    function matchAskWithTakerBid(
        address marketplace,
        bytes calldata params,
        uint256 value
    ) external payable override returns (bytes memory) {
        bytes4 selector;
        if (value == 0) {
            selector = ILooksRareExchange.matchAskWithTakerBid.selector;
        } else {
            selector = ILooksRareExchange
                .matchAskWithTakerBidUsingETHAndWETH
                .selector;
        }
        bytes memory data = abi.encodePacked(selector, params);
        return
            Address.functionCallWithValue(
                marketplace,
                data,
                value,
                Errors.CALL_MARKETPLACE_FAILED
            );
    }

Same code exists in LooksRareAdapter, SeaportAdapter, and X2Y2Adapter.

Recommended Mitigation Steps

Check msg.value == value If the function is only supposed to be delegate called into, consider adding a check to prevent direct call.


The original report as published on Code4rena, by gzeon. 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 payable adapter functions forward the caller-supplied value argument without verifying it equals msg.value, so surplus ETH is neither forwarded nor refunded.

Impact

A user who sends more ETH than the value argument could lose the excess, which remains stuck in the adapter contract.

What the attacker needed

Caller sends more ETH than the value argument

The fix

The adapter should check that msg.value equals the value argument, and consider blocking direct calls if it is only meant to be delegate called.

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 call a payable function in a smart contract, you can attach some cryptocurrency (ETH) to the call. Here the function takes a separate number saying how much ETH to pass on to the marketplace, but it never checks that this number matches what was actually sent. Any extra ETH stays locked in the adapter contract instead of going back to the user.

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 gzeon

View all

46 more disclosed reports, best first.

More from ParaSpace 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.