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

Unchecked ERC20 Transfer Return Value Leads to Potential Fund Loss in FjordAuction

Summary

The bid function in the FjordAuction contract does not verify the return value of the transferFrom function call to the FjordPoints contract. This oversight will allow a malicious actor to place bids without actually transferring tokens, potentially leading to a loss of funds and compromise of the auction integrity.

Vulnerability Details

In the bid function of the FjordAuction contract, the following line is problematic:

fjordPoints.transferFrom(msg.sender, address(this), amount);

This function call is not checked for its return value. According to the ERC20 standard, transferFrom should return a boolean indicating the success or failure of the transfer. By not checking this return value, the contract assumes the transfer was successful, even if it wasn't.

A malicious contract could implement a transferFrom function that always returns true without actually transferring any tokens

If such a contract interacts with the FjordAuction contract, it will place bids without actually transferring any FjordPoints, as the auction contract would not detect the failed transfer.

Impact

1 : The auction could distribute rewards based on bids that were never actually backed by token transfers.

2: An attacker could place arbitrarily large bids without any cost, potentially manipulating the auction outcome.

3: Unfair Advantage: Malicious actors could outbid honest participants without actually staking any tokens.

Tools Used

manual review

Recommendations

1: Always check the return value of transferFrom

require(fjordPoints.transferFrom(msg.sender, address(this), amount), "Token transfer failed");

2: Alternatively, use OpenZeppelin's SafeERC20 library, which provides a safeTransferFrom function that handles this check internally:

import "@openzeppelin/contracts/token/ERC20/utils/SafeERC20.sol";
// In the contract
using SafeERC20 for IERC20;
// In the bid function
fjordPoints.safeTransferFrom(msg.sender, address(this), amount);

3: Implement additional checks to ensure the contract's token balance increases by the expected amount after the transfer.

4: Consider using a pull payment system instead of push payments to mitigate risks associated with failed transfers.

Updates

Lead Judging Commences

inallhonesty Lead Judge 10 months ago
Submission Judgement Published
Invalidated
Reason: Known issue

Support

FAQs

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