Zero-value inputs in createAuction function allow for deployment of malfunctioning auction contracts leading to
Immediate auction end
AFFECTED CONTRACT FILE :
2024-08-fjord/src/FjordAuctionFactory.sol at main · Cyfrin/2024-08-fjord (github.com)
The createAuction function does not validate its inputs, allowing for:
biddingTime to be set to 0, causing the auction to end immediately
totalTokens to be set to 0, resulting in no tokens being transferred to the auction contract
Code Snippet:
function createAuction(
address auctionToken,
uint256 biddingTime, // Vulnerable to 0-value input
uint256 totalTokens, // Vulnerable to 0-value input
bytes32 salt
) external onlyOwner {
// ...
}
This lack of input validation leads to unexpected behavior .
The auction might not work as intended, leading to a failed or unusable auction.
IMPACT
If biddingTime or totalTokens is set to 0, the auction contract can still be deployed, but it would lead to unexpected behavior and potentially severe consequences:
Bidding Time = 0:
The auction would end immediately after deployment, making it impossible for users to place bids.
The auctionEnd() function would be called automatically, distributing tokens to no one or potentially causing errors.
Total Tokens = 0:
No tokens would be transferred to the auction contract, making it impossible for users to receive tokens.
The auction contract would essentially be useless, as there would be no tokens to distribute.
VS CODE
Recommendation:
Input Validation and Error Handling
Add input validation to ensure biddingTime and totalTokens are greater than 0. Use require statements to revert transactions with invalid inputs.
Code Snippet:
function createAuction(
address auctionToken,
uint256 biddingTime,
uint256 totalTokens,
bytes32 salt
) external onlyOwner {
require(biddingTime > 0, "Bidding time must be greater than 0");
require(totalTokens > 0, "Total tokens must be greater than 0");
}
This validation prevents deployment of malfunctioning auction contracts, ensuring the auction functions as intended.
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.