tokenId is not unique
The vulnerability in lines 195 to 211 is related to the minting of NFTs. The function mintNFT allows a user to mint an NFT for an active shortRecord. However, there is no check to ensure that the tokenId generated is unique. This could potentially allow a user to mint multiple NFTs with the same tokenId, leading to a collision in the tokenId space. This could result in unexpected behavior in the contract's functions that rely on tokenId for identifying and manipulating NFTs. This vulnerability could be exploited by an attacker to disrupt the normal functioning of the contract or to gain an unfair advantage.
vscode
To resolve this issue, you should add a check to ensure that the tokenId generated is unique. This can be done by maintaining a mapping of used tokenIds and checking against this mapping whenever a new tokenId is generated. If a collision is detected, the contract should revert the transaction and prevent the minting of the NFT. Here is a sample implementation:
In this code, usedTokenIds is a mapping that keeps track of all tokenIds that have been used. Before a new NFT is minted, the contract checks if the tokenId has been used before. If it has, the contract reverts the transaction with an error message. This ensures that all tokenIds are unique and prevents any potential collisions.
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.