Deposits don’t work with fee-on transfer tokens
The deposit function credits the user with the full amount requested, but fee-on-transfer tokens cause the contract to receive less than that amount. An attacker could deposit such a token and receive an inflated balance, potentially withdrawing more than they deposited.
Submitted by cmichel
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).
The RCTreasury.deposit() function will credit more deposits than the contract actually received:
erc20.safeTransferFrom(msgSender(), address(this), _amount);
user[_user].deposit += SafeCast.toUint128(_amount);
Recommend ensuring that the erc20 token does not implement any customizations. Alternatively, a mitigation is to measure the asset change right before and after the asset-transferring routines
Splidge (Reality Cards) acknowledged:
The issue that keeps on giving..
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 credits the user with the requested transfer amount without checking the actual balance change, so fee-on-transfer tokens cause an over-credit.
What the attacker needed
Fee-on-transfer token; deposit function
The fix
The contract should either reject tokens with custom transfer behaviour or measure the actual balance change before and after the transfer to credit only the received amount.
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 deposit function here assumes the full amount arrives and credits the user with that full amount, even though the contract received less. This means a user could get more credit than they actually paid in.
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.