Skip to content
Business logic Audit finding Intermediate

Deflationary tokens are not supported

The deposit functions of Insurance and TracerPerpetualSwaps assume that the contract's external ERC20 balance increases by exactly the amount specified in transferFrom, but deflationary tokens charge a fee on each transfer, so the user is credited the full amount without accounting for the tax. An attacker could exploit this to receive more credit than the tokens actually received.

cmichel Follow

Originally disclosed on Code4rena

Submitted by cmichel, also found by s1m0 and 0xRajeev

There are ERC20 tokens that may make certain customizations to their ERC20 contracts. One type of these tokens is deflationary tokens that charge a certain fee for every transfer() or transferFrom().

The deposit() functions of Insurance and TracerPerpetualSwaps assume that the external ERC20 balance of the contract increases by the same amount as the amount parameter of the transferFrom.

The user is credited the full amount without the taxes (userBalance.position.quote).

Recommend as one possible mitigation, measuring the asset change right before and after the asset-transferring functions.

raymogg (Tracer) confirmed but disagreed with severity:

Most likely not a medium risk as you can do a lot more nasty things than just use rebasing tokens. Since the owner of a market can set their own quote token, this token could be a token they control the supply of allowing them to arbitrarily transfer tokens between accounts, etc.

As such, this sort of falls outside of our trust model. Market creators should use tokens that behave as “standard” ERC20s. We will make a not that rebasing and deflationary tokens should not be used as quote tokens without weird behaviour.

Would be better as a low or informational issue due to this.

cemozerr (Judge) downgraded severity from 2 to 1:

Marking this as low risk as it seems to fall outside of the trust model, yet important enough to communicate to users explicitly.

The original report as published on Code4rena, by cmichel. 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 deposit functions do not measure the actual change in token balance before and after the transfer, instead trusting the amount parameter.

Impact

A user could be credited more than the tokens actually received, potentially allowing them to gain extra balance; however, the project owner considered this outside the trust model and the judge downgraded it to low severity.

What the attacker needed

Market uses a deflationary token as quote token

The fix

The deposit functions should measure the actual change in token balance before and after the transfer instead of relying on the amount parameter.

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 small fee when they are transferred, so the receiver gets less than the sender sent. The deposit function in this code assumes the full amount arrives and credits the user for that full amount, which means the user gets more credit than the tokens actually received. This could let someone gain extra balance without paying for it.

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 cmichel

View all

196 more disclosed reports, best first.

More from Tracer 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.