EBTCToken.sol mint function logic is incompatible with restrictions implemented in EBTCToken.sol::transfer and EBTCToken.sol::transferFrom methods that prevents EBTCToken holding EBTC tokens breaking EBTCToken balance restriction and leading to EBTC tokens funds stuck in contract unable to recover
Brief/Intro
EBTCToken.sol::transfer and EBTCToken.sol::transferFrom methods implements restrictions to block users to send EBTC tokens to EBTCToken contract, thus ensuring EBTCToken contract EBTC balance always remains 0.
However this restriction can be bypassed using mint function.
Vulnerability Details
The restriction inside transfer and transferFrom are implemented using the internal function _requireValidRecipient:
function_requireValidRecipient(address _recipient) internalview {require( _recipient !=address(0) && _recipient !=address(this),// <@ block"EBTC: Cannot transfer tokens directly to the EBTC token contract or the zero address" );//...}
This function ensures that EBTCToken's EBTC balance remains 0 because it blocks transfer to EBTCToken address:
However this restriction doesnt hold if a user mints tokens directly to this contract, because in mint function there isnt this check in place:
functionmint(address _account, uint256 _amount) externaloverride {_requireCallerIsBOorCdpMOrAuth(); // <@ no restriction _mint(_account, _amount); }function_mint(address account, uint256 amount) internal {require(account !=address(0),"EBTCToken: mint to zero recipient!"); _totalSupply = _totalSupply + amount; _balances[account] = _balances[account] + amount; emit Transfer(address(0), account, amount); }
Impact Details
By using mint function to directly issue EBTC tokens to EBTCToken contract the restrictions implemented in transfer and transferFrom functions to keep EBTCToken balance to 0 are bypassed allowing EBTCToken contract to hold tokens and have EBTC tokens stuck in contract
Risk Breakdown
The vulnerability is easy to exploit, however to exploit it mint capability is needed leading to stuck tokens in EBTCToken contract and balance restriction bypass
Recommendation
Implement a restriction in mint function like the ones implemented in transfer and transferFrom function such as