Bug Title: Incomplete Handling of Half-Price Discount in trickOrTreat
Function
Severity: Medium
Vulnerability Type: Logical Error / Business Logic Flaw
This report identifies a logical flaw in the trickOrTreat
function within the smart contract, which affects the handling of a half-price discount for NFT minting. Users who qualify for this discount are not able to utilize it properly, leading to potential financial loss and decreased user satisfaction.
The trickOrTreat
function uses a pseudo-random number generator to determine the price of treats, allowing for the possibility of a half-price offer. However, the current implementation fails to appropriately manage cases where the random number indicates a half-price discount. Instead of allowing users to pay half the required cost, the function may either require the full price or lead to confusion regarding payments. This flaw could allow users to overpay or miss out on discounts they are entitled to.
Deploy the contract with the trickOrTreat
function.
Set up a user address with sufficient ETH balance (e.g., 100 ether
).
Call trickOrTreat
with a valid treat name.
If the random number generated is 1
, observe that the user is still required to send the full treat cost instead of half.
The user should receive a refund only if they overpay, but they are never charged at the discounted rate directly.
Due to this flaw, users who are entitled to receive a treat at a half-price discount (1/2 multiplier) are not able to benefit from the discount as intended. This results in:
Unintended Financial Loss: Users end up paying more than required when they qualify for the half-price discount, potentially causing dissatisfaction and undermining user trust in the platform.
Degraded User Experience: The random reward mechanism is not working as expected, which impacts the fairness of the function.
Manual Review
To fix this, the code should include an else if
block to handle the half-price scenario: Update the function logic to properly handle the case where random == 1
(half price scenario).
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.