Cannot deposit to BathToken if token is Deflationary Token (BathHouse.sol)
When a user tried to create a new BathToken vault using a deflationary token as the underlying or paired asset, the deposit call reverted because the contract assumed the full amount arrived after transfer. An attacker could not steal funds, but the vault creation function was unusable for such tokens, affecting protocol availability.
Submitted by PP1004, also found by unforgiven, GimelSec, and camden
Function openBathTokenSpawnAndSignal will alway revert when newBathTokenUnderlying or desiredPairedAsset is deflationary token
Proof of Concept
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() For example, I will assume that newBathTokenUnderlying is deflationary token. After line 163, the actual amount of newBathTokenUnderlying that BathHouse gained will be smaller than initialLiquidityNew. It will make the deposit call reverted because there are not enough fund to transfer.
Recommended Mitigation Steps
set initialLiquidityNew = newBathTokenUnderlying.balanceOf(address(this)) after line 163 and initialLiquidityExistingBathToken = desiredPairedAsset.balanceOf(address(this)) after line 178
bghughes (Rubicon) acknowledged and commented:
This is correct, though I believe un needed. If the user wants to create a vault for a deflationary token they need only account for said transfer fee when calculating their
initialLiquidityNewvalue.
Not sure how you can account for transfer fee in
initialLiquidityNewsince it’s the same amount used for approval and deposit:IBathToken(newOne).deposit(initialLiquidityNew, msg.sender);It simply means that deflationary / FoT tokens arent supported at all, which isn’t necessarily a bad thing. There isn’t a loss of assets, though
function of the protocol or its availability could be impacted. Keeping it at medium severity, although could’ve potentially lowered to QA too.
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
Likely the contract used the requested liquidity amount rather than the actual post-transfer balance when calling deposit, so a transfer fee left it short of funds.
Impact
Vault creation with deflationary or fee-on-transfer tokens could fail, impacting protocol availability, but no assets are lost.
What the attacker needed
A deflationary or fee-on-transfer token; calling the vault creation function
The fix
The contract should read the actual token balance after the transfer and use that as the liquidity amount, though the maintainer considered this unnecessary and the judge noted such tokens are simply unsupported.
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 fee each time they are moved, so the receiver gets less than the sender sent. This contract checked the amount it expected to receive rather than the amount it actually held, so its next step failed. The result is that the feature simply does not work with those tokens, though no money is lost.
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.