Skip to content
Smart contracts Audit finding Intermediate

When relisting a floor item listing, listingCount is not increased, causing listingCount can be underflowed

The relist function for floor item listings does not increase the listingCount, so when such a listing is cancelled, the count is decremented and can underflow to a huge number. This prevents the collection shutdown execute function from working because it checks that listingCount is zero.

araj Follow with g, utsav and 1 other

Originally disclosed on Sherlock

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

Found by

araj, g, utsav, zraxx

Summary

https://github.com/sherlock-audit/2024-08-flayer/blob/main/flayer/src/contracts/Listings.sol#L625-L672 The relist function is used to refill the parameters of any token listings, including floor item listing. For a loor item listing, users can change its owner from address(0) to their own address without paying any fees, and set its type to DUTCH or LIQUID. However, this operation does not change listingCount. So, when all the listing is filled, the listingCount will be underflowed to a large num(close to uint256.max) instead of 0. Later, in the function CollectionShutdown.sol#execute, it will be reverted as listings.listingCount(_collection) != 0.

Root Cause

In Listings.sol#relist, when relist for a floor item listing, listingCount is not incresed, causing listingCount can be underflowed.

Internal pre-conditions

  1. The _collection is initialized.
  2. There are floor item listings in the _collection.

External pre-conditions

No response

Attack Path

  1. The attacker call relist for a floor item listing.
  2. The attacker immediately calls cancelListings to cancel it, in order to refund the tax. At the same time, listingCount is decreased. As a result, the listingCount cannot correctly reflect the number of listings contained in _collection.

Impact

listingCount cannot correctly reflect the number of listings contained in _collection. CollectionShutdown.sol#execute will be DOSed.

PoC

No response

Mitigation

Avoid relisting floor item listings OR Increase listingCount by one.

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

How it worked

Impact

The listingCount becomes incorrect and can underflow, causing CollectionShutdown.execute to be DOSed because it requires listingCount to be zero.

What the attacker needed

The collection is initialized; There are floor item listings in the collection

The fix

The fix is to either avoid relisting floor item listings or increase listingCount by one during relist.

How it was found

  1. The attacker calls relist for a floor item listing.
  2. The attacker immediately calls cancelListings to cancel it, which decreases listingCount.

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 keeps a count of how many listings exist for a collection. When you relist a special 'floor item' listing, the count is not increased, but when you cancel it, the count is decreased. This makes the count wrap around to a very large number, which stops a shutdown feature from working.

What is Smart contracts?

Flaws in on-chain code that let an attacker drain funds, freeze them or break the protocol's accounting.

More by araj

View all

2 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.

Smart contract vulnerabilities

The lesson behind this report.

Flaws in on-chain code that let an attacker drain funds, freeze them or break the protocol's accounting.