If the underlying asset is a fee on transfer token, it could break the internal accounting of the vault
The vault mints shares based on the requested deposit amount rather than the amount actually received, so a fee-on-transfer token leaves the vault short of assets. When a user later redeems, the contract may not have enough assets to pay out and the transaction reverts.
Submitted by Udsen, also found by qpzm and saneryee
The Vault._deposit function is used by the users to deposit _assets to the vault and mint vault shares to the recipient address. The amount of _assets are transferred to the Vault as follows:
SafeERC20.safeTransferFrom(
_asset,
_caller,
address(this),
_assetsDeposit != 0 ? _assetsDeposit : _assets
);
The Vault.deposit function uses this _assets amount to calculate the number of shares to be minted to the _recipient address.
The issue here is if the underlying _asset is a fee on transfer token then the actual received amount to the vault will be less than what is referred in the Vault.deposit function _assets input parameter. But the shares to mint is calculated using the entire _assets amount.
This issue could be further aggravated since the _asset is again deposited to the _yieldVault and when needing to be redeemed, will be withdrawn from the _yieldVault as well. These operations will again charge a fee if the _asset is a fee on transfer token. Hence, the actual _asset amount left for a particular user will be less than the amount they initially transferred in.
Hence, when the user redeems the minted shares back to the _assets, the contract will not have enough assets to transfer to the redeemer, thus reverting the transaction.
Proof of Concept
SafeERC20.safeTransferFrom(
_asset,
_caller,
address(this),
_assetsDeposit != 0 ? _assetsDeposit : _assets
);
_yieldVault.deposit(_assets, address(this));
_yieldVault.withdraw(_assets, address(this), address(this));
SafeERC20.safeTransfer(IERC20(asset()), _receiver, _assets);
Tools Used
VSCode
Recommended Mitigation Steps
It is recommended to compute the _assets amount balance of the contract before and after the safeTransferFrom call to get the difference between the two for the “actually transferred” amount to the Vault. Then, the “actually transferred” amount can be converted to shares and mint the correct amount of shares to the recipient.
uint256 balanceBefore = _asset.balanceOf(address(this));
SafeERC20.safeTransferFrom(
_asset,
_caller,
address(this),
_assetsDeposit != 0 ? _assetsDeposit : _assets
);
uint256 balanceAfter = _asset.balanceOf(address(this));
uint256 transferredAmount = balanceAfter - balanceBefore;
asselstine (PoolTogether) confirmed
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 calculates shares from the requested deposit amount instead of measuring the actual balance increase after the transfer.
Impact
With a fee-on-transfer asset, the vault's internal accounting becomes incorrect and redemptions can revert because the contract lacks enough assets to pay the redeemer.
What the attacker needed
The underlying asset is a fee-on-transfer token
The fix
The deposit should measure the contract's asset balance before and after the transfer and use the difference to calculate shares.
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 between wallets. This vault assumed the full amount arrived and gave the user shares for the full amount, so later there was not enough money left to give back when the user wanted to withdraw.
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.