The Auction contract’s getPrice() function subtracts the reserve price from the starting price. If the starting price is set lower than the reserve price, this subtraction underflows, causing the function to revert. This error prevents the auction from operating correctly and can block bidding.
The getPrice() function calculates the current auction price with the following logic:
Issue:
The calculation state.startingPrice - state.reservePrice must be non-negative. If state.startingPrice is less than state.reservePrice, the subtraction underflows (since these are unsigned integers), causing the function to revert. This vulnerability arises from not validating the auction parameters upon initialization.
Example:
Auction Parameters:
state.startingPrice = 50 USDC
state.reservePrice = 100 USDC
Auction duration: 100 seconds
At 50 seconds into the auction:
Expected operation:
Price = 50 - ((50 - 100) x 50/100)
Calculation of decrement:
50 - 100 = Underflow (since unsigned integers cannot be negative)
Instead of yielding -50, the operation reverts.
Outcome:
The auction’s price calculation fails, preventing any further bidding or auction progress.
The underflow error will cause the auction to revert, making it impossible for users to bid.
Manual Review
Add a validation check in the constructor to ensure that the starting price is greater than or equal to the reserve price. For example:
This change ensures that the arithmetic in getPrice() remains valid, preventing underflow and guaranteeing that the auction price decreases correctly to the reserve price.
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.