DatingDapp

AI First Flight #6
Beginner FriendlyFoundrySolidityNFT
EXP
View results
Submission Details
Severity: medium
Valid

Blocked users can immediately mint a new profile, making the block mechanism ineffective

Blocked users can immediately mint a new profile, making the block mechanism ineffective

Description

The SoulboundProfileNFT::blockProfile function is intended to remove malicious or unwanted users from the platform. However, after blocking a user, their profileToToken mapping is deleted (set to 0). Since SoulboundProfileNFT::mintProfile only checks that profileToToken[msg.sender] == 0, a blocked user can immediately call SoulboundProfileNFT::mintProfile again and create a new profile.

function blockProfile(address blockAddress) external onlyOwner {
uint256 tokenId = profileToToken[blockAddress];
require(tokenId != 0, "No profile found");
_burn(tokenId);
@> delete profileToToken[blockAddress]; // Sets to 0, allowing re-mint
delete _profiles[tokenId];
emit ProfileBurned(blockAddress, tokenId);
}
function mintProfile(string memory name, uint8 age, string memory profileImage) external {
@> require(profileToToken[msg.sender] == 0, "Profile already exists"); // Blocked user passes this check
uint256 tokenId = ++_nextTokenId;
_safeMint(msg.sender, tokenId);
// ...
}

Risk

Likelihood:

  • Any blocked user who wants to continue using the platform will simply call SoulboundProfileNFT::mintProfile again

Impact:

  • The blocking mechanism is completely ineffective - blocked users can rejoin immediately

  • Owner has no way to permanently remove bad actors from the platform

  • Undermines platform moderation and user safety

Proof of Concept

  1. User mints a profile NFT

  2. Owner calls SoulboundProfileNFT::blockProfile to block the user

  3. User immediately calls SoulboundProfileNFT::mintProfile to mint a new profile NFT

Add the following test to testSoulboundProfileNFT.sol

function testBlockedUserCanRemint() public {
// user creates a profile
vm.prank(user);
soulboundNFT.mintProfile("Alice", 25, "ipfs://alice");
assertEq(soulboundNFT.profileToToken(user), 1);
// Owner blocks user
vm.prank(owner);
soulboundNFT.blockProfile(user);
// user's profile is deleted
assertEq(soulboundNFT.profileToToken(user), 0);
// user immediately mints a new profile
vm.prank(user);
soulboundNFT.mintProfile("NotAlice", 26, "ipfs://totallynotmalicious");
// user is back on the platform
assertEq(soulboundNFT.profileToToken(user), 2);
}

Recommended Mitigation

Add a blocklist mapping to permanently prevent blocked addresses from minting:

+ mapping(address => bool) public blockedAddresses;
function blockProfile(address blockAddress) external onlyOwner {
uint256 tokenId = profileToToken[blockAddress];
require(tokenId != 0, "No profile found");
+ blockedAddresses[blockAddress] = true;
_burn(tokenId);
delete profileToToken[blockAddress];
delete _profiles[tokenId];
emit ProfileBurned(blockAddress, tokenId);
}
function mintProfile(string memory name, uint8 age, string memory profileImage) external {
+ require(!blockedAddresses[msg.sender], "Address is blocked");
require(profileToToken[msg.sender] == 0, "Profile already exists");
// ...
}
Updates

Lead Judging Commences

ai-first-flight-judge Lead Judge about 20 hours ago
Submission Judgement Published
Validated
Assigned finding tags:

[M-01] `SoulboundProfileNFT::blockProfile` make it possible to recreate the profile

## Description The `SoulboundProfileNFT::blockProfile` function uses `delete profileToToken[blockAddress]`, which resets `profileToToken[blockAddress]` to `0`. Since the mintProfile function checks for an existing profile by verifying that `profileToToken[msg.sender] == 0`, a blocked account can be recreated by simply minting a new profile. This behavior bypasses the intended permanent block functionality. ## Vulnerability Details By deleting the mapping entry for a blocked account, the contract inadvertently allows a new mintProfile call to pass the check `require(profileToToken[msg.sender] == 0, "Profile already exists")`. Essentially, once an account is blocked, its associated mapping entry is cleared, so the condition to identify an account with an existing profile is no longer met. This loophole enables a blocked account to recreate its profile, undermining the purpose of blocking. ## Impact A blocked account, which should be permanently barred from engaging with the platform, can circumvent this restriction by re-minting its profile. The integrity of the platform is compromised, as blocked users could regain access and potentially perform further malicious actions. ## POC ```solidity function testRecereationOfBlockedAccount() public { // Alice mints a profile successfully vm.prank(user); soulboundNFT.mintProfile("Alice", 18, "ipfs://profileImageAlice"); // Owner blocks Alice's account, which deletes Alice profile mapping vm.prank(owner); soulboundNFT.blockProfile(user); // The blocked user (Alice) attempts to mint a new profile. // Due to the reset mapping value (0), the require check is bypassed. vm.prank(user); soulboundNFT.mintProfile("Alice", 18, "ipfs://profileImageAlice"); } ``` ## Recommendations - When blocking an account, implement a mechanism to permanently mark that address as blocked rather than simply deleting an entry. For example, maintain a separate mapping (e.g., isBlocked) to record blocked accounts, and update mintProfile to check if an account is permanently barred from minting: Example modification: ```diff + mapping(address => bool) public isBlocked; ... function mintProfile(string memory name, uint8 age, string memory profileImage) external { + require(!isBlocked[msg.sender], "Account is permanently blocked"); require(profileToToken[msg.sender] == 0, "Profile already exists"); uint256 tokenId = ++_nextTokenId; _safeMint(msg.sender, tokenId); // Store metadata on-chain _profiles[tokenId] = Profile(name, age, profileImage); profileToToken[msg.sender] = tokenId; emit ProfileMinted(msg.sender, tokenId, name, age, profileImage); } ... function blockProfile(address blockAddress) external onlyOwner { uint256 tokenId = profileToToken[blockAddress]; require(tokenId != 0, "No profile found"); _burn(tokenId); delete profileToToken[blockAddress]; delete _profiles[tokenId]; + isBlocked[blockAddress] = true; emit ProfileBurned(blockAddress, tokenId); } ```

Support

FAQs

Can't find an answer? Chat with us on Discord, Twitter or Linkedin.

Give us feedback!