Skip to content
Business logic Audit finding Intermediate

settleAuction() Check for status errors

The settleAuction function uses an incorrect logical condition (AND instead of OR) when checking auction state, so it can proceed even when there is no bid. This allows ClearingHouse.safeTransferFrom() to execute successfully without a valid auction.

bin2chen Follow with kaden

Originally disclosed on Code4rena

Submitted by bin2chen, also found by kaden

https://github.com/code-423n4/2023-01-astaria/blob/1bfc58b42109b839528ab1c21dc9803d663df898/src/CollateralToken.sol#L526-L534

ClearingHouse.safeTransferFrom() to execute successfully even if there is no bid.

Proof of Concept

settleAuction is called at the end of the auction and will check if the status is legal

  function settleAuction(uint256 collateralId) public {
    if (
      s.collateralIdToAuction[collateralId] == bytes32(0) &&
      ERC721(s.idToUnderlying[collateralId].tokenContract).ownerOf(
        s.idToUnderlying[collateralId].tokenId
      ) !=
      s.clearingHouse[collateralId]
    ) {
      revert InvalidCollateralState(InvalidCollateralStates.NO_AUCTION);
    }

This check seems to be miswritten,The normal logic would be

s.collateralIdToAuction[collateralId] == bytes32(0) || ERC721(s.idToUnderlying[collateralId].tokenContract).ownerOf(
        s.idToUnderlying[collateralId].tokenId
      ) == s.clearingHouse[collateralId]

This causes ClearingHouse.safeTransferFrom() to execute successfully even if there is no bid.

Recommended Mitigation Steps

  function settleAuction(uint256 collateralId) public {
    if (
-     s.collateralIdToAuction[collateralId] == bytes32(0) &&
-    ERC721(s.idToUnderlying[collateralId].tokenContract).ownerOf(
-        s.idToUnderlying[collateralId].tokenId
-      ) !=
-      s.clearingHouse[collateralId]
+      s.collateralIdToAuction[collateralId] == bytes32(0) ||
+       ERC721(s.idToUnderlying[collateralId].tokenContract).ownerOf(s.idToUnderlying[collateralId].tokenId
+      ) ==
+      s.clearingHouse[collateralId]
    ) {
      revert InvalidCollateralState(InvalidCollateralStates.NO_AUCTION);
    }

androolloyd (Astaria) confirmed

Picodes (judge) commented:

Keeping medium severity despite the lack of clear impact, the lack of clear impact being due to flaws in the flow before these lines.


The original report as published on Code4rena, by bin2chen. 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 condition uses logical AND instead of OR, so the revert only triggers when both sub-conditions are true rather than either one.

Impact

The auction settlement can proceed without a bid, allowing ClearingHouse.safeTransferFrom() to execute successfully; the judge kept medium severity despite the lack of clear impact.

What the attacker needed

None

The fix

The condition should be changed to use logical OR and compare ownership with equality, as shown in the recommended mitigation.

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.

In a smart contract, a function that ends an auction checks two things with 'AND' when it should use 'OR'. Because of this mistake, the function can run even when there is no bid, letting a transfer happen when it should not.

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 bin2chen

View all

139 more disclosed reports, best first.

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