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

Possible addresses collision when creating a new auction.

Vulnerability Details

In 'FjordAuctionFactory', the owner can create an auction (FjordAuction) calling 'FjordAuctionFactory::createAuction'.

The problem is that a certain auction with the same values can be created.

Impact

If this happens the transaction will fail because there can't be two contracts with the same address.

POC

function test_vulnerability_cantCreateAContractWithAnAddressAlreadyExistent() public {
bytes32 salt = bytes32(keccak256(abi.encode("Pepe to the moon")));
address auctionToken = 0x6982508145454Ce325dDbE47a25d4ec3d2311933;
uint256 biddingTime = 7 days;
uint256 totalTokens = 1_000_000;
vm.startPrank(owner);
deal(auctionToken, owner, 2_000_000);
ERC20(auctionToken).approve(address(auctionFactory), 2_000_000);
//Owner creates an auction with certains values.
auctionFactory.createAuction(auctionToken, biddingTime, totalTokens, salt);
vm.expectRevert();
//Here owner creates another auction with the same values of an old auction, this means that there would 2 addresses and so this call will fail.
auctionFactory.createAuction(auctionToken, biddingTime, totalTokens, salt);
vm.stopPrank();
}

Tools Used

Manual review, Foundry

Recommendations

Consider using create instead of using create2 to create auctions.

Consider changing the logic of 'FjordAuctionFactory::createAuction' in this:

function createAuction(
address auctionToken,
uint256 biddingTime,
uint256 totalTokens
) external onlyOwner {
address auctionAddress = address(
new FjordAuction(fjordPoints, auctionToken, biddingTime, totalTokens)
);
// Transfer the auction tokens from the msg.sender to the new auction contract
IERC20(auctionToken).transferFrom(msg.sender, auctionAddress, totalTokens);
emit AuctionCreated(auctionAddress);
}
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.