The createAuction
function in the SpiceAuctionFactory
contract allows for the creation of new auction contracts and stores them in the deployedAuctions
mapping. However, the current implementation does not check if an auction already exists for a given spiceToken
. As a result, an existing auction can be inadvertently overwritten when creating a new auction, leading to loss of references to the previous auction contract.
No Check for Existing Auction: The line deployedAuctions[pairId] = address(spiceAuction);
does not check if an auction already exists for the given pairId
. This allows the new auction to overwrite the existing one in the deployedAuctions
mapping.
Lack of Safeguards: There is a comment /// @dev not checking pair address exists to allow overwrite in case of a migration
, indicating the intentional omission of this check. However, this opens up the possibility of overwriting existing auctions unintentionally.
Loss of Data: The reference to the previous auction is lost, which may contain important state information, history, or funds.
vs code
To prevent unintentional overwriting of existing auctions, the createAuction
function should include a check to ensure that an auction does not already exist for the given spiceToken
. If an auction already exists, the function should revert or require explicit confirmation to overwrite the existing auction.
Calculate a unique pair ID using the _getPairHash
function.
Check for Existing Auction:
Check if an auction already exists in the deployedAuctions
mapping for the calculated pair ID.
If an auction already exists, revert the transaction with an appropriate error message.
The contest is live. Earn rewards by submitting a finding.
This is your time to appeal against judgements on your submissions.
Appeals are being carefully reviewed by our judges.