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.
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
- A new sale is started
- 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.solcontract. - Seller realizes his mistake and tries to cancel the sale as sale as not yet started using the
cancelfunction.
function cancel() external onlyOwner {
require(block.timestamp < sale.startTime, "TOO LATE");
_end(sale);
}
- This internally calls the
\_endfunction
function _end(Sale memory _sale) internal {
emit End(_sale);
ISaleFactory(factory).feeReceiver().transfer(address(this).balance / 20);
selfdestruct(_sale.saleReceiver);
}
- The
_endfunction 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
FixedPricecontract, where fees are not sent in case the owner cancels a sale.
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
- A new sale is started.
- Seller accidentally sends ETH to the contract via selfdestruct.
- Seller calls cancel before sale startTime.
- 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.