SoulBoundProfileNFT:MintProfile()
updates a state variable after minting, allowing a user to mint NFTs repeatedly. This can lead to a denial-of-service (DoS) attack, where malicious actors can exhaust the contract's resources or prevent legitimate users from minting NFTs.
The vulnerability lies in the order of operations within the mintProfile()
function. The profileToToken[msg.sender] = tokenId; state variable update, which prevents re-minting, is performed after the _safeMint()
call and the metadata storage. This means that a user could potentially trigger multiple mints before the protection mechanism kicks in. A malicious user could create a smart contract that receives ERC721 tokens and repeatedly calls mintProfile()
while receiving tokens. This could lead to the contract minting many NFTs for the same profile.
Proof of Code:
DoS: Repeated minting, potentially through a malicious contract, can inflate the token supply, exhaust the contract's resources (e.g., storage), and prevent legitimate users from minting their own profile NFTs due to exceeding the maximum supply (if there is one) or increased gas costs.
Incorrect State: While the proof of code does not describe this, there's also a risk that the profileToToken mapping can contain incorrect values, making it difficult to accurately track profile ownership.
Solidity
Foundry (for testing)
Follow CEI, update state variable before minting.
Likelihood: High, anyone can do it. Impact: Low, several profile will be minted, which is not allowed by the protocol, but only the last one will be stored in profileToToken and won't affect `likeUser` or `matchRewards`.
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.