Skip to content
Business logic Audit finding Intermediate

Deposits don’t work with fee-on transfer tokens

The deposit function records the requested token amount rather than the amount actually received, so fee-on-transfer tokens leave the contract's internal accounting out of step with its real token balance. An attacker could exploit this mismatch to withdraw more than they deposited.

cmichel Follow

Originally disclosed on Code4rena

Submitted by cmichel

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() function will introduce unexpected balance inconsistencies when comparing internal asset records with external ERC20 token contracts.

Recommend measuring the asset change right before and after the asset-transferring routines as a possible mitigation.

mcplums (Reality Cards) commented:

I think balancedBooks modifier should handle this?

Of course it means we are unable to use such tokens, but that is ok

**Splidge (Reality Cards) disputed

oh, trying the same one again..? 😁 https://github.com/code-423n4/2021-05-88mph-findings/issues/16

I’ll fight this one though, I’d argue that we are using ERC20 tokens and according to the ERC20 spec for transferFrom:

Transfers _value amount of tokens from address _from to address _to

A deflationary token therefore isn’t compliant to ERC20 as it doesn’t transfer the full _value and so it isn’t what we are planning to use and not relevant here.

dmvt (Judge) commented:

If you plan not to support these tokens it should be very clearly documented. Keep in mind that “we don’t support that” still has massive impact on the users involved. See: imBTC / ERC777 on Uniswap v1. The issue is valid and should stand in the audit report, in part so that future users see it.

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 logic credits the requested transfer amount instead of measuring the actual balance change, so tokens that deduct a fee on transfer break the internal accounting.

Impact

Internal asset records could diverge from the real token balance, which may let a user withdraw more than they deposited; the project argued such tokens are out of scope and a modifier may block them.

What the attacker needed

Contract accepts fee-on-transfer tokens; attacker deposits such a token

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 cut every time they are moved, so the receiver gets less than the sender sent. If a contract writes down the full amount it asked for instead of checking what actually arrived, its records say it holds more than it does. Someone could then take out more than they put in.

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 Reality Cards (round 2)

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.