It's not strange for people that had a bad time with dating apps to try and ruin the fun for everybody else that's actually trying to achieve some level of connection. Due to not following CEI on SoulboundProfileNFT::mintProfile
an attacker could create hundreds or thousands of profiles with different names, ages and even use thispersondoesnotexist to pull a profile image for each.
If for every 1 real person there are 10 fakes, the dapp would be annoying to use, if it's 1:100 or 1:1000 it would be borderline unusable, since there's no way to know who's real or who's not without trying to like them, which considering the "[H-2] No functionality to unlike users in LikeRegistry.sol
makes funds stuck until someone likes you back" issue, it would be quite a costly gamble.
First, create a ReentrancyAttacker.sol
contract:
Add these changes on SoulboundProfileNFT.sol
:
Add console
to do some logging:
Add a log to see what tokenIds are being minted on mintProfile
:
For convenience, add a getter function for getting the profileToToken
variable in SoulboundProfileNFT.sol
:
Now onto the test:
Import the ReentrancyAttacker.sol
into testSoulboundProfileNFT.t.sol
:
Copy this test:
If the test is run with -vv
at the end, the logs can be seen to go from 1 to 99, while the attackerProfile
variable displays 1. If run with -vvvv
, it can be seen that it emits ProfileMinted(user: ReentrancyAttacker: [0x2e234DAe75C793f67A35089C9d99245E1C58470b], tokenId: 1, name: "Alan", age: 24, profileImage: "ipfs://profileImage")
for tokenIds 1 through 99, but ultimately only tokenId 1 is attached to the attacker address.
If later the user or owner burn the profile, it's only tokenId 1 that gets deleted, not all the other tokens since the deletion process only targets address => tokenId and doesn't allow to delete tokenIds directly. Therefore, the other 99 Alans are to remain in the dapp forever.
Correctly apply CEI on SoulboundProfileNFT::mintProfile
:
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.