Missing checks allow strategists to steal all fund via tailOff
The tailOff function accepted an arbitrary strategy utility address, and the rebalance function allowed the pool's underlying token to be passed as the asset to move. A malicious strategist could therefore direct a BathToken to send its entire underlying balance to a contract they controlled.
Submitted by shenwilly, also found by 0x52, Kumpa, unforgiven, pedroais, MiloTruck, and pauliax
Impact
Strategists can call tailOff with malicious payload to steal all funds within any BathToken.
There are 2 issues that makes this possible:
BathPair.tailOffallows arbitrary_stratUtiladdress.BathToken.rebalanceallows underlying token asfilledAssetToRebalance.
These allow malicious strategists to input any token address, including the underlying token of a BathToken, and transfer them to a contract of their choosing.
Proof of Concept
A malicious strategist calls tailOff with the following payload:
{
targetPool: bathUSDC.address,
tokenToHandle: USDC.address,
targetToken: USDT.address, // any address
_stratUtil: maliciousContract.address,
amount: USDC.balanceOf(bathUSDC.address),
hurdle: 0, // any
_poolFee: 0 // any
}
bathUSDC BathToken will then send all USDC to the strategist’s maliciousContract. All deposits are lost.
Recommended Mitigation Steps
- Whitelist the addresses that can be used as
_stratUtil. - Add a check in
rebalanceto prevent transferring underlying token: require(filledAssetToRebalance != underlyingToken, “must not be underlying”);
bghughes (Rubicon) acknowledged, but disagreed with severity
HickupHH3 (judge) decreased severity to Medium and commented:
Making this the primary issue of strategist stealing funds via the
tailOff()function. Rationale of med severity is outlined in #344.
Good issue, implemented the
require(filledAssetToRebalance != underlyingToken, "must not be underlying");fix 💯
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 code trusted the strategist-supplied strategy utility address without a whitelist and did not stop the pool's own underlying token from being selected as the asset to rebalance.
Impact
All funds deposited in any BathToken could be stolen by a malicious strategist, though the judge rated the issue Medium rather than Critical.
What the attacker needed
Attacker is a strategist on the pool
The fix
The project added a check in rebalance that rejects the underlying token as the asset to rebalance, and the report also recommends whitelisting strategy utility addresses.
How it was found
- A malicious strategist calls tailOff on the target BathToken.
- They pass their own contract as the strategy utility address.
- They set the underlying token as the asset to handle and the full pool balance as the amount.
- The BathToken sends all of its underlying tokens to the attacker's contract.
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 pool contract holds users' deposits and lets a trusted manager, called a strategist, move funds around. Two checks were missing, so a dishonest strategist could tell the pool to send all of its main token to an address they chose. That means every deposit in the pool could be taken.
What is Access control?
A user can do something their role should not allow: reach an admin function, act on a feature they have not paid for, or skip a permission check. IDOR is the special case where the object belongs to someone else.