Lack of Input Validation for listing.created Parameter in Relisting
summary
When creating or modifying a listing, the listing.created parameter is overwritten with block.timestamp. However, during relisting, listing.created remains unchanged. This lack of validation can result in unintended behaviors, including listings being stuck indefinitely or incorrect deposits.
Scenario 1: Incorrect Deposit
Alice creates a listing for an NFT, and Bob later relists this NFT, setting the listing.created parameter to a past date (block.timestamp - listing.duration). This creates a large discount on the totalPrice, potentially causing it to be reduced to zero.
ownerReceives = 0 because (1e18) - (1e18)
_collectionToken.transferFrom(msg.sender, address(this), totalPr0ice);
will deposit 0
Scenario 2: DOS
when you relist with a listing.created in the future it will DOS the listing being unable to be filled or cancled due to underflow in tax calculation until the listing.created matches the block.timestamp
block.timestamp - listing.created (1209600 - 2160000000) will underflow because listing.created is in the future.
The listing would be able to be canceled in filled in 25 years.
impact
A listing with a created date in the future cannot be filled until the created date is reached plus the duration. This means that no action can be taken until the future timestamp is met, potentially preventing the listing from being processed correctly and causing delays.
If listing.created is set to a past date, it could cause problems with processing deposits, potentially preventing the correct amount from being deposited into the escrow.
Muscular Admiral Marmot
Low/Info
Lack of Input Validation for
listing.created
Parameter in Relistingsummary
When creating or modifying a listing, the
listing.created
parameter is overwritten withblock.timestamp
. However, during relisting,listing.created
remains unchanged. This lack of validation can result in unintended behaviors, including listings being stuck indefinitely or incorrect deposits.Scenario 1: Incorrect Deposit
Alice creates a listing for an NFT, and Bob later relists this NFT, setting the
listing.created
parameter to a past date (block.timestamp
-listing.duration
). This creates a large discount on the totalPrice, potentially causing it to be reduced to zero.discount = ( 1e18 * (86400 - 0) / 86400) = 1e18
The discount calculation will be:
This results in a totalPrice of 0 because 1e18 - 1e18:
In the
fillListings
function:ownerReceives = 0 because (1e18) - (1e18)
_collectionToken.transferFrom(msg.sender, address(this), totalPr0ice);
will deposit 0Scenario 2: DOS
when you relist with a
listing.created
in the future it will DOS the listing being unable to be filled or cancled due to underflow in tax calculation until thelisting.created
matches theblock.timestamp
block.timestamp
-listing.created
(1209600 - 2160000000) will underflow becauselisting.created
is in the future. The listing would be able to be canceled in filled in 25 years.impact
A listing with a created date in the future cannot be filled until the created date is reached plus the duration. This means that no action can be taken until the future timestamp is met, potentially preventing the listing from being processed correctly and causing delays.
If
listing.created
is set to a past date, it could cause problems with processing deposits, potentially preventing the correct amount from being deposited into the escrow.Code snippet
https://github.com/sherlock-audit/2024-08-flayer/blob/main/flayer/src/contracts/Listings.sol#L665
Remediation
In the
relisting
function inListings.sol
overwrite thelisting.created
totime.blockstamp
as done in creating/modifying listings.