DeFiFoundry
60,000 USDC
View results
Submission Details
Severity: high
Invalid

Missing tokenId Check in AccountNFT Contract

Summary

The AccountNFT contract does not check for the existence of a tokenId before minting a new NFT. This can lead to the minting of duplicate NFTs with the same tokenId, causing data integrity issues and potentially being exploited by attackers.

Vulnerability Details

In the mint function, there is no mechanism to ensure that the tokenId has not been used before. When an NFT is minted with an existing tokenId, it will overwrite the existing NFT, leading to data loss and potentially other unintended consequences.

https://github.com/Cyfrin/2024-07-zaros/blob/main/src/account-nft/AccountNFT.sol#L18-L21

function mint(address to, uint256 tokenId) external onlyOwner {
// intentionally not using _safeMint
_mint(to, tokenId);
}

Impact

Users could lose their NFTs if a new NFT is minted with the same tokenId.

Tools Used

Manual review

Recommendations

Add logic to the mint function to check if the tokenId already exists before minting. This can be done by using a mapping to store used tokenIds.

mapping(uint256 => bool) private _usedTokenIds;
function mint(address to, uint256 tokenId) external onlyOwner {
require(!_usedTokenIds[tokenId], "Token ID already used");
_usedTokenIds[tokenId] = true;
_mint(to, tokenId);
}
Updates

Lead Judging Commences

inallhonesty Lead Judge
11 months ago
inallhonesty Lead Judge 10 months ago
Submission Judgement Published
Invalidated
Reason: Incorrect statement

Support

FAQs

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