Skip to content
Business logic Audit finding Intermediate

Inconsistent balance when supplying transfer-on-fee or deflationary tokens

The `supplyTokenTo` function assumes the full `amount` is received after a token transfer, but for transfer-on-fee or deflationary tokens the actual received amount is less, causing an inconsistency between the accounted and actual balance. An attacker could exploit this to manipulate the yield source's accounting.

shw Follow

Originally disclosed on Code4rena

Submitted by shw, also found by cmichel

The supplyTokenTo function of SwappableYieldSource assumes that amount of _depositToken is transferred to itself after calling the safeTransferFrom function (and thus it supplies amount of token to the yield source). However, this may not be true if the _depositToken is a transfer-on-fee token or a deflationary/rebasing token, causing the received amount to be less than the accounted amount. SwappableYieldSource.sol L211-L212

Recommend getting the actual received amount by calculating the difference of token balance before and after the transfer. For example, re-writing line 211-212 to:

uint256 balanceBefore = _depositToken.balanceOf(address(this));
_depositToken.safeTransferFrom(msg.sender, address(this), amount);
uint256 receivedAmount = _depositToken.balanceOf(address(this)) - balanceBefore;
yieldSource.supplyTokenTo(receivedAmount, address(this));

PierrickGT (PoolTogether) confirmed:

PR: https://github.com/pooltogether/swappable-yield-source/pull/9

The original report as published on Code4rena, by shw. 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 contract uses the input `amount` instead of the actual received balance after transfer, which is incorrect for fee-on-transfer or deflationary tokens.

Impact

This could lead to incorrect accounting, potentially allowing an attacker to exploit the discrepancy to gain more shares or funds than deserved.

What the attacker needed

A transfer-on-fee or deflationary token

The fix

The contract should measure the actual received amount by taking the difference of token balance before and after the transfer, and use that for supplying to the yield source.

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 fee when transferred, so the receiver gets less than the sender sends. The code assumed the full amount arrived, which could cause the contract's records to be wrong. An attacker might use such a token to trick the contract into thinking it has more than it does.

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 shw

View all

22 more disclosed reports, best first.

More from PoolTogether

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.