A reentrancy vulnerability has been discovered in the mintProfile()
function of the SoulboundProfileNFT contract. This security flaw allows an attacker to mint multiple NFT profiles when they should only be allowed one.
Place the following lines of code in the test folder testSoulboundProfileNFT.t.sol
:
Here is the contract of the attacker:
The attacker creates a malicious contract that implements onERC721Received
Attacker calls mintProfile()
for the first time
During _safeMint
, the contract calls back to the attacker's onERC721Received
In onERC721Received
, attacker calls mintProfile()
again
Second call succeeds because profileToToken[msg.sender]
hasn't been updated yet
The attacker ends up with multiple profiles when only one should be allowed
Users can create multiple profiles when they should only have one
Violates the core business logic of the dating app
Could lead to spam and fake profiles
Undermines the "soulbound" property of the NFT
Manual Review
Foundry: For the writing of test
Follows the Checks-Effects-Interactions pattern
Updates all state variables before making external calls
Even if the attacker tries to reenter, they'll be stopped by the initial require check
Ensures one profile per address rule is enforced
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.