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