Skip to content
Business logic Audit finding Intermediate

Inconsistency in fees

The FixedPrice contract deducts a fee from the contract balance when a seller cancels a sale before its start time, even though no sale has occurred. This could lead to loss of funds for the seller if they accidentally sent ETH to the contract.

Anurag Jain Follow

Originally disclosed on Code4rena

Submitted by csanuragjain

If the seller cancels before the sale startTime then all funds should be moved to saleReceiver without any deduction (Assuming seller has sent some ETH accidentally before sell start). But in FixedPrice.sol contract, fees are deducted even when seller cancels before the sale startTime which could lead to loss of funds.

Proof of Concept

  1. A new sale is started
  2. Seller selfdestructed one of his personal contracts and by mistake gave this sale contract as receiver. This forcefully sends the remaining 20 ETH to the FixedPrice.sol contract.
  3. Seller realizes his mistake and tries to cancel the sale as sale as not yet started using the cancel function.
function cancel() external onlyOwner {
        require(block.timestamp < sale.startTime, "TOO LATE");
        _end(sale);
    }
  1. This internally calls the \_end function
function _end(Sale memory _sale) internal {
        emit End(_sale);
        ISaleFactory(factory).feeReceiver().transfer(address(this).balance / 20);
        selfdestruct(_sale.saleReceiver);
    }
  1. The _end function deducts fees of 20/20=1 ETH even though seller has cancelled before the sale starts.

Recommended Mitigation Steps

Revise the cancel function

function cancel() external onlyOwner {
        require(block.timestamp < sale.startTime, "TOO LATE");
        emit End(_sale);
        selfdestruct(_sale.saleReceiver);
    }

stevennevins (Escher) disagreed with severity and commented:

Marking as Low as it seems pretty unlikely of a scenario.

berndartmueller (judge) commented:

I consider Medium severity appropriate because fees are sent to the receiver even though a sale has not started yet. This also clearly deviates from the implementation in the FixedPrice contract, where fees are not sent in case the owner cancels a sale.


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

The cancel function calls _end, which unconditionally sends a fee to the feeReceiver, without checking whether the sale has started.

Impact

The seller loses funds because a fee is deducted even though the sale never started; the report notes this could lead to loss of funds.

What the attacker needed

Seller has sent ETH to the contract; sale not yet started; seller calls cancel

The fix

The cancel function should be revised to not call _end (which deducts fees) but instead directly emit an event and selfdestruct to the saleReceiver.

How it was found

  1. A new sale is started.
  2. Seller accidentally sends ETH to the contract via selfdestruct.
  3. Seller calls cancel before sale startTime.
  4. The cancel function calls _end, which deducts a fee.

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 holds money for a sale. If the seller cancels before the sale starts, the contract still takes a cut as a fee, even though no sale happened. This means the seller loses some of their own money.

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 Anurag Jain

View all

63 more disclosed reports, best first.

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