Skip to content
Business logic Audit finding Intermediate

Incompatibility With Rebasing/Deflationary/Inflationary tokens

The TraderJOE contracts do not account for tokens whose balances change during transfers or over time, such as rebasing, deflationary, or inflationary tokens. An attacker could use such a token to cause a loss of funds for users who unknowingly interact with the protocol.

defsec Follow

Originally disclosed on Code4rena

Submitted by defsec

The TraderJOE protocol do not appear to support rebasing/deflationary/inflationary tokens whose balance changes during transfers or over time. The necessary checks include at least verifying the amount of tokens transferred to contracts before and after the actual transfer to infer any fees/interest.

Proof of Concept

https://github.com/code-423n4/2022-01-trader-joe/blob/main/contracts/RocketJoeStaking.sol#L133

https://github.com/code-423n4/2022-01-trader-joe/blob/main/contracts/RocketJoeFactory.sol#L132

Recommended Mitigation Steps

  • Ensure that to check previous balance/after balance equals to amount for any rebasing/inflation/deflation
  • Add support in contracts for such tokens before accepting user-supplied tokens
  • Consider supporting deflationary / rebasing / etc tokens by extra checking the balances before/after or strictly inform your users not to use such tokens if they don’t want to lose them.

cryptofish7 (Trader Joe) disputed and commented:

It won’t revert as long as token’s balance doesn’t decrease (this never happens).

LSDan (judge) increased severity from Low to Medium and commented:

It is possible for someone to unknowingly use this functionality with a token that rebases down during the launch event. Just because you don’t support a token type, doesn’t mean that the design doesn’t exist. This is a medium risk, not a low risk, because there is the potential for external interaction to cause a loss of funds.


The original report as published on Code4rena, by defsec. 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 contracts do not verify the actual balance change after a token transfer, so they assume the transferred amount equals the received amount.

Impact

A user could lose funds if they use a token that rebases down during the launch event, as the contract may not handle the balance change correctly.

What the attacker needed

Use of a rebasing or fee-on-transfer token

The fix

The contracts should check the balance before and after transfers to account for rebasing or fee-on-transfer tokens, or clearly warn users not to use such 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 tokens automatically change a user's balance over time or take a fee on transfers. The contracts here assume the amount sent is exactly the amount received, so they can miscalculate and lose funds if such a token is used.

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 defsec

View all

16 more disclosed reports, best first.

More from Trader Joe 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.