When an auction ends with no bids, the amount of tokens held by the FjordAuction
contract is transferred to the owner's address. The owner address is that of the creator of the auction, i.e., the AuctionFactory
contract. However, AuctionFactory
contract lacks any functionality or logic to handle the transferred tokens, resulting in a complete loss of that amount of tokens.
AuctionFactory
contract is used to create a new auction by creating a FjordAuction
contract. The auction constructor
sets the owner as the msg.sender
, which in all cases is the AuctionFactory
contract address:
When the auction ends with no bids, all tokens are transferred to the owner of the contract (the AuctionFactory
contract), as can be seen in the FjordAuction::auctionEnd
function
However, AuctionFactory
contract does not contain any logic to handle the transferred tokens, resulting in a total loss.
auction.t.sol file contains a test to address the case when an auction ends with no bids. However, AuctionFactory
contract is not used to create the auction, resulting in an incomplete test. For a more realistic simulation, there must be an AuctionFactory
contract that creates the desired auction. This can be achieved by performing the following steps:
Create the AuctionFactory
contract
Create the ERC20
token for the auction (it must be a mintable token)
Approve the AuctionFactory
contract to transfer the desired amount of tokens
Create the auction
Simulate the end of the auction with zero bids
Check the destination of the auction tokens
Add the following imports in the auction.t.sol
file
The code for the ERC20MintableMock.sol
file is simple. It must be created and allocated in the mocks directory.
In the auction.t.sol
file, create the global variables shown and add the following code to the end of the setUp
function.
Finally, add the following test to the auction.t.sol
file
The test passes proving that the final destination of the tokens is the AuctionFactory
contract.
Impact: High
Likelihood: Medium
Manual Review
It is straightforward to see that the desired address to transfer the tokens to when the auction ends with no bids is that of the owner of the AuctionFactory
contract. A valid solution to the issue is to pass the desired address as a parameter to the FjordAuction
contract constructor
.
An auction with 0 bids will get the `totalTokens` stuck inside the contract. Impact: High - Tokens are forever lost Likelihood - Low - Super small chances of happening, but not impossible
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.