Skip to content
Business logic Audit finding Intermediate

Incorrect ProtocolOwnedLiquidityOhm calculation due to inclusion of other user's reserves

The protocol-owned liquidity calculation for Bunni incorrectly sums the reserves of all BunniTokens, including liquidity deposited by any user. An attacker can inflate the reported protocol-owned liquidity, potentially causing the system to value treasury assets incorrectly.

hash Follow with tvdung94

Originally disclosed on Sherlock

Source: https://github.com/sherlock-audit/2023-11-olympus-judging/issues/172

Found by

hash, tvdung94

Summary

ProtocolOwnedLiquidityOhm for Bunni can include the liquidity deposited by other users which is not protocol owned

Vulnerability Detail

The protocol owned liquidity in Bunni is calculated as the sum of reserves of all the BunniTokens

Solidity
    function getProtocolOwnedLiquidityOhm() external view override returns (uint256) {

        uint256 len = bunniTokens.length;
        uint256 total;
        for (uint256 i; i < len; ) {
            TokenData storage tokenData = bunniTokens[i];
            BunniLens lens = tokenData.lens;
            BunniKey memory key = _getBunniKey(tokenData.token);

        .........

            total += _getOhmReserves(key, lens);
            unchecked {
                ++i;
            }
        }


        return total;
    }

The deposit function of Bunni allows any user to add liquidity to a token. Hence the returned reserve will contain amounts other than the reserves that actually belong to the protocol

Solidity

    // @audit callable by any user
    function deposit(
        DepositParams calldata params
    )
        external
        payable
        virtual
        override
        checkDeadline(params.deadline)
        returns (uint256 shares, uint128 addedLiquidity, uint256 amount0, uint256 amount1)
    {
    }

Impact

Incorrect assumption of the protocol owned liquidity and hence the supply. An attacker can inflate the liquidity reserves The wider system relies on the supply calculation to be correct in order to perform actions of economical impact

Text
https://discord.com/channels/812037309376495636/1184355501258047488/1184397904551628831
it will be determined to get backing
so it will have an economical impact, as we could be exchanging ohm for treasury assets at a wrong price

Code Snippet

POL liquidity is calculated as the sum of bunni token reserves https://github.com/sherlock-audit/2023-11-olympus/blob/9c8df76dc9820b4c6605d2e1e6d87dcfa9e50070/bophades/src/modules/SPPLY/submodules/BunniSupply.sol#L171-L191

BunniHub allows any user to deposit https://github.com/sherlock-audit/2023-11-olympus/blob/9c8df76dc9820b4c6605d2e1e6d87dcfa9e50070/bophades/src/external/bunni/BunniHub.sol#L71-L106

Tool used

Manual Review

Recommendation

Guard the deposit function in BunniHub or compute the liquidity using shares belonging to the protocol

Discussion

0xJem

This is a good catch, and the high level is justified

0xrusowsky

https://github.com/OlympusDAO/bophades/pull/260

IAm0x52

Fix looks good. OnlyOwner modifier has been added to deposits

The original report as published on Sherlock, by hash. Images and videos are our own copies; raw HTML is shown as text. View it on Sherlock.

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 calculation sums the total reserves of all BunniTokens without distinguishing protocol-owned shares from user-deposited liquidity.

Impact

An attacker can inflate the reported protocol-owned liquidity, leading to incorrect supply assumptions and potentially causing the system to exchange assets at the wrong price.

What the attacker needed

Any user can deposit into Bunni

The fix

The deposit function in BunniHub was restricted to only the owner, preventing arbitrary users from adding liquidity.

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.

The protocol tries to measure how much of its own money is in a liquidity pool, but it mistakenly counts everyone else's money too. Because anyone can add money to the pool, an attacker can make the protocol think it has more than it really does, which could lead to bad trades.

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 hash

View all

27 more disclosed reports, best first.

More from Olympus RBS 2.0

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.