NFT Dealers

First Flight #58
Beginner FriendlyFoundry
100 EXP
Submission Details
Impact: medium
Likelihood: medium

Unnecessary `payable` on Non-ETH Functions

Author Revealed upon completion

Root + Impact

Description

  • The mintNft and buy functions are marked as payable even though they only handle USDC transfers and don't accept ETH. This could lead to users accidentally sending ETH that would be permanently locked in the contract.

function mintNft() external payable onlyWhenRevealed onlyWhitelisted {
if (msg.sender == address(0)) revert InvalidAddress();
require(tokenIdCounter < MAX_SUPPLY, "Max supply reached");
require(msg.sender != owner, "Owner can't mint NFTs");
require(usdc.transferFrom(msg.sender, address(this), lockAmount), "USDC transfer failed");
tokenIdCounter++;
collateralForMinting[tokenIdCounter] = lockAmount;
_safeMint(msg.sender, tokenIdCounter);
}
function buy(uint256 _listingId) external payable {
Listing memory listing = s_listings[_listingId];
if (!listing.isActive) revert ListingNotActive(_listingId);
require(listing.seller != msg.sender, "Seller cannot buy their own NFT");
activeListingsCounter--;
bool success = usdc.transferFrom(msg.sender, address(this), listing.price);
require(success, "USDC transfer failed");
_safeTransfer(listing.seller, msg.sender, listing.tokenId, "");
s_listings[_listingId].isActive = false;
emit NFT_Dealers_Sold(msg.sender, listing.price);
}

Risk

Impact

  • Users could accidentally send ETH to these functions, which would be permanently locked in the contract with no withdrawal mechanism. This represents a loss of user funds.

Proof of Concept

no need

Recommended Mitigation

+ function mintNft() external onlyWhenRevealed onlyWhitelisted {
...
...
}
+ function buy(uint256 _listingId) external {
...
...
}

Support

FAQs

Can't find an answer? Chat with us on Discord, Twitter or Linkedin.

Give us feedback!