The FjordAuction::auctionEnd
function attempts to transfer the auctioned tokens to the owner if no bids are placed. However, the contract does not check the return value of the transfer
function. If the transfer
fails (for example, due to a malicious or non-standard ERC20 token), the contract incorrectly assumes the transfer was successful, marking the auction as ended. This results in the auctioned tokens being locked in the contract permanently, as no further actions can be taken to retrieve them.
If the transfer
function fails and its return value is not checked, the auctioned tokens will be stuck in the contract. The owner will not receive the tokens, and since the auction is marked as ended, there is no way to recover or redistribute the tokens. This could lead to a significant loss, especially if a large amount of tokens is involved.
A test was conducted using a mock ERC20 token (MaliciousERC20Mock
) that overrides the transfer
function to always return false
. The test demonstrated that:
The FjordAuction::auctionEnd
function did not revert when the transfer
failed.
The auction was marked as ended, but the tokens remained in the contract.
The owner did not receive the auctioned tokens, confirming that they were effectively locked in the contract.
Here is the code for the MaliciousERC20Mock
contract that was used in the test:
Here is the relevant test code:
To prevent this issue, the FjordAuction::auctionEnd
function should check the return value of the transfer
function. If the transfer fails, the transaction should be reverted to ensure that the auctioned tokens are not locked in the contract.
The project already uses SafeTransferLib
from the Solmate library in the FjordStaking
contract. It is recommended to apply the same approach in the FjordAuction
contract to handle token transfers safely.
Here’s how you can modify the FjordAuction::auctionEnd
function to use SafeTransferLib
:
This mitigation ensures that if the transfer
fails, the contract reverts the transaction, preventing the auction tokens from being locked in the contract. By using SafeTransferLib
, you align with existing practices in the codebase and improve the overall security and reliability of the contract.
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.