Skip to content
Business logic Audit finding Intermediate

Ineffective Handling of FoT or Rebasing Tokens

The contracts do not account for tokens that charge a fee on transfer or rebase, so the Splitter records more tokens than it actually holds. If all users claim, the last user cannot withdraw their share because the contract runs out of funds.

kirk-baird Follow

Originally disclosed on Code4rena

Submitted by kirk-baird, also found by defsec, hickuphh3, and leastwood

Certain ERC20 tokens may change user’s balances over time (positively or negatively) or charge a fee when a transfer is called (FoT tokens). The accounting of these tokens is not handled by RoyaltyVault.sol or Splitter.sol and may result in tokens being stuck in Splitter or overstating the balance of a user

Thus, for FoT tokens if all users tried to claim from the Splitter there would be insufficient funds and the last user could not withdraw their tokens.

Proof of Concept

The function RoyaltyVault.sendToSplitter() will transfer splitterShare tokens to the Splitter and then call incrementWindow(splitterShare) which tells the contract to split splitterShare between each of the users.

        require(
            IERC20(royaltyAsset).transfer(splitterProxy, splitterShare) == true,
            "Failed to transfer royalty Asset to splitter"
        );
        require(
            ISplitter(splitterProxy).incrementWindow(splitterShare) == true,
            "Failed to increment splitter window"
        );

Since the Splitter may receive less than splitterShare tokens if there is a fee on transfer the Splitter will overstate the amount split and each user can claim more than their value (except the last user who claims nothing as the contract will have insufficient funds to transfer them the full amount).

Furthermore, if the token rebase their value of the tokens down while they are sitting in the Splitter the same issue will occur. If the tokens rebase their value up then this will not be accounted for in the protocol.

Recommended Mitigation Steps

It is recommend documenting clearly that rebasing token should not be used in the protocol.

Alternatively, if it is a requirement to handle rebasing tokens balance checks should be done before and after the transfer to ensure accurate accounting. Note: this makes the contract vulnerable to reentrancy and so a reentrancy guard must be placed over the function sendToSplitter().

        uint256 balanceBefore = IERC20(royaltyAsset).balanceOf(splitterProxy);
        require(
            IERC20(royaltyAsset).transfer(splitterProxy, splitterShare) == true,
            "Failed to transfer royalty Asset to splitter"
        );
        uint256 balanceAfter = IERC20(royaltyAsset).balanceOf(splitterProxy);
        require(
            ISplitter(splitterProxy).incrementWindow(balanceAfter - balanceBefore) == true,
            "Failed to increment splitter window"
        );

sofianeOuafir (Joyn) confirmed


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

Likely the contract credits the intended transfer amount rather than measuring the actual change in token balance, so fee-on-transfer or rebasing tokens cause the recorded split to exceed the real holdings.

Impact

Users can claim more than their share and the last claimant may receive nothing because the contract has insufficient funds; upward rebases are also not accounted for.

What the attacker needed

Fee-on-transfer or rebasing token used; users claim from Splitter

The fix

The report recommends documenting that rebasing tokens should not be used, or alternatively checking balances before and after the transfer and adding a reentrancy guard.

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 tokens take a fee when sent or change everyone's balance over time. The contract assumes the amount it sends is exactly the amount received, so its records become wrong. Later, when users withdraw, there is not enough money left for the last person.

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 kirk-baird

View all

32 more disclosed reports, best first.

More from Joyn contest

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.