28890 - [SC - Insight] EBTCTokensol mint function lack of checks allow...

Submitted on Mar 1st 2024 at 01:09:47 UTC by @cryptonoob2k for Boost | eBTC

Report ID: #28890

Report type: Smart Contract

Report severity: Insight

Target: https://github.com/ebtc-protocol/ebtc/blob/release-0.7/packages/contracts/contracts/EBTCToken.sol

Impacts:

  • Permanent freezing of funds

Description

Bug Description

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:

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:

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

Proof of Concept

Here is a foundry test file, save it in packages/contracts/foundry_test subdir and run it with:

Code:

Last updated

Was this helpful?