Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Missing return values in IERC20.transferFrom. #146

Closed
c4-bot-10 opened this issue Oct 22, 2024 · 0 comments
Closed

Missing return values in IERC20.transferFrom. #146

c4-bot-10 opened this issue Oct 22, 2024 · 0 comments
Labels
2 (Med Risk) Assets not at direct risk, but function/availability of the protocol could be impacted or leak value bug Something isn't working edited-by-warden insufficient quality report This report is not of sufficient quality 🤖_primary AI based primary recommendation

Comments

@c4-bot-10
Copy link
Contributor

c4-bot-10 commented Oct 22, 2024

Lines of code

https://github.com/kkrt-labs/kakarot/blob/7411a5520e8a00be6f5243a50c160e66ad285563/src/backend/starknet.cairo#L264

Vulnerability details

Summary

Missing Return Values in IERC20.transferFrom.

ERC20 token behaviors in scope

Missing return values: In scope

Vulnerability details

Some tokens do not return a bool (e.g. USDT, BNB, OMG) on ERC20 methods. see here for a comprehensive (if somewhat outdated) list.
Some tokens (e.g. BNB) may return a bool for some methods, but fail to do so for others. This resulted in stuck BNB tokens in Uniswap v1 (details). Some particularly pathological tokens (e.g. Tether Gold) declare a bool return, but then return false even when the transfer was successful (code).
A good safe transfer abstraction (example) can help somewhat, but note that the existence of Tether Gold makes it impossible to correctly handle return values for all tokens.

Proof Of Concept

As seen below, there is a missing return value as transferFrom. It does not return a bool for the ERC20 token transfer operation.

        IERC20.transferFrom(
            token_address, transfer.sender.starknet, transfer.recipient.starknet, transfer.amount
        );

Tools Used

Manual Review

Recommendation Mitigaiton Steps

The protocol should use the safe transfer method from open zeppelin.

        IERC20.safeTransferFrom(
            token_address, transfer.sender.starknet, transfer.recipient.starknet, transfer.amount
        );

Assessed type

ERC20

@c4-bot-10 c4-bot-10 added 2 (Med Risk) Assets not at direct risk, but function/availability of the protocol could be impacted or leak value bug Something isn't working labels Oct 22, 2024
c4-bot-9 added a commit that referenced this issue Oct 22, 2024
@c4-bot-9 c4-bot-9 changed the title Missing Return Values in IERC20.transferFrom. Missing return values in IERC20.transferFrom. Oct 23, 2024
@c4-bot-12 c4-bot-12 added the 🤖_primary AI based primary recommendation label Oct 25, 2024
@howlbot-integration howlbot-integration bot added the insufficient quality report This report is not of sufficient quality label Oct 28, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
2 (Med Risk) Assets not at direct risk, but function/availability of the protocol could be impacted or leak value bug Something isn't working edited-by-warden insufficient quality report This report is not of sufficient quality 🤖_primary AI based primary recommendation
Projects
None yet
Development

No branches or pull requests

3 participants