DeFiFoundry
20,000 USDC
View results
Submission Details
Severity: low
Invalid

Unvalidated input vulnerability in createAuction function

Summary

Zero-value inputs in createAuction function allow for deployment of malfunctioning auction contracts leading to

Immediate auction end

Vulnerability Details

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 .

Impact

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.

Tools Used

VS CODE

Recommendations

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");

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");
address auctionAddress = address(
new FjordAuction{salt: salt}(fjordPoints, auctionToken, biddingTime, totalTokens)
);
IERC20(auctionToken).transferFrom(msg.sender, auctionAddress, totalTokens);
emit AuctionCreated(auctionAddress);
}

}

This validation prevents deployment of malfunctioning auction contracts, ensuring the auction functions as intended.

Updates

Lead Judging Commences

inallhonesty Lead Judge about 1 year ago
Submission Judgement Published
Invalidated
Reason: Non-acceptable severity

Support

FAQs

Can't find an answer? Chat with us on Discord, Twitter or Linkedin.