Trick or Treat

First Flight #27
Beginner FriendlyFoundry
100 EXP
View results
Submission Details
Severity: medium
Invalid

No Mechanism to Cancel Pending Purchases

Summary

Users cannot cancel pending purchases in the "trick" scenario.

Vulnerability Details

Location: src/TrickOrTreat.sol:resolveTrick()

Proof of Concept:

function testNoCancelMechanism() public {
vm.deal(user1, 2 ether);
// Get the initial cost of the Candy treat
(, uint256 treatCost,) = spookySwap.treatList("Candy");
// User1 attempts to buy a treat
vm.prank(user1);
spookySwap.trickOrTreat{value: treatCost}("Candy");
// Check the next token ID
uint256 tokenId = spookySwap.nextTokenId() - 1;
// Check if user1 received the NFT directly
address nftOwner = spookySwap.ownerOf(tokenId);
// Assert that user1 owns the NFT
assertEq(nftOwner, user1, "User1 should own the NFT");
// Assert that user1's balance has decreased
assertLt(address(user1).balance, 2 ether, "User1's balance should have decreased");
}

Impact

Users' funds could be locked indefinitely if they're unable to complete a "trick" purchase, leading to poor user experience and potential loss of funds.

Tools Used

Forge

Recommendations

Implement a cancellation mechanism with a time limit.

Updates

Appeal created

bube Lead Judge 8 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.