No cap on fees can result in a DOS in BathToken.withdraw()
The owner can set an arbitrary fee above 100%, causing withdrawals to revert due to an underflow. This prevents users from withdrawing their BathTokens.
Submitted by Ruhum, also found by cccz, 0x1f8b, kenzo, xiaoming90, reassor, sseefried, catchup, shenwilly, GimelSec, defsec, StErMi, berndartmueller, throttle, sashiketh, eccentricexit, 0xDjango, peritoflores, pedroais, hubble, joestakey, 0x4non, blackscale, csanuragjain, Dravee, ellahi, horsefacts, hubble, and rotcivegaf_
https://github.com/code-423n4/2022-05-rubicon/blob/main/contracts/RubiconMarket.sol#L1232
https://github.com/code-423n4/2022-05-rubicon/blob/main/contracts/rubiconPools/BathToken.sol#L261
Impact
The owner can set an arbitrary fee. If they set it to a value above 100%, withdrawing BathTokens won’t be possible anymore because of an underflow. In RubiconMarket the owner can also have an arbitrary fee although that won’t result in a DOS. But, the user might pay an absurdly high fee.
There should be checks that only allow fees up to a specific value, e.g. 10%.
Proof of Concept
For the DOS:
- Owner sets fees to 101% using
BathToken.setFeeBPS(): https://github.com/code-423n4/2022-05-rubicon/blob/main/contracts/rubiconPools/BathToken.sol#L261 - User tries to withdraw which will revert here because
fee > r: https://github.com/code-423n4/2022-05-rubicon/blob/main/contracts/rubiconPools/BathToken.sol#L604
Recommended Mitigation Steps
Add a limit to the constructors where a fee is set and to all the configuration functions for fees.
bghughes (Rubicon) acknowledged
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 fee is not capped, so a fee greater than the withdrawal amount causes an arithmetic underflow when subtracted.
Impact
Withdrawals become impossible, causing a denial of service for users.
What the attacker needed
Owner sets fee above 100%
The fix
Add a limit to the constructors and configuration functions for fees.
How it was found
- Owner sets fees to 101% using BathToken.setFeeBPS()
- User tries to withdraw which will revert because fee > r
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.
A smart contract lets the owner set a fee percentage. If the owner sets it too high (over 100%), the code that subtracts the fee from the withdrawal amount fails because it would go negative, so users cannot withdraw their funds.
What is DoS?
A request that exhausts resources or crashes a component. Many programs forbid testing it; reports usually show it from code, not by attacking.