Positive VPI from an open position is counted as distributable Junior NAV, letting an LP-trader redeem above fair value and take principal from other Junior LPs
The pool's reconcile snapshot counts a positive VPI charge collected at open as distributable Junior equity, while the refund the same open position can later reclaim is never booked as a liability. An account that is both a Junior LP and a trader can redeem at an inflated price and then close to recover the charge, taking principal from other Junior holders.
- Disclosed after under an hour
#97770 [SC-Critical] Positive VPI from an open position is counted as distributable Junior NAV, letting an LP-trader redeem above fair value and take principal from other Junior LPs
Submitted on Nov 3rd 2026 at 03:21:31 UTC by @Naveen0x for Audit Competition | Plether
- Report ID: #97770
- Report Type: Smart Contract
- Report severity: Critical
- Target: https://github.com/immunefi-team/audit-comp-plether/blob/a82d4fefb02768e5b3bddcc97dee371eee24fea8/packages/perps/src/HousePool.sol
- Impacts:
- Direct theft of any user funds, whether at-rest or in-motion, other than unclaimed yield
Description
Summary
A trade that increases skew pays a positive VPI charge into the pool. That cash lands in physicalAssets, and buildReconcileSnapshot treats it as distributable Junior equity. The refund that the very same position is entitled to when it closes is never booked as a liability at reconcile. Matured Junior redemptions are then priced off an inflated juniorPrincipal.
Any unprivileged account that is both a Junior LP and a trader can turn this into a transfer of principal. It deposits at fair NAV, requests a redemption, opens a skew-increasing position shortly before the redemption boundary, lets an unrelated keeper settle the epoch while the position is still open, and then closes. The redemption is paid above fair value, and the close hands the VPI charge straight back to the same account. The other Junior holders fund the difference.
The whole thing runs through the ordinary user-facing paths: TrancheVault.requestDeposit / claimDeposit, requestRedeem / claimRedeem, OrderRouter.commitOrder and the permissionless OrderRouter.settleLpEpoch. No privileged role, no governance action, no oracle control, no reentrancy.
In a Foundry run built on the repository's own test fixture, a Junior incumbent that only deposited and redeemed ended 447.957052 USDG below its no-trade control after a single cycle, and below the USDG it deposited in absolute terms. Across eight cycles on a 20M pool the Junior incumbents ended 67463.818349 USDG below control.
Affected asset: HousePool (holds active LP USDG) and the Junior tranche deposit / redemption pricing it drives.
Affected code:
packages/perps/src/libraries/HousePoolAccountingLib.sol—buildReconcileSnapshot, lines 60-78 (primary defect)packages/perps/src/CfdEngineProtocolLens.sol— lines 63-64packages/perps/src/TerminalNavBookV2.sol— lines 320-349packages/perps/src/libraries/CloseAccountingLib.sol— lines 112-118packages/perps/src/libraries/CfdEnginePlanLib.sol— lines 1059-1068packages/perps/src/HousePool.sol— lines 809-819, 835-840, 915, 1147-1152packages/perps/src/OrderRouter.sol—settleLpEpoch, lines 479-484
Commit reviewed: a82d4fefb02768e5b3bddcc97dee371eee24fea8
Root cause
buildReconcileSnapshot (HousePoolAccountingLib.sol:63-74) starts terminalAssets from physicalAssets, adds only a positive terminal price delta, subtracts traderClaimBalanceAssets, and returns distributable = terminalAssets - terminalLiabilities. There is no VPI term on either side of that expression.
The pieces that make that omission exploitable:
CfdEngineProtocolLens.sol:63-64—physicalAssetsis the pool'stotalAssets(), which already contains the VPI charge collected at open. So the charge is inside NAV from the moment it is paid.TerminalNavBookV2.sol:320-349— the terminal LP delta isslope * markPrice + interceptover the radix coefficients. It covers mark-to-market price only, so nothing elsewhere compensates for the missing VPI liability.CloseAccountingLib.sol:116-118— when the position's own skew-reducing close nets a rebate, the lifetime clamp caps the refund at that position's positivevpiAccrued. In other words the amount the position can recover is fixed at open and is known in advance, and reconcile books nothing against it. The clamp's comment at:112-115explains it was added to stop sandwiches that reduce pool depth before closing; this attack needs no depth change at all.HousePool.sol:835runs_reconcile, andHousePool.sol:840then setsjuniorPhase.pricingPrincipal = juniorPrincipal.HousePool.sol:915does the same for Junior deposits settled in that epoch. Both prices are therefore taken after reconcile, while the attacker's position is still open and its refundable charge is still sitting in NAV.OrderRouter.sol:479-484(settleLpEpoch) is permissionless, and with open positionsHousePool.sol:809-819only requires the caller to be the engine's order router and the mark to be fresh. The router call satisfies both, so settlement with an open position is a normal, callable state.CfdEnginePlanLib.sol:1059-1068— when a close nets a rebate, no close charge is assessed, so the close-leg execution fee is never routed to the treasury and stays in the pool. That is a small offset to the attacker's cost, not a defence.
Put simply: the protocol recognises a refundable liability as equity, and the price at which other people buy and sell that equity is taken while the refund is still outstanding.
Attack path
The figures below come from the primary one-cycle arm: a Junior-only pool with a 1000000.000000 USDG incumbent and a 1000000.000000 USDG attacker.
- Deposit at fair NAV. The attacker deposits 1000000.000000 USDG into the Junior
TrancheVaultwhile holding no position, so its shares are minted at an unmanipulated price. - Request redemption. After the deposit cooldown the attacker requests redemption of all of its shares. The request matures at the next epoch boundary (
HousePool.sol:178). At that point the attacker holds 0.4997 of Junior supply. - Open just before the boundary. Shortly before the boundary the attacker commits a LONG and an unrelated keeper executes it. Notional is 799800.000000 USDG, which is the 0.4-of-depth maximum skew on a depth of 2002000.000000 less a small slack. The open pays a VPI charge of c = 1597.522618 USDG into the pool. The 4 bp open fee of 319.920000 goes to the treasury.
- An unrelated keeper settles. Just after the boundary a keeper EOA calls the permissionless
settleLpEpoch. Reconcile counts c as distributable, and the matured redemption is priced from the inflated principal. The redemption uplift over control is 808.355258 USDG, against a first-order prediction of f·c = 798.362747. - Close after settlement. With the redemption already priced, the attacker closes. The lifetime clamp returns the charge, net of the close-leg fee the pool keeps. The attacker's clearinghouse delta over the whole trader leg is only -680.062942, i.e. it gets nearly all of c back.
- Claim. The attacker claims the redemption and receives 1000808.346110 USDG. Net result is +128.283168 against a control of -0.009148.
- Repeat. On a 20M pool run for eight cycles inside roughly 24 hours, every cycle is profitable, from 3847.002142 in the first to 3902.748303 in the eighth, for a cumulative +30998.201365 against a control of -1316.207978.
The victims do nothing unusual. They realise their losses through the ordinary request / settle / claim path.
Impact
All numbers are measured in the PoC below. "Control" means the identical flow from the same snapshot with the attacker performing only the LP round trip and no trade.
Single cycle, 1M incumbent vs 1M attacker (f = 0.4997, c = 1597.522618). The incumbent deposited 1000000.000000 and realised 999552.006388 in the attack arm against 999999.963440 in control. That is 447.957052 lost against control and 447.993612 below its own deposit. The attacker netted +128.283168 against -0.009148 in control, and the treasury took 319.912002. Because the control is whole to 0.036560 USDG, the absolute loss here is entirely attack-caused.
Single cycle, 20M pool, Junior incumbents 5M (f = 0.5999, c = 21996.500315). Incumbents realised 4991069.575367 against 4999479.407008 in control: 8409.831641 lost against control, 8930.424633 below deposits. Attacker +3847.002142 against -164.498867.
Eight cycles inside ~24 hours, 20M pool. Incumbents realised 4930290.352492 against 4997754.170841 in control: 67463.818349 lost against control, 69709.647508 below deposits. Attacker +30998.201365 against -1316.207978, a delta of 32314.409343. Treasury 35161.280946.
Single cycle, 50M pool at the 80% Senior cap, Junior incumbents 10M (f = 0.5999, c = 51993.802347). Incumbents realised 9978729.265177 against 9998611.755752 in control: 19882.490575 lost against control, 21270.734823 below deposits. Attacker +9046.162284 against -438.653465.
At scale the no-trade control is not exactly whole because the Senior coupon accrues in the fixture, so the attack-attributable figure is always the loss against control; the control drift is printed in every arm. Conservation (attacker + treasury + keeper + every victim + seed holders, arm minus control) nets to 0.000000 in each of the arms above, so nothing is created and the attacker's gain is funded by the other holders.
A majority Junior share is not required
With an unrelated trader already long on the same side, a 0.3330 share of Junior supply is enough. Incumbents hold 2000000.000000 USDG of Junior across two EOAs, an honest trader opens a 750000.000000 LONG before the attacker deposits, and the attacker then deposits 1000000.000000 at fair NAV and adds a 450300.000000 LONG before maturity. Total skew is 0.3996 of depth, inside the 0.4 cap. The open charge is c = 1461.967742 and the redemption uplift is 490.678946, about 0.8% above f·c.
Incumbents realise 2000053.648606 against 2000341.715493 in control, so they are 288.066887 worse off than they should be. The attacker nets +107.699532 against -0.006098 in control, and the same open closed before settlement loses 315.846376. The honest trader is not the victim: its PnL is -641.937807 in the attack arm against -642.127379 in control. Most of the remainder of the incumbents' loss is the attacker's open fee, which goes to the treasury (480.107997 against 299.992500 in control).
In this arm the incumbents still end above their deposit in absolute terms, because the honest trader's fees accrue to the pool. The claim here is a loss against control, not an absolute loss. With no other trader in the market, the arithmetic break-even share is about 0.43 (trader-leg cost 680.062942 divided by c = 1597.522618 in the primary arm).
A second class of victim: depositors settling in the same epoch
In a depth-neutral variant, a third party deposits 1500000.000000 USDG in the same epoch and therefore buys shares at the inflated price. That depositor realises 1499057.404267 against 1499999.989028 in control, losing 942.584761. The incumbent actually gains 179.777873 in that arm, but the Junior holders as a group end 762.841631 below what they deposited. So the loss does not always land on incumbents; whoever transacts at the manipulated price pays.
Economics
Attacker gain is roughly f·c minus the open and close execution fees, less price cost. In the primary arm f·c = 798.362747 and each 4 bp leg is 319.920000, leaving 158.522747; the measured net is +128.283168, with the remaining ~30 USDG being price and spread cost. The loss to the other Junior holders is the redemption uplift less the trader payments that stay in the pool: 447.957052 lost against an uplift of 808.355258.
Attacker capital across the measured arms runs from 1013509.000000 to 62637162.000000 USDG minted, the largest figure being cumulative over eight cycles with the stake re-deposited each time.
Why this is a code defect and not a market/economic attack
The profit comes entirely from an omission in buildReconcileSnapshot: no liability is booked for a refund that is already determined at open and capped by CloseAccountingLib.sol:116-118. Book that liability and the transfer disappears. No vote, no privileged role, no market-wide price move and no majority of anything is involved; the attacker obtains its Junior share through ordinary deposits at fair NAV one cooldown before settlement, needs no pre-existing stake, and profits with a 0.3330 share in the measured sub-majority arm.
Relation to the documented design
The design documents describe the NAV definition the code implements, but they do not sanction this transfer. Paraphrasing the relevant passages:
SECURITY.md:859-860states that new LPs should not enter at a higher deposit NAV than the marked-liability discount existing LPs bear. Here they enter at a NAV inflated by a refund that has not yet been paid out.SECURITY.md:863keeps VPI and the other action economics outside the pre-close price book, which is exactly where the code leaves them — the problem is that the collected cash is simultaneously insidephysicalAssets, whichWHITEPAPER.md:411-413confirms is where a positive VPI charge lands.SECURITY.md:866-867andACCOUNTING_SPEC.md:821-822give negative lifetime VPI a dedicated nonwithdrawable reserve that LPs cannot extract before the matching obligation settles. No equivalent protection exists for the positive charge that the same position can recover on close. That asymmetry is the defect.- The "unfunded value is waived rather than claim-backed" language in
SECURITY.md:871-872andWHITEPAPER.md:885-888is a payment-priority rule for when free cash is short. In the measured runs nothing was waived: the close preview showed a VPI delta of -1597.602497, the trader received +1277.649554 (the refund net of the close-leg fee the pool keeps), and pool cash fell by the same amount. ACCOUNTING_SPEC.md:738-740explicitly accepts a timing transfer for pending carry, which cannot be reversed. A positive VPI charge is different: it is refundable up tovpiAccrued, and no equivalent allowance was written for it.- The clamp comment at
CloseAccountingLib.sol:112-115says the clamp exists to stop sandwiches that reduce pool depth. It does that, but it also fixes the recoverable refund at open while reconcile books nothing for it, and this attack needs no depth reduction. - The VPI limitations list at
SECURITY.md:1434-1444does not describe this mechanism.
Relation to the known-issues list
The known-issue list excludes findings from the AI scan report, which contains an entry about a temporary reduction of pool liquidity amplifying a skew-reducing close rebate. That mechanism requires pool depth to fall between open and close. This one does not, and the depth-neutral test demonstrates the difference directly:
- A same-size third-party Junior deposit holds pool depth at close at 10003 bps of depth at open, i.e. flat.
- The unclamped close curve at close depth is 1996.975848 against an open charge of c = 1997.502119, so the refund is already ~c without any depth reduction and the clamp does not need to bind.
- The attacker still nets +362.506407 against a control of -0.010979, with a redemption uplift of 1213.013819 against f·c = 1198.022806.
The profit therefore comes from NAV recognition at reconcile, not from a depth-driven rebate. The LP refund-epoch and redemption-rounding items on the known-issue list are unrelated mechanisms (zero-payout refund epochs and rounding).
Preconditions
- Junior share. At settlement the attacker must hold enough of Junior supply that its redemption uplift exceeds the trader-leg cost. Measured working shares are 0.3330 (with same-side honest flow) and 0.4997 to 0.5999 (with no other trader). Break-even with no other trader is about 0.43.
- Same-side flow, for the sub-majority variant only. The 0.3330 case needs an unrelated trader with a same-side position open at the moment the attacker opens; in the test that is 0.2497 of depth. The attacker does not control that flow.
- Room to open. The open must increase skew and there must be room under
maxSkewRatio(0.4 of depth). - No offsetting trade. No third party may reduce skew between settlement and the attacker's close.
- Live market. The market must be live and not oracle-frozen; live redemptions pay no exit fee (
HousePool.sol:1147-1152). - Free cash covers the rebate. If free pool cash is short the rebate is partly waived (
CfdEnginePlanLib.sol:973-976). This was never hit in the measured runs. - Price risk. The attacker's net turns negative at an adverse close move of 3.97 bp with zero oracle confidence, or 3.62 bp with 1 bp confidence (f = 0.5997, notional 999800.000000).
Limitations, disclosed honestly
- Ordering risk. If a third party sells short half the attacker's size between settlement and the close, the attacker nets -1610.310353 where the uninterrupted arm nets +347.436539. The conservation check does not close in that interposed arm (residual 420.866850, which I have not explained), so no claim above depends on it.
- Share threshold. The sub-majority result uses one honest LONG of a fixed size; real same-side flow is not modelled. The 0.43 no-other-trader break-even is arithmetic from the primary arm, not a measured sweep.
- Price path. All measured arms use a flat basket price; path risk over the holding window is not tested.
- Basket. The test uses a two-feed flat-price basket rather than the six-feed production basket. VPI depends on skew and depth rather than basket composition, but that is not measured here.
- Environment. The test runs against local Foundry state, not against any deployed build.
- Not covered. Frozen-market and FAD windows, organic order flow, sustained multi-cycle extraction at the 80% Senior cap (one cycle only at 50M), and gas costs.
Recommended fix
Track live VPI and keep its positive part out of distributable equity until the matching position actually settles.
Concretely: keep a signed running total of live vpiAccrued across accounts in TerminalNavBookV2, updated on each per-account curve sync (previous value out, new value in, zero when the account goes flat). Then in CfdEngineProtocolLens.getHousePoolInputSnapshot, while positions are open, subtract the positive part of that total from terminalLpPriceDeltaAssets. Net positive live VPI then stays outside distributable Junior equity until the position closes or is liquidated, while net negative live VPI stays unrecognised exactly as the documents describe.
Trade-offs worth flagging:
- VPI remains LP revenue. Only the moment of recognition moves, from open to close/liquidation.
- Any replacement of
TerminalNavBookV2while positions are open must seed the running total from the live positions, or the fix silently starts from zero. - I built a prototype of this in a separate copy of the tests: the attack arms then fail their attack-premise assertions, while the no-trade control and the fee-routing check still pass. I have not run the sub-majority variant or the full regression suite against the prototype, and a small residual uplift remains that I have not fully explained, so please treat the prototype as a direction rather than a finished patch.
A cheaper alternative, if touching the terminal book is undesirable, is to refuse to price matured Junior deposits and redemptions off a principal that includes unsettled refundable VPI — for example by deferring epoch settlement pricing for accounts with open positive-VPI positions, or by holding an explicit nonwithdrawable reserve for positive live vpiAccrued mirroring the one that already exists for negative lifetime VPI.
Sketch (illustrative, not compiled):
--- a/packages/perps/src/TerminalNavBookV2.sol
+++ b/packages/perps/src/TerminalNavBookV2.sol
+ mapping(address account => int256 liveVpiAccruedAssets) private _liveVpiAccruedAssets;
+ int256 public totalLiveVpiAccruedAssets;
...
// inside the per-account curve sync, after the position is read:
+ _syncLiveVpi(account); // moves prev -> next in totalLiveVpiAccruedAssets; next = 0 when flat
--- a/packages/perps/src/CfdEngineProtocolLens.sol
+++ b/packages/perps/src/CfdEngineProtocolLens.sol
snapshot.terminalLpPriceDeltaAssets = terminalSnapshot.terminalLpPriceDeltaAssets;
+ if (terminalSnapshot.hasOpenPositions) {
+ int256 liveVpi = terminalNavBook.totalLiveVpiAccruedAssets();
+ if (liveVpi > 0) snapshot.terminalLpPriceDeltaAssets -= liveVpi;
+ }
Proof of Concept
The attachment option is not available on this form, so the complete Foundry test file is inlined below. Save it as VpiNavJuniorExtractionPoC.t.sol inside the perps package's test directory (any subdirectory works; the file imports test/perps/BasePerpTest.sol, which pulls in test/utils/LegacyOrderRouterHarness.sol, and MockPyth through the existing @plether/test-utils remapping). No changes to src are required.
Run it from the perps package:
FOUNDRY_FFI=false FOUNDRY_DYNAMIC_TEST_LINKING=true forge test --match-path '**/VpiNavJuniorExtractionPoC.t.sol' -vv
All 11 tests pass, with identical logged values on current Forge releases, using solc 0.8.35 with via-IR and 200 optimizer runs as configured in the repository.
Tests included: test_Attack_UnprivilegedIncumbent_AbsoluteLoss, test_Control_NoTrade, test_NegControl_SameTradesClosedBeforeSettlement, test_SubMajorityShare_WithHonestSkew_Profitable, test_DepthNeutral_DepositorOverpays, test_PriceSensitivity, test_OrderingRisk_Disclosed, test_Scale_D20M_S75_f060_RealizedClaims, test_Scale_D20M_S75_f060_EightCyclesPerDay_RealizedClaims, test_Scale_D50M_S80cap_f060_RealizedClaims, test_CloseFeeRouting.
A few notes on how the PoC is set up, so nothing looks like it was smuggled in:
- Every actor is an unprivileged EOA created with
makeAddr. The keeper is unrelated to the attacker and executes orders and callssettleLpEpoch. Victims only ever userequestDeposit/claimDepositandrequestRedeem/claimRedeem. - The only owner calls are in
setUp, and they only apply release configuration through the documented timelocks: 4 bp execution fee, 25 bp settlement buffer, 2500 adverse confidence multiplier, 1000e6 minimum open notional, 40M Senior exposure cap and an 8000 bp Senior share. No owner, guardian, pauser or oracle-worker action happens during the attack itself. - Orders go through
LegacyOrderRouterHarness, a test-only subclass of the productionOrderRouterthat builds a production V3OrderRequestwith every caller bound at its maximum and delegatecalls the production commit path. Any EOA can submit the same request. - Cheatcodes used are limited to
vm.prank,vm.startPrank,vm.warp,vm.roll,vm.snapshotState,vm.revertToState,vm.toStringandmakeAddr. There is novm.store,vm.etch,vm.mockCall,deal,vm.loadorvm.setNonce; funding goes throughMockSettlementToken.mintor the repository's own_fundTraderhelper. - Every attack arm is run from the same snapshot as its control, so the two differ only in whether the attacker trades and when it closes.
Console output (trimmed of gas and timing lines)
[MAIN attack] f (attacker share of Junior supply) = 0.4997
[MAIN attack] c (open VPI charge) USDG = 1597.522618 ; notional USDG = 799800.000000
[MAIN attack] attacker NET PnL USDG = 128.283168 ; stuck shares valued = 0.000000
[MAIN attack] trader leg PnL (first cycle, clearinghouse delta) USDG = -680.062942
[MAIN_f050] f = 0.4997 ; c USDG = 1597.522618 ; f*c USDG = 798.362747
[MAIN_f050] LOSS VS CONTROL USDG = 447.957052
[MAIN_f050] attacker NET (attack) USDG = 128.283168 ; attacker NET (control) USDG = -0.009148
[MAIN_f050] redemption uplift vs control USDG = 808.355258
[MAIN_f050] conservation residual (should be ~0) USDG = 0.000000
[SUBMAJ] f = 0.3330 ; honest skew ratio = 0.2497 ; c USDG = 1461.967742
[SUBMAJ] honest LONG notional USDG = 750000.000000 ; attacker LONG notional USDG = 450300.000000
[SUBMAJ] total skew / depth at open = 0.3996 (cap 0.4000)
[SUBMAJ] ATTACKER NET USDG = 107.699532 ; control = -0.006098 ; neg-control = -315.846376
[SUBMAJ] INCUMBENT LOSS VS CONTROL USDG = 288.066887 ; attack = 2000053.648606 vs control = 2000341.715493
[SUBMAJ] honest trader PnL control = -642.127379 ; attack = -641.937807 (the honest trader is not the victim)
[DAY20M] cycle 0 : f = 0.5999 ; c USDG = 21996.500315 ; attacker cycle PnL USDG = 3847.002142
[SCALE_D20M_S75_f060_8cycles] LOSS VS CONTROL USDG = 67463.818349
[SCALE_D20M_S75_f060_8cycles] attacker net delta vs control USDG = 32314.409343
Suite result: ok. 11 passed; 0 failed; 0 skipped
Negative controls contained in the same file
- No trade at all: the incumbent ends whole at 999999.963440 and the attacker at -0.009148.
- The same open and close, completed before settlement: the attacker loses 500.727765 and the incumbent ends 180.426467 above control.
- Same shape in the sub-majority variant: closed before settlement, the attacker nets -315.846376.
The only difference between the profitable arm and the losing arm is whether the position is still open when the epoch settles. That is the whole bug.
Proof of Concept
Proof of Concept (Full test file)
// SPDX-License-Identifier: AGPL-3.0
pragma solidity 0.8.35;
// =====================================================================================================================
// Proof of concept for the Plether perps LP accounting at commit a82d4fefb02768e5b3bddcc97dee371eee24fea8.
//
// Claim: positive VPI that a skew-increasing open pays into the pool is held as pool cash and is counted as distributable
// Junior NAV at settlement. No liability is booked for the refund that a same-skew close pays back to the same position.
// A Junior LP that holds matured shares, opens before its redemption settles, and closes after settlement redeems at a
// price above fair value. The excess is funded by the other Junior holders.
//
// Code anchors (packages/perps/src at the commit above):
// libraries/HousePoolAccountingLib.sol:60-78 buildReconcileSnapshot: no liability term for collected positive VPI
// HousePool.sol:835-840 _settleLpEpoch: _reconcile, then juniorPhase.pricingPrincipal = juniorPrincipal
// libraries/CloseAccountingLib.sol:112-117 lifetime clamp: a same-skew close refunds up to the positive vpiAccrued
// libraries/CfdEnginePlanLib.sol:1059-1068 net-rebate close: no close fee is assessed, so the fee stays in the pool
//
// Actors: all unprivileged EOAs created with makeAddr. The keeper is an unrelated EOA that executes orders and calls the
// permissionless Router.settleLpEpoch. The attacker is a Junior LP that also trades. Victims realize only through
// TrancheVault requestDeposit/claimDeposit and requestRedeem/claimRedeem.
//
// Orders are submitted through LegacyOrderRouterHarness (test/utils), a test-only subclass of the production OrderRouter
// that builds a production V3 OrderRequest with every caller bound at its maximum and delegatecalls the production V3
// commit path. Any EOA can submit the same request.
//
// Setup (owner calls, setUp only): the release configuration is applied through the documented timelocks. This is
// configuration, not an attack step: executionFeeBps 4, settlementBufferBps 25, adverseConfidenceMultiplierBps 2500,
// basketMaxConfidenceRatioBps 10, minOpenNotionalAssets 1000e6, Senior exposure cap 40,000,000e6 and Senior share 8000 bps.
//
// Cheatcodes: vm.prank, vm.startPrank, vm.warp, vm.roll, vm.snapshotState, vm.revertToState, vm.toString, makeAddr.
// No vm.store, vm.etch, vm.mockCall, deal, vm.load or vm.setNonce. EOA funding uses MockSettlementToken.mint or the repo
// helper _fundTrader. Pyth is the repo MockPyth with a flat basket price and 1 bp per-feed confidence unless a test says
// otherwise.
// =====================================================================================================================
import {BasePerpTest} from "../perps/BasePerpTest.sol";
import {CfdTypes} from "@plether/perps/CfdTypes.sol";
import {TrancheVault} from "@plether/perps/TrancheVault.sol";
import {ICfdEngineAdminHost} from "@plether/perps/interfaces/ICfdEngineAdminHost.sol";
import {ICfdEngineTypes} from "@plether/perps/interfaces/ICfdEngineTypes.sol";
import {IOrderRouterAdminHost} from "@plether/perps/interfaces/IOrderRouterAdminHost.sol";
import {MockPyth} from "@plether/test-utils/MockPyth.sol";
import {console2} from "forge-std/console2.sol";
contract VpiNavJuniorExtractionPoC is BasePerpTest {
uint256 internal constant VPI_FACTOR = 0.01e18;
uint256 internal constant LOT = 100e18; // positionSizeQuantum
uint256 internal constant P0 = 1e8;
address internal keeper;
address internal attacker;
address internal incumbentA;
address internal incumbentB;
address internal seniorLp;
address internal thirdDepositor;
address internal honestTrader;
uint256 internal price = P0;
uint64 internal confE8 = 1e4; // per-feed Pyth confidence, 1e4 = 1 bp at price 1.0
enum Mode {
NoTrade, // LP round trip only (control)
Attack, // open before the redemption boundary, unrelated keeper settles, close
CloseBeforeSettle // identical open, closed BEFORE the settlement (negative control)
}
struct Scn {
uint256[2] incDep;
uint256[2] incShares;
uint256 seniorDep;
uint256 seniorShares;
}
struct Cfg {
Mode mode;
uint256 cycles;
uint256 attackerDeposit;
uint256 thirdDeposit; // third-party Junior deposit maturing with the attacker's redemption (single cycle)
uint256 honestShortDiv; // 0 none; n => honest SHORT of size/n between settlement and the attacker's close
uint256 closePrice; // 0 = flat; otherwise the feed price used for the attacker's close onl
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 reconcile snapshot starts from physical assets that already include the collected VPI charge and subtracts no liability for the refund the open position is entitled to on close, so refundable cash is treated as distributable equity.
Impact
Other Junior holders can lose principal, measured at 447.957052 USDG below control in one cycle and 67463.818349 USDG below control over eight cycles, though the attacker's profit turns negative on a small adverse price move and can be disrupted by an offsetting trade.
What the attacker needed
A Junior LP position; enough Junior share (about 0.43 without other flow); room under the 0.4 skew cap; no offsetting trade before close
The fix
Track live positive vpiAccrued across accounts and subtract it from the terminal LP price delta while positions are open, so the charge is only recognised as equity at close or liquidation.
How it was found
- Deposit into the Junior tranche at fair NAV while holding no position.
- After the cooldown, request redemption of all shares so it matures at the next epoch boundary.
- Shortly before the boundary, open a skew-increasing position that pays a positive VPI charge into the pool.
- Have an unrelated keeper call the permissionless settleLpEpoch just after the boundary, pricing the redemption off the inflated principal.
- Close the position after settlement so the clamp refunds the charge.
- Claim the redemption, which pays above fair value.
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 lets people put money in (liquidity providers) and also lets people place trades against it. When a trade opens, it pays a fee into the pool, and the pool can later give part of that fee back when the trade closes. The bug is that the pool counts that fee as money it owns outright, so it prices shares too high, and someone who is both an investor and a trader can cash out at the inflated price and then get the fee refunded, leaving other investors short.
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.