The SoulboundProfileNFT.sol::mintProfile() function violates the Checks-Effects-Interactions (CEI) pattern by calling _safeMint() before updating state variables. Since _safeMint() in OpenZeppelin’s ERC721 contract can call external smart contracts, this introduces a reentrancy risk where an attacker could reenter mintProfile() before the mappings are updated.
In SoulboundProfileNFT.sol::mintProfile() function the _safeMint(msg.sender, tokenId); executes beforeprofileToToken[msg.sender] and _profiles[tokenId] are updated. If msg.sender is a smart contract, _safeMint() will trigger a call to the onERC721Received() hook, allowing reentrant execution. A malicious contract could exploit this to reenter**mintProfile()** before the state updates, bypassing the single-profile restriction and minting multiple NFTs.
Add the following AttackerContract and test to the SoulboundProfileNFT.t.sol.
A malicious smart contract could mint multiple profile NFTs by reentering before state updates occur.
The NFT could be minted without a corresponding _profiles entry, leading to metadata inconsistencies.
Since _safeMint() interacts with external contracts, unforeseen vulnerabilities could arise.
Manual review
Foundry
Follow the CEI pattern to prevent reentrancy and update state variables before calling _safeMint():
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.