Skip to content
Business logic Audit finding Intermediate

Fee-on-Transfer tokens cause problems in multiple places

The vault and controller contracts do not account for tokens that charge a fee on transfer, so the vault mints more shares than the assets received and later attempts to send the full balance fail. This can leave the last users unable to withdraw and prevent the end of an epoch from being triggered.

Lambda Follow

Originally disclosed on Code4rena

Submitted by Lambda, also found by csanuragjain, Deivitto, R2, and Rolezn

https://github.com/code-423n4/2022-09-y2k-finance/blob/bca5080635370424a9fe21fe1aded98345d1f723/src/SemiFungibleVault.sol#L94

https://github.com/code-423n4/2022-09-y2k-finance/blob/bca5080635370424a9fe21fe1aded98345d1f723/src/Controller.sol#L168

https://github.com/code-423n4/2022-09-y2k-finance/blob/bca5080635370424a9fe21fe1aded98345d1f723/src/Controller.sol#L225

Impact & Proof Of Concept

Certain tokens (e.g., STA or PAXG) charge a fee for transfers and others (e.g., USDT or USDC) may start doing so in the future. This is not correctly handled in multiple places and would lead to a loss of funds:

  1. SemiFungibleVault.deposit: Here, less tokens are transferred to the vault than the amount of shares that is minted to the user. This is an accounting mistake that will ultimately lead to the situation where the last user(s) cannot withdraw anymore, because there are no more assets left.
  2. Controller.triggerDepeg & Controller.triggerEndEpoch: sendTokens tries to send the whole asset balance to the other contract, which will fail when less tokens are available at this point (because the previous accounting was done without incorporating fees). This will mean that the end can never be triggered and all assets are lost.

Recommended Mitigation Steps

When fee-on-transfer tokens should be supported, you need to check the actual balance differences. If they are not supported, this should be clearly documented.

MiguelBits (Y2K Finance) acknowledged

HickupHH3 (judge) commented:

Valid because SemiFungibleVault may not be applied to WETH only (unlike Vault), but generic tokens. Furthermore, if there is an intention to make semi fungible vaults an EIP standard, then one may have to consider catering to FoT tokens as well, unless explicitly stated otherwise.


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

The contracts assume the full transfer amount is received and do not check the actual balance difference, so fee-on-transfer tokens break the accounting.

Impact

Users may lose funds because the last withdrawals cannot be fulfilled and the end of an epoch may never be triggered, leaving assets stuck.

What the attacker needed

Fee-on-transfer token used; vault or controller in use

The fix

The contracts should check the actual balance difference after transfers if fee-on-transfer tokens are to be supported, or clearly document that such tokens are not supported.

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 when they are moved between wallets. The code here assumes the full amount arrives, so it records more money than it actually holds. Later withdrawals or transfers can fail because the real balance is lower than expected.

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 Lambda

View all

64 more disclosed reports, best first.

More from Y2k Finance 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.