Skip to content
Business logic Audit finding Advanced

AssignUnassignedAssets revives a wiped Junior tranche at a near-zero NAV, so any depositor buys the wiped holders' recovery and the receiver takes the rest

The owner-only function that clears leftover unassigned pool assets prices new Junior shares against a wiped tranche's zero principal, so it mints almost the whole tranche to a chosen receiver and reopens the tranche to ordinary deposits. Any depositor can then buy the wiped holders' future recovery cheaply, and the receiver keeps the remainder.

farismaulana Follow

Originally disclosed on Immunefi

Critical View original
  • Disclosed after under an hour

#98794 [SC-Critical] assignUnassignedAssets revives a wiped Junior tranche at a near-zero NAV, so any depositor buys the wiped holders' recovery and the receiver takes the rest

Submitted on Nov 10th 2026 at 08:08:04 UTC by @farismaulana for Audit Competition | Plether

Description

Brief/Intro

when a loss wipes Junior principal to zero, the Junior shares stay live (the seed floor guarantees supply), and their holders keep the claim on every unit of LP value that later flows back to Junior through the waterfall. every ordinary entry path refuses to enter this state, so nobody can buy that claim.

HousePool.assignUnassignedAssets(false, receiver), the owner's documented way to clear unassignedAssets and the only target that does not revert in this state, breaks that protection twice. it prices the bootstrap at the wiped principal of 0 and mints the receiver U * (supply + 1000) shares, ~100% of the tranche. it also sets Junior principal to U, which reopens the tranche to ordinary deposits priced at a NAV of U. any unprivileged LP can then buy the wiped holders' recovery for cents on the dollar.

in the PoC an honest owner recapitalization of the exact Senior gap, followed by a 1 cent favourable move before the next reconcile, leaves U = 190_000 USDG. after the assignment an unprivileged LP deposits 1_000_000 USDG, receives 84% of the tranche, and when the mark recovers holds 10_422_688 USDG and withdraws 1_999_942 USDG in cash. the wiped Junior LP, who recovers 11_209_998 USDG without the assignment, is left with 0.00001 USDG.

Vulnerability Details

how the state arises with honest actors

  1. a trader-PnL loss larger than juniorPrincipal is reconciled through the permissionless settleLpEpoch. the waterfall absorbs it Junior-first, so juniorPrincipal = 0 and Senior is impaired below its high-water mark. Junior supply stays live because the seed receiver can never drop below its floor (TrancheVault.sol#L322-L324).
  2. the owner recapitalizes the Senior gap with CfdEngine.recapitalizePool, a documented immediate power. the recap is applied inside _reconcile after the waterfall plan, so any revenue reconciled in the same pass restores part of the gap first and the rest of the recap becomes ownerless:
Solidity
            } else {
                uint256 gap = state.waterfall.seniorHighWaterMark > state.waterfall.seniorPrincipal
                    ? state.waterfall.seniorHighWaterMark - state.waterfall.seniorPrincipal
                    : 0;
                if (gap > 0) {
                    uint256 seniorAssignedAssets = remaining > gap ? gap : remaining;
                    state.waterfall.seniorPrincipal += seniorAssignedAssets;
                    remaining -= seniorAssignedAssets;
                }
            }
        }
        if (remaining > 0) {
@>          state.unassignedAssets += remaining;
        }
  1. unassignedAssets > 0 blocks new tranche-deposit requests and activation, and the spec treats it as "exceptional telemetry, not a normal operating bucket". the only way to clear it is assignUnassignedAssets.

the defect

Solidity
        uint256 amount = unassignedAssets;
        if (amount == 0) {
            revert HousePool__NoUnassignedAssets();
        }
        if (toSenior) {
@>          _requireSeniorDepositCapacity(amount, _getWaterfallState());
        }

        address targetVault = toSenior ? seniorVault : juniorVault;
        if (targetVault == address(0)) {
            revert HousePool__ZeroAddress();
        }
@>      uint256 shares = ITrancheVaultBootstrap(targetVault).quoteBootstrapDeposit(amount);
        if (shares == 0) {
            revert HousePool__BootstrapSharesZero();
        }
        ...
        } else {
@>          juniorPrincipal += amount;
        }
        unassignedAssets = 0;
@>      ITrancheVaultBootstrap(targetVault).bootstrapMint(shares, receiver);

the quote is priced against the current principal with no wiped-tranche check:

Solidity
    function quoteBootstrapDeposit(
        uint256 assets
    ) external view returns (uint256) {
@>      return _convertToSharesUsingAssets(assets, _depositPricingAssets(), Math.Rounding.Floor);
    }

    function _convertToSharesUsingAssets(uint256 assets, uint256 totalAssets_, Math.Rounding rounding)
        internal view returns (uint256)
    {
@>      return Math.mulDiv(assets, accruedTotalSupply() + VIRTUAL_SHARES, totalAssets_ + 1, rounding);
    }

with Junior principal 0 this is U * (supply + 1000) / 1. the receiver's fraction of the tranche becomes (supply + 1000) * U / ((supply + 1000) * U + supply), which is ~100% for any U. in the PoC, U = 190_000e6 against a supply of 10_006_665_431_847_178 mints 1_901_266_432_051_153_820_000_000_000 shares, a fraction of 0.999999999994736842. even U = 1 USDG gives the receiver 0.999999000000999999 of the tranche.

the owner has no other target in this state. Senior capacity is min(cap, juniorPrincipal * 8000 / 2000), which is 0 while Junior principal is 0 (HousePoolSeniorCapacityLib.sol#L35-L39, #L102-L113), so assignUnassignedAssets(true, ...) reverts HousePool__ExceedsSeniorDepositCapacity. Junior is the only target that executes.

every other entry path protects this exact state

the protocol treats "principal 0 with live supply" as a terminally wiped tranche whose holders must not be diluted:

Solidity
        if (isSenior
                ? ctx.pendingState.waterfall.seniorPrincipal == 0 && ctx.pendingState.seniorSupply != 0
@>              : ctx.pendingState.waterfall.juniorPrincipal == 0 && ctx.pendingState.juniorSupply != 0) {
            return false;
        }
Solidity
@>      bool juniorActivationDeferred = juniorDepositPhase.pricingAssets == 0 && juniorDepositPhase.pricingSupply != 0;

the public docs (docs.plether.com, "The liquidity pool and tranche waterfall", section "Senior impairment and tranche wipeout") state the rule this enforces:

A tranche is terminally wiped when shares still exist but its accounting assets reach zero. An ordinary deposit cannot silently revive a wiped tranche. Recovery can come from future reconciled LP-owned value allocated through the waterfall or from an explicit recapitalization path that preserves existing ownership rights. ... This prevents a new depositor from obtaining the recovery rights of previously wiped holders through a nominal first deposit.

and the NatSpec of assignUnassignedAssets itself describes the function as the safeguard: "Prevents later LPs from implicitly capturing previously ownerless value." the owner path does the opposite. it hands a new holder the recovery rights of the wiped holders for a nominal amount, and it revives the tranche: right after the assignment canAcceptTrancheDeposits(false) returns true again.

the wiped holders' claim is real value. Junior has no high-water mark, so once Senior is whole every unit of reconciled revenue accrues to Junior principal (HousePoolWaterfallAccountingLib.sol#L158). a zero-NAV bootstrap is only neutral when the target tranche has no residual claimant, as in a Senior reboot with principal and high-water mark both 0. a wiped Junior with live holders is the opposite case.

the assignment reopens the wiped tranche to any depositor

after the assignment Junior principal is U, Senior is whole and unassignedAssets is 0, so every gate the wiped state closed is open again: canAcceptTrancheDeposits(false) returns true and the request preflight no longer reverts. deposit activation prices new shares against the current Junior principal (HousePool.sol#L914-L920):

Solidity
        juniorDepositPhase.pricingAssets = juniorPrincipal;
        juniorDepositPhase.pricingSupply = _juniorShareSupply();
@>      bool juniorActivationDeferred = juniorDepositPhase.pricingAssets == 0 && juniorDepositPhase.pricingSupply != 0;
        if (!juniorActivationDeferred) {
@>          juniorDepositPhase = _settleDepositPhase(juniorVault, result.cutoffEpoch, juniorDepositPhase, 0, false);
        }

with pricingAssets = U, a deposit D buys D / (U + D) of the tranche, and with it the same share of the recovery that the waterfall later credits to Junior. the attacker needs no role:

  1. watch for UnassignedAssetsAssigned(false, ...) while the mark is still depressed.
  2. call juniorVault.requestDeposit(D, attacker, attacker).
  3. any keeper's OrderRouter.settleLpEpoch activates it at Junior NAV U.
  4. when the mark recovers, the reconciled revenue accrues to Junior principal and the attacker redeems through the same permissionless settlement.

without the assignment, step 2 reverts TrancheVault__TerminallyWiped and the recovery stays with the wiped holders.

an assignment is value-neutral only after the recovery has already been reconciled into Junior principal (J much larger than U). at J = 0 any amount hands over the tranche and reopens it at a NAV of U, and the contract gives the owner no signal for when the call becomes safe.

numerical example from the PoC (release parameters)

step action state
0 Junior LP 10_000_000, Senior LP 39_000_000, trader 19_000_000 LONG at 1.00 J = 10_000_000.99, S = H = 39_000_001
1 mark 0.40, keeper settleLpEpoch J = 0, Junior supply 1.0007e16 live, S = 37_636_836.80 < H = 39_000_711.43
2 owner recapitalizePool(1_363_874.63) (exact gap), mark 0.41, keeper settleLpEpoch J = 0, S = H, unassignedAssets = 190_000
3 owner assignUnassignedAssets(false, receiver) (Senior reverts) receiver holds 0.999999999994736842 of Junior
4 mark reverts to 1.00, keeper settleLpEpoch J = 11_399_643.93

the old Junior LP ends with 0.000059 USDG. without the assignment the same LP ends with 11_209_998.88 USDG, and with no owner action at all it recovers 10_036_124.43 USDG. the receiver ends with 11_399_643.93 USDG claimable and redeems 999_968.76 USDG in cash through settleLpEpoch within the test.

with an unprivileged depositor in the same flow:

step action state
3 owner assignUnassignedAssets(false, receiver) at mark 0.41 J = 190_000, Junior deposits reopen
3a unprivileged LP requestDeposit(1_000_000), keeper settleLpEpoch at mark 0.41 deposit activates at J = 190_000, the LP holds 0.840587655 of Junior
4 mark reverts to 1.00, keeper settleLpEpoch J = 12_399_287.75
5 the LP redeems 2_000_000 worth through settleLpEpoch the LP receives 1_999_942.55 USDG in cash

the unprivileged LP holds 10_422_688.22 USDG of Junior value for its 1_000_000 deposit, a 9_422_688 USDG gain, and its wallet ends 999_942 USDG above where it started after taking only part of that value out. the receiver keeps 1_976_599.53 USDG. the wiped Junior LP ends with 0.00001 USDG against 11_209_998.88 USDG in the control without the assignment.

Impact Details

  • the wiped Junior holders lose their entire recovery. the PoC measures 11_209_998 USDG against the same recapitalization without the assignment, and 10_036_124 USDG against no owner action at all. that is principal: the same LP held 10_036_836 USDG before the wipe.
  • an unprivileged depositor pulls most of it. a 1_000_000 USDG deposit placed after the assignment and before the reversion takes 84% of the tranche, ends with 10_422_688 USDG, and withdraws 1_999_942 USDG in cash within the test. the deposit size is the attacker's choice; a larger deposit takes a larger share.
  • the receiver takes whatever the depositors do not, ~100% when nobody else enters.
  • the same assignment built from ordinary 10% moves (five realized 10% trader wins, then one 10% move that wipes Junior and later reverts) takes 1_553_191 USDG from the wiped holders.
  • the trigger is the owner's documented immediate power to "assign ownerless pool assets", called on the only target that does not revert. the defect is the missing wiped-tranche check inside the function, and the beneficiary is any address that deposits.

severity: Critical, Direct theft of any user funds. the wiped Junior LPs' share of pool value is transferred to an unprivileged depositor and to the receiver, and the attacker realizes it in cash through the permissionless settlement path.

Recommendation

apply the same wiped-tranche rule the ordinary entry paths use. refuse to mint into a tranche whose principal is 0 while its supply is live, and refuse a Senior assignment while Senior is below its high-water mark, so ownerless value waits until the waterfall has restored the tranche:

Diff
         if (toSenior) {
             _requireSeniorDepositCapacity(amount, _getWaterfallState());
+            if (seniorPrincipal < seniorHighWaterMark) revert HousePool__TrancheImpaired();
+            if (seniorPrincipal == 0 && _seniorShareSupply() != 0) revert HousePool__TrancheWiped();
+        } else if (juniorPrincipal == 0 && _juniorShareSupply() != 0) {
+            revert HousePool__TrancheWiped();
         }

References

https://github.com/immunefi-team/audit-comp-plether/blob/a82d4fefb02768e5b3bddcc97dee371eee24fea8/packages/perps/src/HousePool.sol#L660-L704

https://github.com/immunefi-team/audit-comp-plether/blob/a82d4fefb02768e5b3bddcc97dee371eee24fea8/packages/perps/src/HousePool.sol#L653-L657

https://github.com/immunefi-team/audit-comp-plether/blob/a82d4fefb02768e5b3bddcc97dee371eee24fea8/packages/perps/src/TrancheVault.sol#L1392-L1396

https://github.com/immunefi-team/audit-comp-plether/blob/a82d4fefb02768e5b3bddcc97dee371eee24fea8/packages/perps/src/TrancheVault.sol#L1853-L1859

https://github.com/immunefi-team/audit-comp-plether/blob/a82d4fefb02768e5b3bddcc97dee371eee24fea8/packages/perps/src/HousePool.sol#L494-L497

https://github.com/immunefi-team/audit-comp-plether/blob/a82d4fefb02768e5b3bddcc97dee371eee24fea8/packages/perps/src/HousePool.sol#L914-L920

https://github.com/immunefi-team/audit-comp-plether/blob/a82d4fefb02768e5b3bddcc97dee371eee24fea8/packages/perps/src/TrancheVault.sol#L1361-L1367

https://github.com/immunefi-team/audit-comp-plether/blob/a82d4fefb02768e5b3bddcc97dee371eee24fea8/packages/perps/src/TrancheVault.sol#L1585-L1587

https://github.com/immunefi-team/audit-comp-plether/blob/a82d4fefb02768e5b3bddcc97dee371eee24fea8/packages/perps/src/TrancheVault.sol#L322-L324

https://github.com/immunefi-team/audit-comp-plether/blob/a82d4fefb02768e5b3bddcc97dee371eee24fea8/packages/perps/src/libraries/HousePoolPendingPreviewLib.sol#L111-L137

https://github.com/immunefi-team/audit-comp-plether/blob/a82d4fefb02768e5b3bddcc97dee371eee24fea8/packages/perps/src/libraries/HousePoolSeniorCapacityLib.sol#L27-L43

https://github.com/immunefi-team/audit-comp-plether/blob/a82d4fefb02768e5b3bddcc97dee371eee24fea8/packages/perps/src/libraries/HousePoolWaterfallAccountingLib.sol#L140-L159

https://github.com/immunefi-team/audit-comp-plether/blob/a82d4fefb02768e5b3bddcc97dee371eee24fea8/packages/perps/ACCOUNTING_SPEC.md?plain=1#L320-L330

https://github.com/immunefi-team/audit-comp-plether/blob/a82d4fefb02768e5b3bddcc97dee371eee24fea8/packages/perps/ACCOUNTING_SPEC.md?plain=1#L648-L652

Proof of Concept

Proof of Concept

the test deploys the in-scope contracts through the existing BasePerpTest harness at release risk parameters. only Pyth (MockPyth) and USDG (mock token) are mocked. every trade goes through the production Router FIFO with a keeper executeOrder, and every reconcile after setup is the permissionless OrderRouter.settleLpEpoch.

  1. create packages/perps/test/perps/poc/WipedJuniorAssignment.t.sol with the content below (no harness changes are needed)
  2. from packages/perps, run:
forge test --match-path test/perps/poc/WipedJuniorAssignment.t.sol -vv

tests:

  • test_assignIntoWipedJunior_redirectsRecovery: the full honest flow and the assignment, against the same flow without it
  • test_control_noAssignment_oldJuniorRecovers: the old holder's recovery with no owner action and with the recap only
  • test_seniorAssignmentReverts_noAlternative: Senior capacity is 0 at J = 0, the Senior target reverts
  • test_unassignedBlocksDeposits: which gate blocks deposits before and after the assignment
  • test_ordinaryEntryIntoWipedJuniorIsDeferred: the protocol's own rule defers an ordinary deposit in the same state, while the owner path mints 0.999999 of supply for 1 USDG
  • test_escape_waitUntilJuniorPrincipalPositive: assignment timing, at J = U and after the recovery is reconciled
  • test_variant_tenPercentMoves_redirectsRecovery: the same outcome built from 10% moves only
  • test_outsiderDepositAfterAssignment_capturesRecovery: an unprivileged LP deposits after the assignment, buys 84% of the revived tranche and withdraws more cash than it deposited, while the same request reverts TerminallyWiped without the assignment
Solidity
// SPDX-License-Identifier: AGPL-3.0
pragma solidity 0.8.35;

import {BasePerpTest} from "../BasePerpTest.sol";
import {CfdTypes} from "@plether/perps/CfdTypes.sol";
import {OrderV3Types} from "@plether/perps/OrderV3Types.sol";
import {TrancheVault} from "@plether/perps/TrancheVault.sol";
import {IHousePool} from "@plether/perps/interfaces/IHousePool.sol";
import {Vm} from "forge-std/Vm.sol";
import {console2} from "forge-std/console2.sol";

/// @title PoC: HousePool.assignUnassignedAssets(false, receiver) mints Junior shares at zero NAV into a wiped
///        Junior tranche (principal 0, live share supply) and hands the old Junior holders' recovery to the receiver.
/// @notice Root cause: HousePool.sol:681-702 quotes ITrancheVaultBootstrap.quoteBootstrapDeposit (TrancheVault.sol:1392-1396)
///         = mulDiv(U, supply + 1000, pricingAssets + 1) with pricingAssets = Junior principal = 0, and has no
///         "principal == 0 && supply != 0" gate. Every sibling entry path has one: request admission
///         (HousePool.sol:494-497), activation (HousePool.sol:917), the display quote (TrancheVault.sol:1366-1367) and
///         the request preflight (TrancheVault.sol:1585-1587).
/// @dev Local deploy of the repo contracts at a82d4fef (BasePerpTest) with release risk parameters
///      (DEPLOYMENT.md:126-165). Only Pyth (MockPyth) and USDG (MockSettlementToken) are mocked. Every trade goes through
///      the production Router FIFO: LegacyOrderRouterHarness.commitOrder (test-only adapter that builds a V3 request and
///      self-delegatecalls the production commitOrder), then the production OrderRouter.executeOrder. Every post-setup
///      reconcile is the permissionless production OrderRouter.settleLpEpoch with a MockPyth update; it needs matured
///      LP work (HousePool.sol:1183-1184), which an ordinary Senior LP's 2-USDG redemption request provides. Setup-only
///      LP funding uses BasePerpTest._fundJunior/_fundSenior (no open positions at that time).
contract WipedJuniorAssignmentTest is BasePerpTest {

    address internal constant JUNIOR_LP = address(0xA11CE); // old Junior holder (pre-wipe LP)
    address internal constant SENIOR_LP = address(0xB0B);
    address internal constant LONG_TRADER = address(0x7A01);
    address internal constant KEEPER = address(0x4EE9);
    address internal constant RECEIVER = address(0x7E5E); // owner-chosen receiver (e.g. a treasury / recovery wallet)
    address internal constant NEW_JUNIOR_LP = address(0xC0DE1);
    address internal constant NEW_SENIOR_LP = address(0xC0DE2);

    uint256 internal constant JUNIOR_DEPOSIT = 10_000_000e6;
    uint256 internal constant SENIOR_DEPOSIT = 39_000_000e6; // Senior 39M + 1 seed <= 40M cap and <= 80% of pool
    uint256 internal constant LONG_NOTIONAL = 19_000_000e6; // < maxSkewRatio 0.4 * 49M net depth
    uint256 internal constant TRADER_DEPOSIT = 2_000_000e6;
    uint256 internal constant TRADER_MARGIN = 1_000_000e6;
    uint256 internal constant NEW_LP_DEPOSIT = 1_000_000e6;

    uint256 internal constant P_OPEN = 1e8;
    uint256 internal constant P_WIPE = 0.4e8; // LONG skew 19M * 0.60 = 11.4M LP loss > Junior 10M
    uint256 internal constant P_DRIFT = 0.41e8; // +1 cent favourable drift between the recap and the next reconcile
    uint256 internal constant P_SMALL_REVENUE = 0.42e8; // one more cent: first revenue that reaches Junior
    uint256 internal constant P_REVERT = 1e8; // mark reverts to the open price

    uint256 internal longSize;

    struct Snap {
        uint256 senior;
        uint256 junior;
        uint256 hwm;
        uint256 unassigned;
        uint256 pendingRecap;
        uint256 juniorSupply;
        uint256 poolAssets;
        uint256 deficit;
        bool degraded;
    }

    struct Outcome {
        uint256 receiverShares;
        uint256 juniorSupply;
        uint256 receiverFractionWad;
        uint256 oldHolderValue;
        uint256 receiverValue;
        uint256 juniorPrincipal;
        uint256 unassigned;
        uint256 seniorPrincipal;
        uint256 hwm;
    }

    // ---------------------------------------------------------------------
    // Release parameters (DEPLOYMENT.md:126-165)
    // ---------------------------------------------------------------------

    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 _initialSeniorDeposit() internal pure override returns (uint256) {
        return 0;
    }

    function _initialJuniorSeedDeposit() internal pure override returns (uint256) {
        return 1e6;
    }

    function _initialSeniorSeedDeposit() internal pure override returns (uint256) {
        return 1e6;
    }

    function setUp() public override {
        super.setUp();
        _setSeniorCapacity(40_000_000e6, 8000); // release caps (DEPLOYMENT.md:160-161)

        assertEq(engine.executionFeeBps(), 4, "release executionFeeBps");
        assertEq(engine.settlementBufferBps(), 25, "release settlementBufferBps");
        assertEq(engine.frozenCloseSpreadBps(), 50, "release frozenCloseSpreadBps");
        assertEq(pool.maxSeniorShareBps(), 8000, "release maxSeniorShareBps");
        assertEq(pool.maxSeniorExposureAssets(), 40_000_000e6, "release maxSeniorExposureAssets");

        // Real LPs in both tranches through the async vault flow.
        _fundJunior(JUNIOR_LP, JUNIOR_DEPOSIT);
        _fundSenior(SENIOR_LP, SENIOR_DEPOSIT);

        _fundTrader(LONG_TRADER, TRADER_DEPOSIT);
        settlementToken.mint(NEW_JUNIOR_LP, 10 * NEW_LP_DEPOSIT);
        vm.prank(NEW_JUNIOR_LP);
        settlementToken.approve(address(juniorVault), type(uint256).max);
        settlementToken.mint(NEW_SENIOR_LP, 10 * NEW_LP_DEPOSIT);
        vm.prank(NEW_SENIOR_LP);
        settlementToken.approve(address(seniorVault), type(uint256).max);

        // A trader opens 19M LONG notional at 1.00 through the production Router FIFO.
        longSize = _sizeFor(LONG_NOTIONAL, P_OPEN);
        _trade(LONG_TRADER, CfdTypes.Side.LONG, longSize, TRADER_MARGIN, false, P_OPEN);
    }

    // ---------------------------------------------------------------------
    // 1. Full production path: assignment at zero NAV redirects the recovery
    // ---------------------------------------------------------------------

    function test_assignIntoWipedJunior_redirectsRecovery() public {
        Snap memory s0 = _snap();
        _logSnap("stage 0: funded pool, 19M LONG open at 1.00", s0);
        uint256 oldHolderShares = juniorVault.balanceOf(JUNIOR_LP);
        console2.log("old Junior holder value before the wipe (USDG)", _whole(_value(JUNIOR_LP)));

        _wipeJunior();
        (uint256 gap, Snap memory s2) = _recapGapThenDrift();
        uint256 u = s2.unassigned;

        // What an honest owner sees: ownerless U > 0, deposits closed, Senior target reverts (test 3).
        assertFalse(pool.canAcceptTrancheDeposits(false), "Junior deposits closed");
        assertFalse(pool.canAcceptTrancheDeposits(true), "Senior deposits closed");

        uint256 snapshotId = vm.snapshotState();

        // ---- ATTACK branch: owner clears U with the only non-reverting target ----
        Outcome memory attack;
        {
            uint256 supplyBefore = juniorVault.totalSupply();
            _keeperMark(P_DRIFT); // assignUnassignedAssets needs a fresh mark (HousePool.sol:670)
            pool.assignUnassignedAssets(false, RECEIVER);
            uint256 assigned = pool.juniorPrincipal();
            assertApproxEqAbs(assigned, u, 1e6, "Junior principal = assigned U (it was 0)");
            assertEq(pool.unassignedAssets(), 0, "U cleared");
            // quoteBootstrapDeposit at pricingAssets = 0: mulDiv(U, supply + 1000, 0 + 1) (TrancheVault.sol:1853-1859)
            assertEq(
                juniorVault.balanceOf(RECEIVER),
                assigned * (supplyBefore + 1000),
                "receiver minted U * (supply + 1000) shares at zero NAV"
            );
            console2.log("=== ATTACK: assignUnassignedAssets(false, RECEIVER) at J = 0 ===");
            console2.log("  assigned U (raw 6-dec)                  ", assigned);
            console2.log("  Junior supply before assignment         ", supplyBefore);
            console2.log("  receiver shares minted                  ", juniorVault.balanceOf(RECEIVER));
            console2.log(
                "  receiver share fraction right after (1e18)",
                (juniorVault.balanceOf(RECEIVER) * 1e18) / juniorVault.totalSupply()
            );
            console2.log("  receiver value right after (raw)        ", _value(RECEIVER));
            console2.log("  old holder value right after (raw)      ", _value(JUNIOR_LP));
            // The assignment is what revives the wiped tranche for ordinary entry (J > 0, U == 0, Senior whole).
            assertTrue(pool.canAcceptTrancheDeposits(false), "assignment reopens Junior deposit requests");
            console2.log("  Junior deposit gate after assignment    ", pool.canAcceptTrancheDeposits(false));
        }

        _settleWithSeniorDust(P_REVERT);
        attack = _outcome();
        _logOutcome("ATTACK: after the mark reverts to 1.00 and LP settlement runs", attack);

        // The receiver can actually take the recovery in cash (Junior withdrawal ratio cap allows ~1.6M now).
        uint256 cashOut = _redeemJuniorWorth(RECEIVER, 1_000_000e6);
        console2.log("  receiver redeemed in USDG through settleLpEpoch (raw)", cashOut);
        assertApproxEqRel(cashOut, 1_000_000e6, 0.01e18, "receiver realizes ~1M USDG of the redirected recovery");

        vm.revertToState(snapshotId);

        // ---- CONTROL branch: identical sequence, no assignment ----
        _settleWithSeniorDust(P_REVERT);
        Outcome memory control = _outcome();
        _logOutcome("CONTROL: no assignment, same reversion", control);

        // ---- Assertions ----
        assertEq(juniorVault.balanceOf(JUNIOR_LP), oldHolderShares, "old holder never moved shares");
        assertGt(attack.receiverFractionWad, 0.999999e18, "receiver holds > 99.9999% of Junior supply");
        assertLt(attack.oldHolderValue, 1e6, "old Junior holder is left with < 1 USDG");
        assertGt(attack.receiverValue, 11_000_000e6, "receiver holds > 11M USDG of Junior value");
        assertGt(control.oldHolderValue, 11_000_000e6, "control: old holder recovers > 11M USDG");
        assertEq(control.receiverShares, 0, "control: no receiver shares");
        assertGt(control.unassigned, 0, "control: U stays ownerless (deposits stay closed until assigned)");

 

The original report as published on Immunefi, by farismaulana. 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 bootstrap assignment path lacks the wiped-tranche check (principal zero with live supply) that every ordinary deposit path enforces, so it prices shares against a zero principal and revives the tranche.

Impact

The wiped Junior holders lose their entire recovery (about 11.2M USDG in the PoC), an unprivileged depositor can capture most of it in cash, and the receiver keeps whatever is left.

What the attacker needed

Owner calls the assignment function; Junior tranche wiped with live supply; unassigned assets present; attacker deposits before recovery

The fix

The assignment should refuse to mint into a tranche whose principal is zero while its supply is live, and refuse a Senior assignment while Senior is below its high-water mark, so ownerless value waits for the waterfall to restore the tranche.

How it was found

  1. A large trader loss is reconciled through the permissionless settlement, wiping Junior principal to zero while its share supply stays live.
  2. The owner recapitalises the Senior gap, and a small favourable price move before the next reconcile leaves unassigned assets.
  3. The owner calls the assignment function targeting Junior, which mints nearly all Junior shares to the receiver and sets Junior principal to the assigned amount.
  4. An unprivileged depositor requests a Junior deposit, which a keeper activates at the new low Junior value.
  5. When the mark recovers, the depositor redeems through the permissionless settlement and takes most of the recovery in cash.

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 pool splits money into a safer Senior part and a riskier Junior part. A big trading loss can use up all the Junior money while its share tokens still exist, and the protocol normally refuses new deposits so the old holders keep their claim on any later recovery. Here a special owner function for leftover cash ignores that rule, hands nearly all the Junior shares to one address for almost nothing, and lets anyone deposit again at a tiny price, so newcomers capture the recovery that belonged to the wiped holders.

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 farismaulana

View all

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