DatingDapp

First Flight #33
Beginner FriendlyFoundrySolidityNFT
100 EXP
View results
Submission Details
Severity: low
Invalid

SoulboundProfileNFT mintProfile accepts JSON character that breaks the tokenURI function

Summary

The contract allows to specify the profileImage when calling the mintProfilefunction.

Vulnerability Details

The function allows special JSON characters to be sent as part of the profileImageparameter.

This breaks the JSON response when the tokenURIis called.

The following has been added to the existing SoulboundProfileNFTTest.

function testBreakURI() public {
vm.prank(user);
soulboundNFT.mintProfile("Alice", 25, '"} // ');
uint256 tokenId = soulboundNFT.profileToToken(user);
string memory uri = soulboundNFT.tokenURI(tokenId);
assertEq(uri, "eyJuYW1lIjoiQWxpY2UiLCAiZGVzY3JpcHRpb24iOiJBIHNvdWxib3VuZCBkYXRpbmcgcHJvZmlsZSBORlQuIiwgImF0dHJpYnV0ZXMiOiBbeyJ0cmFpdF90eXBlIjogIkFnZSIsICJ2YWx1ZSI6IDI1fV0sICJpbWFnZSI6IiJ9IC8vICJ9");
}

When calling tokenURIfor this particular case, the resulting base64 decoded JSON is the following, which is invalid:

{"name":"Alice", "description":"A soulbound dating profile NFT.", "attributes": [{"trait_type": "Age", "value": 25}], "image":""} // "}

Impact

If the profile pictures URIs are consumed by an API, the resulting JSON is be corrupted, breaking the API or web application logic, disallowing to view the accounts' profiles.

Tools Used

Foundry

Recommendations

Ensure that the profileImage string does not exceed a certan length. Then, ensure that the string does not contain any double quote characters that could break the JSON when the tokenURIfunction is called.

Updates

Appeal created

n0kto Lead Judge 7 months ago
Submission Judgement Published
Invalidated
Reason: Non-acceptable severity
Assigned finding tags:

Informational or Gas

Please read the CodeHawks documentation to know which submissions are valid. If you disagree, provide a coded PoC and explain the real likelyhood and the detailed impact on the mainnet without any supposition (if, it could, etc) to prove your point.

Support

FAQs

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