VaultHelper deposits don’t work with fee-on transfer tokens
The VaultHelper contract's deposit functions transfer tokens from the user to itself, but if the token charges a fee on transfer, the contract receives less than the requested amount. A subsequent vault deposit then tries to transfer more tokens than the contract holds, causing the transaction to revert and potentially bricking the protocol.
Submitted by cmichel, also found by 0xsanson
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(). Others are rebasing tokens that increase in value over time like Aave’s aTokens (balanceOf changes over time).
Impact
The VaultHelper’s depositVault() and depositMultipleVault functions transfer _amount to this contract using IERC20(_token).safeTransferFrom(msg.sender, address(this), _amount);. This could have a fee, and less than _amount ends up in the contract. The next actual vault deposit using IVault(_vault).deposit(_token, _amount); will then try to transfer more than the this contract actually has and will revert the transaction.
Recommended Mitigation Steps
One possible mitigation is to measure the asset change right before and after the asset-transferring routines. This is already done correctly in the Vault.deposit function.
GalloDaSballo (judge) commented:
Agree with finding, checking actual balance of contract would mitigate vulnerability Additionally ensuring the protocol never uses rebasing or tokens with
feeOnTransfercan be enough to mitigateThe vulnerability can brick the protocol However it can be sidestepped by simply not using
feeOnTransfertokens Downgrading to medium
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 does not measure the actual token balance change after a transfer, so it assumes the full amount was received even when a fee-on-transfer token reduces it.
Impact
The vulnerability can brick the protocol, but it can be sidestepped by simply not using fee-on-transfer tokens; the judge downgraded it to medium.
What the attacker needed
Use of fee-on-transfer tokens
The fix
The contract should measure the actual token balance change before and after transfers, as done in the Vault.deposit function, or the protocol should avoid using fee-on-transfer or rebasing tokens.
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 digital tokens take a small cut every time they are moved between wallets. The VaultHelper contract assumes it receives the full amount, so when it later tries to deposit that amount into the vault, it does not have enough tokens and the whole transaction fails. This means the helper cannot be used with such tokens, and any attempt to use them will get stuck.
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.