Skip to content
Business logic Audit finding Intermediate

`reserve()` doesn't deletes the `_isLiquidation` mapping, causing tax loss for owner in future

0x37 Follow with BADROBINX, BugPull and 7 others

Originally disclosed on Sherlock

Source: https://github.com/sherlock-audit/2024-08-flayer-judging/issues/698

Found by

0x37, BADROBINX, BugPull, Ollam, araj, cawfree, h2134, kuprum, utsav, zzykxx

Summary

reserve() doesn't deletes the _isLiquidation mapping, causing tax loss for owner in future

Vulnerability Detail

When a user reserve() a tokenId, it doesn't deletes the _isLiquidation mapping.

Solidity
    function reserve(address _collection, uint _tokenId, uint _collateral) public nonReentrant lockerNotPaused {
//
        // Check if the listing is a floor item and process additional logic if there
        // was an owner (meaning it was not floor, so liquid or dutch).
        if (oldListing.owner != address(0)) {
            // We can process a tax refund for the existing listing if it isn't a liquidation
            if (!_isLiquidation[_collection][_tokenId]) {
                (uint _fees,) = _resolveListingTax(oldListing, _collection, true);
                if (_fees != 0) {
                    emit ListingFeeCaptured(_collection, _tokenId, _fees);
                }
            }

            // If the floor multiple of the original listings is different, then this needs
            // to be paid to the original owner of the listing.
            uint listingFloorPrice = 1 ether * 10 ** collectionToken.denomination();
            if (listingPrice > listingFloorPrice) {
                unchecked {
                    collectionToken.transferFrom(msg.sender, oldListing.owner, listingPrice - listingFloorPrice);
                }
            }

            // Reduce the amount of listings
            unchecked { listingCount[_collection] -= 1; }
        }
//
    }

Let's go step by step to see how this will create problem for the owner:

  1. Suppose a token is liquidated, which set the _isLiquidation = true for that tokenId in listing.sol
  2. A user reserved that tokenId(_isLiquidation is not deleted) & withdrawn that token from protectedListing.sol
  3. He listed that tokenId in listing.sol paying tax amount.
  4. Now, if that tokenId is filled then owner should get tax refund amount(if any) but will not receive due to _isLiquidation = true for that tokenId.
Solidity
 function _fillListing(address _collection, address _collectionToken, uint _tokenId) private {
//
        if (_listings[_collection][_tokenId].owner != address(0)) {
            // Check if there is collateral on the listing, as this we bypass fees and refunds
            if (!_isLiquidation[_collection][_tokenId]) {
                // Find the amount of prepaid tax from current timestamp to prepaid timestamp
                // and refund unused gas to the user.
>                (uint fee, uint refund) = _resolveListingTax(_listings[_collection][_tokenId], _collection, false);
                emit ListingFeeCaptured(_collection, _tokenId, fee);
//
    }

Impact

Lose of tax amount for the user

Code Snippet

https://github.com/sherlock-audit/2024-08-flayer/blob/main/flayer/src/contracts/Listings.sol#L501C12-L510C18 https://github.com/sherlock-audit/2024-08-flayer/blob/main/flayer/src/contracts/Listings.sol#L690C4-L759C6

Tool used

Manual Review

Recommendation

Delete the _isLiquidation mapping in reserve()

The original report as published on Sherlock, by 0x37. Images and videos are our own copies; raw HTML is shown as text. View it on Sherlock.

Not written yet. The AI write-up for this report has not been written yet. The Original tab links to the source.

What is known

A high-severity business logic bug in Flayer. Sherlock made it public on 10 October 2024. Found in the 468 audit contest (finding H-22), also found by 9 other wardens.

About Business logic

The application works as coded but not as intended: a negative price, a skipped payment step, a limit that can be crossed.

Not written yet. The AI write-up for this report has not been written yet. The Original tab links to the source.

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 0x37

View all

79 more disclosed reports, best first.

More from Flayer

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.