https://github.com/Cyfrin/2025-02-raac/blob/main/contracts/zeno/Auction.sol
The Auction
contract's constructor does not validate critical input parameters, such as:
_startTime
: The timestamp when the auction starts.
_endTime
: The timestamp when the auction ends.
_startingPrice
: The initial price of ZENO tokens at the start of the auction.
_reservePrice
: The minimum price of ZENO tokens at the end of the auction.
_totalAllocated
: The total number of ZENO tokens allocated for the auction.
Without proper validation, the contract could be initialized with invalid or malicious values, leading to unexpected behavior or rendering the auction unusable.
Invalid Auction Timing:
If _startTime
is set to a timestamp in the past, the auction will start immediately, potentially catching users off guard.
If _endTime
is set to a timestamp before _startTime
, the auction will end before it starts, making it impossible for users to participate.
Invalid Pricing:
If _startingPrice
is set lower than _reservePrice
, the price calculation in getPrice
will result in incorrect or negative values, breaking the auction logic.
If _startingPrice
or _reservePrice
is set to 0
, the auction will effectively give away ZENO tokens for free.
Zero or Negative Allocation:
If _totalAllocated
is set to 0
, the auction will have no tokens to sell, rendering it useless.
If _totalAllocated
is set to an excessively large value, it could lead to integer overflow or other unexpected behavior.
Business Logic Failure:
Invalid parameters could cause the auction to behave unpredictably, leading to financial losses for users or the business.
Consider the following scenario:
The contract is deployed with the following parameters:
_startTime = 0
(invalid, as it is in the past).
_endTime = 100
(invalid, as it is before _startTime
).
_startingPrice = 100
(invalid, as it is less than _reservePrice = 200
).
_totalAllocated = 0
(invalid, as no tokens are allocated for the auction).
The auction will start immediately (due to _startTime = 0
) and end at timestamp 100
.
The getPrice
function will return incorrect or negative values due to _startingPrice < _reservePrice
.
Users will be unable to participate in the auction, as _totalAllocated = 0
.
Add input validation in the constructor to ensure that:
_startTime
is in the future.
_endTime
is after _startTime
.
_startingPrice
is greater than _reservePrice
.
_totalAllocated
is greater than 0
.
Here is the updated constructor with input validation:
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.