Description
Normal behavior: NFT Dealers is an NFT marketplace where whitelisted users can mint NFTs by paying a USDC collateral, list them for resale, and collect proceeds. Non-whitelisted users can only buy listed NFTs. The owner can manage the whitelist, reveal the collection, and withdraw fees.
The contract has multiple security risks: owner abuse, reentrancy in USDC transfers, fee manipulation based on listing price, race conditions in listings, and redundant internal token transfers. These issues could lead to unauthorized minting, loss of funds, and inconsistent contract state.
Problem: The contract has multiple security risks:
Excessive owner privileges: the owner can manipulate the whitelist, reveal the collection, and withdraw all fees without restrictions.
Reentrancy in USDC payments: collectUsdcFromSelling and cancelListing transfer tokens before updating state, allowing recursive attacks.
Fee and price manipulation: _calculateFees depends directly on the listing price, allowing optimization attacks and potential inconsistencies in totalFeesCollected.
Race conditions in listings: multiple users interacting with the same NFT simultaneously can cause inconsistent state or payments.
Incorrect token transfers: usdc.safeTransfer(address(this), fees) is unnecessary and can confuse internal accounting.
Likelihood:
If the owner's wallet is compromised, an attacker can add malicious wallets to the whitelist and mint NFTs without limits.
Malicious users could attempt reentrancy attacks in collectUsdcFromSelling or cancelListing to steal funds or collaterals.
Price and fee manipulation could allow users to optimize commissions, causing losses in totalFeesCollected.
Impact:
Theft of NFTs or unauthorized minting.
Loss of USDC due to incorrect or duplicated fees.
Inconsistent listing states causing accounting errors or NFT lock-ups.
An attacker controls the owner account.
They whitelist their own wallet using whitelistWallet.
They mint NFTs multiple times using mintNft() without paying legitimate collateral
They call withdrawFees() to drain all accumulated fees.
Alternatively, a malicious user can deploy a contract that repeatedly calls collectUsdcFromSelling before state updates, stealing funds via reentrancy.
This demonstrates that both owner abuse and reentrancy attacks are feasible with the current code.
Explanation of mitigation:
These steps reduce risks by limiting owner powers through timelocks, preventing reentrancy with proper state updates, removing redundant transfers that confuse accounting, and validating prices/fees to protect financial correctness
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.
The contest is complete and the rewards are being distributed.