Token-0x

First Flight #54
Beginner FriendlyDeFi
100 EXP
Submission Details
Impact: medium
Likelihood: high

Missing function signatures in IERC20.sol makes some functions unavailable in code.

Author Revealed upon completion

Root + Impact

Description

  • In the IERC20.sol file, there are almost all function signatures. However, the ones for name(), symbol(), and decimals() are missing. Therefore, these functions cannot be called using the IERC20 wrapper interface.

// Function signatures for name(), symbol() and decimals() are missing in the `IERC20.sol` file.

Risk

Likelihood: High

  • Since the signatures do not exist in the interface file, when the code tries to call any of those functions, it fails in the compilation phase.


Impact: Medium

  • There are many cases in which the program needs to access those properties, especially the decimals() that is used for precision calculations. However, in the current situation, they are not accessible via the interface wrapper. This disrupts the functionality of the programs which rely on it.


Proof of Concept

Please add the following function to the Token.t.sol test file, add the import statement to the import section of the file, and try to run the test using forge test --mt test_decimalsFunctionIsNotAvailable. It will fail with the error visible in the following screenshot.

import {IERC20} from "../src/IERC20.sol";
.
.
.
function test_decimalsFunctionIsNotAvailable() public {
IERC20 newToken = IERC20(address(token));
uint8 decimals = newToken.decimals();
}

Recommended Mitigation

To solve the issue, please add the following function signatures to the IERC20.sol file.

// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;
/**
* @dev Interface of the ERC-20 standard as defined in the ERC.
*/
interface IERC20 {
event Transfer(address indexed from, address indexed to, uint256 value);
event Approval(address indexed owner, address indexed spender, uint256 value);
function totalSupply() external view returns (uint256);
function balanceOf(address account) external view returns (uint256);
function transfer(address to, uint256 value) external returns (bool);
function allowance(address owner, address spender) external view returns (uint256);
function approve(address spender, uint256 value) external returns (bool);
function transferFrom(address from, address to, uint256 value) external returns (bool);
// Mitigation
+ function name() external view returns (string memory);
+ function symbol() external view returns (string memory);
+ function decimals() external view returns (uint8);
}

Support

FAQs

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

Give us feedback!