Skip to content
Business logic Audit finding Intermediate

HybridPool ’s reserve is converted to “amount” twice

The HybridPool contract stored reserves as Bento 'amounts' but then converted them again when reading, causing incorrect reserve values. This led to wrong swap outputs, allowing attackers to receive more tokens than they should and causing losses for liquidity providers.

cmichel Follow

Originally disclosed on Code4rena

Submitted by cmichel, also found by 0xsanson and WatchPug

The HybridPool’s reserves are stored as Bento “amounts” (not Bento shares) in _updateReserves because _balance() converts the current share balance to amount balances. However, when retrieving the reserve0/1 storage fields in _getReserves, they are converted to amounts a second time.

Impact

The HybridPool returns wrong reserves which affects all minting/burning and swap functions. They all return wrong results making the pool eventually economically exploitable or leading to users receiving less tokens than they should.

POC

Imagine the current Bento amount / share price being 1.5. The pool’s Bento share balance being 1000. _updateReserves will store a reserve of 1.5 * 1000 = 1500. When anyone trades using the swap function, _getReserves() is called and multiplies it by 1.5 again, leading to using a reserve of 2250 instead of 1500. A higher reserve for the output token leads to receiving more tokens as the swap output. Thus the pool lost tokens and the LPs suffer this loss.

Recommended Mitigation Steps

Make sure that the reserves are in the correct amounts.

maxsam4 (Sushi) confirmed

The original report as published on Code4rena, by cmichel. 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 reserves were stored as Bento amounts but then converted again in _getReserves, leading to double conversion.

Impact

The pool could be economically exploited, causing users to receive less tokens and LPs to suffer losses.

What the attacker needed

None

The fix

The reserves should be stored and used consistently in the correct amounts, avoiding double conversion.

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 liquidity pool holds reserves of two tokens and uses them to calculate swap amounts. The code mistakenly converted the reserve values twice, making the pool think it had more tokens than it actually did. This meant traders could get more tokens out than they should, and the pool's liquidity providers lost money.

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 cmichel

View all

196 more disclosed reports, best first.

More from Sushi Trident contest phase 1

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.