When it's a trick, a user is requird to pay double amount for the Treat. However, the NFT is minted to SpookySwap
and user can complete the purchase by paying the remaining amount later by calling resolveTrick
. But the contract owner can increase the cost of the Treat and make user pay more for it or block from completing the purchase.
The trickOrTreat
function in the SpookySwap contract uses a pseudo-random number to adjust the cost of purchasing NFTs.
For a double-price purchase, the NFT is first minted to the SpookySwap contract address, and the user pays an initial amount of ETH. The user must then call the resolveTrick
function to complete the purchase by paying the remaining required ETH.
The contract owner has the authority to call setTreatCost
function to increase the price of the NFT between the user's initial trickOrTreat
transaction and the follow-up resolveTrick
call. If the owner raises the NFT price before the user can call resolveTrick
, the user would not be able to complete the purchase under the originally determined cost, effectively blocking the purchase or forcing the user to pay an arbitrarily higher price.
Proof Of Concept
User buys the NFT by calling trickOrTreat
If the random number is 2, it's a trick and user has to pay double cost.
The NFT is minted to SpookySwap
.
Admin calls the setTreatCost
function to increase the cost of the Treat.
When user calls resolveTrick
with required amount, the transaction would revert as the cost has been increased.
The user has to pay more ETH to complete the purchase.
The user would be blocked from completing the purchase of the NFT. Moreover, if they want it, they are required to pay higher cost.
The user is at the mercy of the owner's pricing adjustments, leading to potential unfair practices.
VS Code, Foundry, Manual review
Record the Treat's initial price at the time of trickOrTreat
call in the pendingNFTs data. Ensure this price is locked in for the subsequent resolveTrick
call, preventing any modification by the owner.
Consider using immutable variables for base prices or restricting price changes to specified intervals (e.g. every 24 hours) using time-based restrictions.
Only the owner has the rights to change the cost of the treat. Therefore it is assumed that the owner will not change the cost of the pending NFTs. The owner role is trusted.
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.