Skip to content
Business logic Audit finding Intermediate

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.

PP1004 Follow

Originally disclosed on Code4rena

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 initialLiquidityNew value.

HickupHH3 (judge) commented:

Not sure how you can account for transfer fee in initialLiquidityNew since 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.


The original report as published on Code4rena, by PP1004. 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

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.

More by PP1004

View all

2 more disclosed reports, best first.

More from Rubicon v2

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.