In the trickOrTreat
function of the SpookySwap
contract, a user can exploit the lack of an initial msg.value
check by sending a minimal amount of ETH (e.g., 1 wei) for multiple calls. When the random condition for a "trick" (double price) is met, the NFT is minted to the contract with 1 wei as pendingNFTsAmountPaid
. Since there is no requirement to call resolveTrick
, users may abandon the NFT purchase process, leaving the NFT locked in the contract without adequate compensation. This can lead to storage bloat and create a DoS risk by filling the contract’s storage with orphaned NFTs, ultimately affecting contract functionality and user experience.
The issue can be found here at : https://github.com/Cyfrin/2024-10-trick-or-treat/blob/main/src/TrickOrTreat.sol#L48-L105
Continuous exploitation may cause the contract to store a large number of abandoned NFTs, which could eventually exhaust storage capacity, causing the contract to reach operational limits or even face high storage costs. The accumulation of orphaned NFTs makes it harder for legitimate users to mint new NFTs or engage with the contract, reducing the contract’s efficiency and reliability. The contract owner may incur costs due to unclaimed NFTs in storage without adequate payment, leading to a financial loss over time.
Manual Review
To address this issue, introduce an initial msg.value
check in the trickOrTreat
function to ensure the user has sent at least the base treat.cost
. This ensures a minimum commitment, deterring abuse from minimal payments.
The protocol can work correctly with more than 20000 tokens in it. It is informational.
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.