Pieces Protocol

First Flight #32
Beginner FriendlyFoundrySolidityNFT
100 EXP
View results
Submission Details
Severity: medium
Invalid

Missing Validation for tokenId in divideNft Function

Summary

The divideNft function does not validate whether the provided tokenId is valid or exists within the specified nftAddress and also if not zero. This omission can lead to unexpected errors, unintended behavior, and potential exploitation if invalid or malicious tokenId values are passed to the function.

Vulnerability Details

function divideNft(address nftAddress, uint256 tokenId, uint256 amount) onlyNftOwner(nftAddress, tokenId) external {
if (nftAddress == address(0)) {
revert TokenDivider__NftAddressIsZero();
}
if (amount == 0) {
revert TokenDivider__AmountCantBeZero();
}
// No validation for the tokenId
}

Impact

  1. An attacker could pass malicious or invalid tokenId values to exploit the lack of validation, leading to potential denial of service or misuse of the function.

Tools Used

Manual

Recommendations

add the tokenId validation Missing Validation for tokenId in divideNft Function

if (!ERC721(nftAddress).ownerOf(tokenId)) {
revert TokenDivider__InvalidTokenId();
}
Updates

Lead Judging Commences

fishy Lead Judge 4 months ago
Submission Judgement Published
Invalidated
Reason: Non-acceptable severity

Support

FAQs

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