Skip to content
Business logic Audit finding Intermediate

Tokens with fee on transfer are not supported

The contract's addValue function assumes the received amount equals the transfer amount, but fee-on-transfer tokens reduce the actual received amount. An attacker could exploit this to cause incorrect attribution calculations and balance discrepancies.

robee Follow

Originally disclosed on Code4rena

Submitted by robee

There are ERC20 tokens that charge fee for every transfer() / transferFrom().

Vault.sol#addValue() assumes that the received amount is the same as the transfer amount, and uses it to calculate attributions, balance amounts, etc. But, the actual transferred amount can be lower for those tokens.

Recommended Mitigation Steps

Therefore it’s recommended to use the balance change before and after the transfer instead of the amount. This way you also support the tokens with transfer fee - that are popular.

IndexLogic.sol#L115

olivermehr (Phuture Finance) confirmed


The original report as published on Code4rena, by robee. Images and videos are our own copies; raw HTML is shown as text. View it on Code4rena.

The original is short, so this covers everything it reports, then explains this kind of bug in general: how it works, how to test for it and how it is fixed. The general sections are about the bug class, not this target. Written with AI and checked against the original; the original is the record. 4 min read.

What the report shows

The report concerns Vault.sol's addValue() function and points to IndexLogic.sol#L115. The researcher, robee, reports that the contract does not support ERC20 tokens that charge a fee on every transfer() or transferFrom() call.

The reasoning is short and direct. addValue() assumes that the amount received by the vault equals the amount passed to the transfer call, and it uses that figure to calculate attributions, balance amounts and similar accounting values. For fee-on-transfer tokens the amount that actually lands in the vault is lower than the amount sent, so every calculation built on the nominal transfer amount is wrong.

The report points to one location in the codebase:

Text
IndexLogic.sol#L115

No request, payload, transaction trace or proof-of-concept is included. The finding is an observation about the accounting assumption in the code rather than a demonstrated exploit.

Recommended Mitigation Steps

The researcher's recommendation is to measure the balance change before and after the transfer and use that difference instead of the transfer amount. As the report puts it, this also supports the tokens with a transfer fee, which it describes as popular.

The finding was confirmed by olivermehr of Phuture Finance. It does not give a bounty amount or a disclosure date.

Root cause

The bug is an accounting mismatch: the contract trusts the amount it asked the token to move rather than the amount the token actually moved. Fee-on-transfer tokens deduct their fee inside transfer and transferFrom, so the recipient's balance increases by less than the argument. Any code that credits the sender or the vault with the full nominal amount overstates the position, and downstream calculations such as attributions inherit the error.

Impact

The report frames the issue as unsupported token behaviour rather than as a direct theft primitive. The concrete consequence it describes is incorrect attributions and balance amounts when such a token is used. Whether that mispricing can be turned into profit depends on how those values are consumed, which the report does not analyse.

How this kind of bug works

Most ERC20 code assumes that a successful transfer(to, amount) increases to's balance by exactly amount. That assumption holds for plain tokens but not for the growing family of tokens that take a cut on each movement: reflection tokens, deflationary tokens and tokens with a configurable transfer tax. Some also burn a portion, and some apply different rates to transfer and transferFrom.

A protocol that integrates arbitrary tokens therefore has two sources of truth: the requested amount and the observed balance delta. Bugs appear wherever the code uses the first where it should use the second. Typical victims are deposit and mint functions that issue shares against the nominal amount, collateral accounting that credits the full transfer, and reward or attribution logic that distributes value proportionally to recorded deposits. The result is that the protocol believes it holds more than it does, or that a depositor is credited with more than they contributed.

The defence is to treat the balance delta as authoritative: read the balance before the transfer, perform it, read again, and use the difference. Protocols that cannot tolerate such tokens should instead maintain an allowlist of supported assets and reject everything else at the integration boundary.

How to test for it

  1. Identify every function that pulls tokens in: deposits, mints, collateral top-ups, liquidity additions, and any path that calls transferFrom on a user-supplied token address.
  2. Check whether the token address is fixed by the protocol or supplied by the caller. Caller-supplied tokens widen the surface considerably.
  3. Read the accounting code around each transfer and note whether it uses the function argument or a measured balance delta.
  4. Deploy or obtain a fee-on-transfer test token, or use an existing one on a fork, and run the deposit path with it. Compare the shares or credit recorded against the amount that actually arrived.

Common false positives: the protocol explicitly documents that only a fixed set of plain tokens is supported, or the token list is enforced on-chain; the discrepancy exists but is bounded to rounding dust with no economic path; or the affected function is unreachable or admin-only. Confirm reachability before writing up.

How it is fixed

The standard fix is to measure the balance before and after the transfer and use the delta for all accounting, exactly as the report recommends. Where the token set is known and closed, an allowlist with an explicit rejection of fee-charging tokens is an acceptable alternative. Some designs additionally compare the delta against the requested amount and revert if they differ, which fails closed rather than silently mis-accounting.

Hunting notes

This class hides in any contract that accepts arbitrary ERC20s: vaults, staking pools, lending markets, DEX routers and reward distributors. Recon signals include a token parameter in a deposit or collateral function, a registry that lets users add tokens, or documentation claiming broad token compatibility. Fee-on-transfer, reflection and rebasing tokens are the usual triggers; rebasing tokens cause a related but distinct problem because balances change without any transfer at all.

The original is short, so this covers everything it reports, then explains this kind of bug in general: how it works, how to test for it and how it is fixed. The general sections are about the bug class, not this target. Written with AI and checked against the original; the original is the record. 6 min read.

What happened, in plain words

The report looks at one smart contract, Vault.sol, and in particular at a function inside it called addValue(). A smart contract is a program that lives on the blockchain and runs automatically when someone calls it.

The researcher, robee, reports that this contract does not cope with a certain kind of digital token. To understand why, you need to know what a token is. On blockchains such as Ethereum, a token is not a separate coin with its own network; it is a small program that keeps a table of who owns how much. The most common standard for these programs is called ERC20, and it defines a few standard actions, including transfer() (send tokens from your own balance to someone else) and transferFrom() (send tokens from one account to another on someone's behalf, usually after they have given permission).

Most tokens move exactly the amount you ask for: if you call transfer(to, 100), the recipient's balance goes up by 100. But some tokens take a cut on every movement, a bit like a bank charging a small commission on each transfer. These are called fee-on-transfer tokens. If you send 100 of such a token, the recipient might only end up with 95, with the rest going to a fee collector or being burned.

The problem in Vault.sol is an assumption. addValue() assumes that the amount the vault receives is the same as the amount it asked the token to move, and it uses that requested figure to calculate attributions, balance amounts and similar accounting values. For a fee-on-transfer token, the amount that actually lands in the vault is lower than the amount sent, so every calculation built on the nominal transfer amount is wrong. The vault's calculations are based on more than it actually received.

The report points to one location in the codebase:

Text
IndexLogic.sol#L115

That is a file and line reference: the file IndexLogic.sol, line 115. No request, payload, transaction trace or proof-of-concept is included. The finding is an observation about the accounting assumption in the code rather than a demonstrated exploit, which is why it reads more like a code review note than a step-by-step attack.

Recommended Mitigation Steps

The researcher's recommendation is to measure the balance before and after the transfer and use the difference instead of the transfer amount. In everyday terms: look at the vault's account statement before the payment, look again after, and book whatever actually arrived, rather than trusting the invoice. As the report puts it, this also supports the tokens with a transfer fee, which it describes as popular.

The finding was confirmed by olivermehr of Phuture Finance. It does not give a bounty amount or a disclosure date.

In general, this kind of bug

In general, most ERC20 code assumes that a successful transfer(to, amount) increases to's balance by exactly amount. That assumption holds for plain tokens but not for the growing family of tokens that take a cut on each movement: reflection tokens, deflationary tokens and tokens with a configurable transfer tax. Some also burn a portion, and some apply different rates to transfer and transferFrom.

A protocol that integrates arbitrary tokens therefore has two sources of truth: the requested amount and the observed balance delta. Bugs appear wherever the code uses the first where it should use the second. Typical victims are deposit and mint functions that issue shares against the nominal amount, collateral accounting that credits the full transfer, and reward or attribution logic that distributes value proportionally to recorded deposits. The result is that the protocol believes it holds more than it does, or that a depositor is credited with more than they contributed.

The defence is to treat the balance delta as authoritative: read the balance before the transfer, perform it, read again, and use the difference. Protocols that cannot tolerate such tokens should instead maintain an allowlist of supported assets and reject everything else at the integration boundary.

How to test for it

  1. Identify every function that pulls tokens in: deposits, mints, collateral top-ups, liquidity additions, and any path that calls transferFrom on a user-supplied token address.
  2. Check whether the token address is fixed by the protocol or supplied by the caller. Caller-supplied tokens widen the surface considerably.
  3. Read the accounting code around each transfer and note whether it uses the function argument or a measured balance delta.
  4. Deploy or obtain a fee-on-transfer test token, or use an existing one on a fork, and run the deposit path with it. Compare the shares or credit recorded against the amount that actually arrived.

Common false positives: the protocol explicitly documents that only a fixed set of plain tokens is supported, or the token list is enforced on-chain; the discrepancy exists but is bounded to rounding dust with no economic path; or the affected function is unreachable or admin-only. Confirm reachability before writing up.

How it is fixed

The standard fix is to measure the balance before and after the transfer and use the delta for all accounting, exactly as the report recommends. Where the token set is known and closed, an allowlist with an explicit rejection of fee-charging tokens is an acceptable alternative. Some designs additionally compare the delta against the requested amount and revert if they differ, which fails closed rather than silently mis-accounting.

Hunting notes

This class hides in any contract that accepts arbitrary ERC20s: vaults, staking pools, lending markets, DEX routers and reward distributors. Recon signals include a token parameter in a deposit or collateral function, a registry that lets users add tokens, or documentation claiming broad token compatibility. Fee-on-transfer, reflection and rebasing tokens are the usual triggers; rebasing tokens cause a related but distinct problem because balances change without any transfer at all.

Glossary

  • Blockchain: a shared, append-only record of transactions maintained by many computers, where programs can run and store data.
  • Smart contract: a program deployed on a blockchain that runs automatically when called and cannot be changed afterwards.
  • ERC20: the common standard that defines how tokens on Ethereum behave, including transfer and transferFrom.
  • Token: a small program on a blockchain that records who owns how much of a digital asset.
  • transfer(): the ERC20 action that sends tokens from the caller's own balance to another address.
  • transferFrom(): the ERC20 action that moves tokens from one account to another on someone's behalf, usually after an approval.
  • Fee-on-transfer token: a token that deducts a fee on every transfer, so the recipient receives less than the amount sent.
  • Reflection token: a token that redistributes a fee to existing holders on each transfer.
  • Deflationary token: a token that removes (burns) a portion of the supply on each transfer.
  • Rebasing token: a token whose holders' balances change automatically over time, without any transfer taking place.
  • Vault: a contract that pools assets from many depositors and tracks each depositor's share.
  • Attribution: the record of how much of a vault or pool a given depositor is entitled to.
  • Balance delta: the difference between an account's balance before and after a transfer, i.e. what actually arrived.
  • Nominal amount: the figure passed to a transfer call, which may differ from what is actually received.
  • Allowlist: an explicit list of tokens or addresses that a protocol accepts, with everything else rejected.
  • Proof-of-concept: a working demonstration that shows a bug can actually be triggered.
  • Fork: a copy of a live blockchain's state used for testing, so experiments run against realistic conditions.
  • Triager: the person who reviews a submitted bug report and decides whether it is valid.
  • Severity: the rating (here, medium) that reflects how serious a finding is judged to be.

More by robee

View all

6 more disclosed reports, best first.

More from Phuture

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.