getBunniTokenPrice wrongly returns the total price of all tokens
The getBunniTokenPrice function returns the total value of all shares in a pool instead of the price per share, because it does not divide by the total token supply. This incorrect price could cause the RBS module to make bad swaps and lose money.
Arabadzhiev Follow with Drynooo, ge6a and 3 others
Originally disclosed on Sherlock
Source: https://github.com/sherlock-audit/2023-11-olympus-judging/issues/198
Found by
Arabadzhiev, Drynooo, ge6a, hash, jasonxiale, tvdung94
Summary
The function getBunniTokenPrice() is supposed to return the price of 1 Bunni token (1 share) like all other feeds, but it doesn't. It returns the total price of all minted tokens/shares for a specific pool (total value of position's reserves) which is wrong.
Vulnerability Detail
This happens because the totalValue on line 163 is not devided by the total tokens supply.
Impact
The function getBunniTokenPrice always returns wrong price. This would impact the operation of the RBS module. For instance, using the wrong price during a swap may lead to financial losses for the protocol.
Code Snippet
Tool used
Manual Review
Recommendation
Devide totalValue by the total tokens supply.
Discussion
0xrusowsky
https://github.com/OlympusDAO/bophades/pull/244
IAm0x52
Fix looks good. Token price is now normalized to get price per token.
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
The code calculates the total value of all shares but fails to divide by the total token supply to get a per-share price.
Impact
The price feed always returns a wrong price, which could lead to financial losses for the protocol when used in swaps by the RBS module.
What the attacker needed
None
The fix
The function was fixed by dividing the total value by the total token supply to normalise the price per token.
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 price feed should tell you how much one token is worth. Here, the function added up the value of every token in the pool and returned that total, so it looked like one token was worth far more than it really is. If a trading system uses that wrong price, it can trade at bad rates and lose funds.
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.