Skip to content
Business logic Audit finding Intermediate

TOFT leverageDown always fails if TOFT is a wrapper for native tokens

windhustler Follow

Originally disclosed on Code4rena

Submitted by windhustler

Pathway for sendForLeverage -> leverageDown always fails if the TapiocaOFT or mTapiocaOFT holds the native token as underlying, i.e. erc20 == address(0). This results in loss of gas, airdropped amount, and burned TOFT on the sending side for the user. The failed message if retried will always fail and result in permanent loss for the user.

Proof of Concept

TapiocaOFT/mTapiocaOFT is deployed with erc20 being address(0) in case if it holds the native token as an underlying token. However, it still allows anyone to execute the sendForLeverage which always results in reverts when receiving the message.

The revert happens at IERC20(erc20).approve(externalData.swapper, amount); since address(0) doesn’t have an approve function.

The message if retried will just keep on reverting because of the same reason due to the way the failedMessages are stored, e.g. you can just retry the same exact payload. This way anyone invoking this function will lose his TOFT tokens forever.

Recommended Mitigation Steps

Disable sendForLeverage function if the TapiocaOFT or mTapiocaOFT holds the native token as underlying, e.g. revert on the sending side.

0xRektora (Tapioca) confirmed


The original report as published on Code4rena, by windhustler. 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.

What is known

A high-severity business logic bug in Tapioca Invitational. Code4rena made it public on 16 November 2023. Found in the 2023-07-tapioca audit contest (finding H-46).

About Business logic

The application works as coded but not as intended: a negative price, a skipped payment step, a limit that can be crossed.

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

What is Business logic?

The application works as coded but not as intended: a negative price, a skipped payment step, a limit that can be crossed.

More by windhustler

View all

6 more disclosed reports, best first.

More from Tapioca Invitational

View all

The newest disclosed reports for this program.

Similar reports

View all

Same bug class and techniques, clearest first.

Business logic flaws

The lesson behind this report.

The application works as coded but not as intended: a negative price, a skipped payment step, a limit that can be crossed.