Skip to content
Smart contracts Audit finding Intermediate

TokenManagerERC20.sol uses transferFrom() instead of safeTransferFrom()

The TokenManagerERC20 contract uses transferFrom() instead of safeTransferFrom(), so tokens that do not return a boolean (non-standard ERC20) will cause transactions to revert. This makes such tokens unusable in the protocol, but no funds are lost.

jayjonah8 Follow

Originally disclosed on Code4rena

Submitted by jayjonah8, also found by cmichel and IllIllI

https://github.com/skalenetwork/ima-c4-audit/blob/main/contracts/schain/TokenManagers/TokenManagerERC20.sol#L298

https://github.com/skalenetwork/ima-c4-audit/blob/main/contracts/schain/TokenManagers/TokenManagerERC20.sol#L303

Impact

In TokenManagerERC20.sol the _exit() function makes use of transferFrom() instead of using safeTransferFrom(). Tokens that don’t correctly implement the latest EIP20 spec will be unusable in the protocol as they revert the transaction because of the missing return value.

Proof of Concept

https://github.com/skalenetwork/ima-c4-audit/blob/main/contracts/schain/TokenManagers/TokenManagerERC20.sol#L298

https://github.com/skalenetwork/ima-c4-audit/blob/main/contracts/schain/TokenManagers/TokenManagerERC20.sol#L303

Recommended Mitigation Steps

It’s recommended to use OpenZeppelin’s SafeERC20 versions with the safeTransfer and safeTransferFrom functions that handle the return value check as well as non-standard-compliant tokens.

cstrangedk (SKALE) disputed, disagreed with severity and commented:

Issue is acknowledged and work is pending on the roadmap. No loss of funds is possible, only revert txn. In the meantime, SKALE Chain owners at their discretion can expand the bridge compatibility to use safeTransfer functions. Owners must evaluate token compatibility.

GalloDaSballo (judge) decreased severity to Medium and commented:

I believe that given the “need for configuration” the finding cannot be of High Severity. Additionally, the tx will revert as such no loss of funds is possible.

The tokens that will cause a revert (e.g. USDT) will simply be unusable.

While the argument for configuration is correct in de-escalating to Medium, I don’t believe it exempts the code from being properly scrutinized.

If a user were to configure their chain to use TokenManagerERC20 they’d have revert on non returning tokens, for that reason I believe Medium Severity to be appropriate as this is contingent on configuration


The original report as published on Code4rena, by jayjonah8. Images and videos are our own copies; raw HTML is shown as text. View it on Code4rena.

Not written yet. The AI write-up for this report has not been written yet. The Original tab links to the source.

How it worked

Root cause

The contract calls transferFrom() directly instead of using a safe wrapper that checks the return value and handles tokens without a return value.

Impact

Tokens that do not return a boolean from transferFrom will cause transactions to revert, making them unusable in the protocol; no loss of funds is possible.

What the attacker needed

Chain configured to use TokenManagerERC20; Token does not return a boolean on transfer

The fix

Use OpenZeppelin's SafeERC20 safeTransfer and safeTransferFrom functions, which handle the return value check and non-standard tokens.

Explained by bugbounty.wiki with AI from the original and checked against quotes from it; it can still be wrong. Read the original before relying on a detail.

Not written yet. The AI write-up for this report has not been written yet. The Original tab links to the source.

Some older or non-standard tokens do not return a true/false value when you transfer them. The contract expects that return value, so the transfer fails and the whole transaction is undone. This means those tokens cannot be used with this bridge.

What is Smart contracts?

Flaws in on-chain code that let an attacker drain funds, freeze them or break the protocol's accounting.

More by jayjonah8

View all

18 more disclosed reports, best first.

More from SKALE contest

View all

The newest disclosed reports for this program.

Similar reports

View all

Same bug class and techniques, clearest first.

Smart contract vulnerabilities

The lesson behind this report.

Flaws in on-chain code that let an attacker drain funds, freeze them or break the protocol's accounting.