Refundable positive VPI is counted as Junior equity at LP epoch settlement, letting a Junior LP who also trades redeem above fair value
A positive VPI charge paid into the pool when a skew-increasing position opens is counted as distributable Junior LP equity at epoch settlement, even though the same position can reclaim that charge on close. An account that is both a Junior LP and a trader can therefore redeem its shares at an inflated price and recover most of the charge, leaving other Junior holders worse off.
- Disclosed after under an hour
#99337 [SC-Critical] Refundable positive VPI is counted as Junior equity at LP epoch settlement, letting a Junior LP who also trades redeem above fair value
Submitted on Nov 13th 2026 at 08:21:32 UTC by @tomX0 for Audit Competition | Plether
- Report ID: #99337
- 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 becomes part of HousePool.totalAssets(), and buildReconcileSnapshot counts it as distributable LP equity. But the same position gets the charge back when it later closes and brings skew back down, and the lifetime clamp in CloseAccountingLib caps that refund at exactly the position's positive vpiAccrued. Reconcile never books the refund as a liability.
LP epoch settlement prices matured Junior redemptions and deposits straight after reconcile, from juniorPrincipal. So if a skew-increasing position is open when the epoch settles, its refundable charge is baked into the Junior share price.
An account that is both a Junior LP and a trader can use this:
- Deposit into the Junior vault at fair NAV.
- Request redemption of those shares.
- Open a skew-increasing position just before the redemption matures.
- Let anyone, for example an unrelated keeper, call the permissionless
OrderRouter.settleLpEpoch. - Close the position after settlement and get the charge back.
- Claim the redemption, which was priced above fair value.
The attacker collects its share of the charge through the redemption and nearly all of the charge again through the close. The other Junior holders pay for both.
Everything goes through public entrypoints: TrancheVault.requestDeposit / claimDeposit, requestRedeem / claimRedeem, OrderRouter.commitOrder and OrderRouter.settleLpEpoch. No privileged role, governance action, oracle control or reentrancy is involved.
In a Foundry test built on the repository's own fixture, a Junior incumbent that only deposited and redeemed finished 447.957052 USDG below its no-trade control after a single cycle, which also puts it below its own deposit. On a 20M pool over eight cycles in about 24 hours, the Junior incumbents lost 67,463.818349 USDG against control.
Target
- Asset:
HousePool.sol(holds active LP USDG), together with the JuniorTrancheVaultdeposit and redemption pricing it drives - Commit:
a82d4fefb02768e5b3bddcc97dee371eee24fea8 - Affected code:
packages/perps/src/libraries/HousePoolAccountingLib.sol:buildReconcileSnapshot, lines 60-78 (main defect)packages/perps/src/CfdEngineProtocolLens.sol:getHousePoolInputSnapshot, lines 63-64packages/perps/src/TerminalNavBookV2.sol:_terminalLpPriceDeltaAssetAtoms, lines 320-349packages/perps/src/libraries/CloseAccountingLib.sol: lifetime VPI clamp, lines 112-118packages/perps/src/libraries/CfdEnginePlanLib.sol: net-rebate close, lines 1059-1068packages/perps/src/HousePool.sol:settleLpEpoch/_settleLpEpoch, lines 809-819, 835-840, 915 and 1147-1152packages/perps/src/OrderRouter.sol:settleLpEpoch, lines 479-484
Vulnerability details
1. Reconcile has no VPI term
// HousePoolAccountingLib.sol:60-78
function buildReconcileSnapshot(
HousePoolEngineViewTypes.HousePoolInputSnapshot memory engineSnapshot
) internal pure returns (ReconcileSnapshot memory snapshot) {
uint256 terminalAssets = engineSnapshot.physicalAssets;
uint256 terminalLiabilities = engineSnapshot.traderClaimBalanceAssets;
int256 terminalDelta = engineSnapshot.terminalLpPriceDeltaAssets;
if (terminalDelta >= 0) {
terminalAssets += uint256(terminalDelta);
} else {
terminalLiabilities += uint256(-(terminalDelta + 1)) + 1;
}
if (terminalAssets >= terminalLiabilities) {
snapshot.distributable = terminalAssets - terminalLiabilities;
} else {
snapshot.deficit = terminalLiabilities - terminalAssets;
}
}
Where the inputs come from:
physicalAssetsis the pool'stotalAssets()(CfdEngineProtocolLens.sol:63-64). The VPI charge collected at open is already in it.WHITEPAPER.md:411-413says the same thing: positive VPI increases physical pool assets.terminalLpPriceDeltaAssetscomes fromTerminalNavBookV2(:320-349), which computesslope * markPrice + interceptover the radix coefficients. It only covers mark-to-market price PnL.traderClaimBalanceAssetsonly covers trader claims that are already owed.
Nothing on either side accounts for the VPI refund the open position is still entitled to.
2. The refund is fixed at open and paid on close
// CloseAccountingLib.sol:112-118
// Clamp so lifetime VPI (accrued + delta) never goes negative. Prevents LP sandwich attacks
// where an attacker opens at high depth, reduces pool depth, then closes to extract a
// net-negative lifetime VPI rebate. ...
if (state.proportionalAccrualAssets + state.vpiDeltaAssets < 0) {
state.vpiDeltaAssets = -state.proportionalAccrualAssets;
}
When the position closes and returns skew to where it was, the VPI curve produces a rebate about the size of the open charge, and the clamp caps it at the position's vpiAccrued. So the amount the position will get back is known the moment it opens.
When a close nets a rebate, no close charge is assessed (CfdEnginePlanLib.sol:1059-1068), so the close-leg execution fee is not sent to the treasury. It stays in the pool and is netted against the rebate. That trims the attacker's profit a little but doesn't stop anything.
In the PoC, the close preview showed a VPI delta of -1,597.602497 against an open charge of 1,597.522618. The trader received +1,277.649554 (the refund minus the 4 bp close fee the pool keeps), and pool cash dropped by the same amount. Nothing was waived.
3. Settlement prices LP flows after reconcile, while the position is still open
// HousePool.sol:835-840
_reconcile(accountingSnapshot, statusSnapshot);
_checkpointEngineCarryIndexes();
result.cutoffEpoch = cutoffEpoch;
RedemptionPhase memory juniorPhase;
juniorPhase.pricingPrincipal = juniorPrincipal;
Junior deposits settled in the same call are priced the same way (HousePool.sol:915, juniorDepositPhase.pricingAssets = juniorPrincipal). Live redemptions pay no exit fee, because _settlementFeeBps returns 0 when the oracle isn't frozen (HousePool.sol:1147-1152).
4. Settling with an open position is a normal public path
With positions open, HousePool.settleLpEpoch only checks that the caller is the engine's order router and that the mark is the fresh one it just set (HousePool.sol:809-819). OrderRouter.settleLpEpoch (:479-484) is permissionless and satisfies both. A keeper settling the epoch while the attacker's position is open is ordinary operation.
Put simply: the protocol treats a refundable liability as Junior equity, and the price at which other people enter and leave the Junior tranche is taken while that refund is still outstanding.
Attack path
The numbers below come from the main one-cycle test: a Junior-only pool with a 1,000,000 USDG incumbent and a 1,000,000 USDG attacker.
- Deposit at fair NAV. The attacker deposits 1,000,000 USDG into the Junior vault while it holds no position, so its shares are minted at an honest price.
- Request redemption. After the deposit cooldown the attacker requests redemption of all its shares. The request matures at the next hourly epoch boundary. At that point the attacker holds 0.4997 of Junior supply.
- Open just before the boundary. About 60 seconds before the boundary, the attacker commits a LONG and an unrelated keeper executes it. Notional is 799,800 USDG, the 0.4 max-skew limit on 2,002,000 USDG of depth minus 1,000 USDG of slack. The open pays a VPI charge of c = 1,597.522618 USDG into the pool. The 4 bp open fee of 319.92 USDG goes to the treasury.
- An unrelated keeper settles. Just after the boundary, a keeper calls
OrderRouter.settleLpEpoch. Reconcile counts c as distributable, and the matured redemption is priced from the inflatedjuniorPrincipal. The redemption comes out 808.355258 USDG above control, against a first-order estimate of f·c = 798.362747. - Close after settlement. With the redemption already priced, the attacker closes. The clamp returns the charge minus the close fee the pool keeps. Over the whole trade the attacker's clearinghouse balance moved by only -680.062942 USDG, so it got most of c back.
- Claim. The attacker claims 1,000,808.346110 USDG. Net result: +128.283168 USDG, against -0.009148 in the no-trade control.
- Repeat. One cycle takes about three hours, so it can be run about eight times a day.
The victims don't do anything unusual. They take the loss through the normal request, settle and claim path.
Impact
"Control" below means the identical flow from the same snapshot, where the attacker only does the LP round trip and doesn't trade. A conservation check (attacker + treasury + keeper + every victim + seed holders, attack minus control) comes out at 0.000000 in each of the runs below. No value is created; the attacker's gain is paid for by the other holders.
- One cycle, 1M incumbent vs 1M attacker (f = 0.4997, c = 1,597.522618). The incumbent deposited 1,000,000 and got back 999,552.006388, against 999,999.963440 in control. That is 447.957052 USDG below control and 447.993612 below its own deposit. Because the control leaves the incumbent whole to within 0.04 USDG, the absolute loss is caused entirely by the attack. The attacker netted +128.283168 (control -0.009148) and the treasury took 319.912002.
- One cycle, 20M pool with 5M of Junior incumbents (f = 0.5999, c = 21,996.500315). Incumbents got back 4,991,069.575367 against 4,999,479.407008 in control: 8,409.831641 below control and 8,930.424633 below their deposits. The attacker netted +3,847.002142 (control -164.498867).
- Eight cycles in about 24 hours, same 20M pool. Every cycle was profitable, from 3,847.002142 in the first to 3,902.748303 in the eighth. Incumbents got back 4,930,290.352492 against 4,997,754.170841 in control: 67,463.818349 below control and 69,709.647508 below their deposits. The attacker's cumulative net was +30,998.201365 against -1,316.207978 in control, a difference of 32,314.409343. The treasury took 35,161.280946.
- One cycle, 50M pool at the 80% Senior cap with 10M of Junior incumbents (f = 0.5999, c = 51,993.802347). Incumbents got back 9,978,729.265177 against 9,998,611.755752 in control: 19,882.490575 below control and 21,270.734823 below their deposits. The attacker netted +9,046.162284 (control -438.653465).
In the larger pools the no-trade control isn't exactly whole because the Senior coupon accrues in the fixture. That's why the loss caused by the attack is always measured against control. The control drift is printed in every run.
A majority Junior share is not needed
If an unrelated trader is already positioned on the same side, a third of Junior supply is enough. In this test the incumbents hold 2,000,000 USDG of Junior across two accounts, and an honest trader opens a 750,000 USDG LONG before the attacker deposits. The attacker then deposits 1,000,000 USDG at fair NAV (f = 0.3330) and adds a 450,300 USDG LONG before maturity. Total skew is 0.3996 of depth, inside the 0.4 cap. The open charge is c = 1,461.967742 and the redemption uplift is 490.678946.
- Incumbents got back 2,000,053.648606 against 2,000,341.715493 in control, so they are 288.066887 USDG worse off.
- The attacker netted +107.699532 (control -0.006098). The same open, closed before settlement, loses 315.846376.
- The honest trader is not the victim. Its PnL was -641.937807 in the attack run and -642.127379 in control.
In this run the incumbents still finish above their deposit in absolute terms, because the honest trader's fees go to the pool, so the claim here is a loss against control rather than an absolute loss. With no other trader in the market, the break-even share is about 0.43 (trader-leg cost of 680.062942 divided by c = 1,597.522618).
Depositors in the same epoch are also victims
In a depth-neutral run, a third party deposits 1,500,000 USDG into the Junior vault in the same epoch and so buys shares at the inflated price. That depositor gets back 1,499,057.404267 against 1,499,999.989028 in control, a loss of 942.584761. In this run the incumbent actually comes out 179.777873 ahead, but the Junior holders as a group end 762.841631 below what they deposited. The loss lands on whoever transacts at the manipulated price.
Economics
The attacker's gain is roughly f·c minus the open and close execution fees, minus price and spread cost. In the main run f·c = 798.362747 and each 4 bp leg is 319.92, which leaves 158.522747. The measured net is +128.283168; the remaining ~30 USDG is price and spread cost. The loss to the other Junior holders is the redemption uplift minus the trader payments that stay in the pool: 447.957052 lost against an uplift of 808.355258.
Attacker capital across the runs ranges from 1,013,509 USDG to 62,637,162 USDG. The largest figure is cumulative over eight cycles, with the same stake re-deposited each time.
Why this is a code defect and not an economic or majority attack
All of the profit comes from one omission: reconcile books no liability for a refund that is already fixed at open and capped by CloseAccountingLib.sol:116-118. Book that liability and the transfer disappears.
- No vote, privileged role, market-wide price move or majority stake is involved.
- The attacker gets its Junior share by depositing at fair NAV one cooldown before settlement. It needs no pre-existing stake and is profitable with a 0.3330 share in the sub-majority test.
- The negative control shows the same open and close, finished before settlement, costs the attacker 500.727765 USDG and leaves the incumbent 180.426467 USDG above control. The only difference between the losing run and the profitable run is whether the position is still open when the epoch settles.
Why this is not a known issue or intended behaviour
It is not the known depth-manipulation issue. The AI scan report contains "Temporary pool-liquidity reduction can amplify a skew-reducing close rebate". That mechanism needs pool depth to fall between open and close. This one doesn't, and the depth-neutral test shows it directly:
- A same-size third-party Junior deposit keeps pool depth at close at 10,003 bps of depth at open, i.e. flat.
- The unclamped close curve at close depth is 1,996.975848 against an open charge of c = 1,997.502119, so the refund is already about c and the clamp doesn't need to bind.
- The attacker still nets +362.506407 (control -0.010979), with a redemption uplift of 1,213.013819 against f·c = 1,198.022806.
So the profit comes from how NAV is recognised at reconcile, not from a depth-driven rebate. The listed LP refund-epoch and redemption-rounding findings are unrelated mechanisms (zero-payout refund epochs and rounding). I went through the Cecuro AI audit, the SC Audit Studio pre-audit, the AI scan findings, the collaborative audit and the Cantina report, and none of them covers VPI in LP pricing. I also found no issue, PR or commit in the upstream Plether-Fi/plether-core repository that addresses it.
The documentation doesn't allow this transfer. The docs describe the NAV definition the code implements, but they don't sanction what happens here:
packages/perps/SECURITY.md:859-860says 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 hasn't been paid out yet.SECURITY.md:863keeps VPI outside the pre-close price book, which is where the code leaves it. The problem is that the collected cash is at the same time insidephysicalAssets.SECURITY.md:866-867andACCOUNTING_SPEC.md:821-822give negative lifetime VPI a dedicated nonwithdrawable reserve that LPs can't extract before the matching obligation settles. There is no equivalent protection for the positive charge that the same position can recover on close. That asymmetry is the bug.- The "unfunded value is waived rather than claim-backed" rule in
SECURITY.md:871-872andWHITEPAPER.md:885-888is a payment-priority rule for when free cash is short. Nothing was waived in any measured run. ACCOUNTING_SPEC.md:738-740explicitly accepts a timing transfer for pending carry, which can't be reversed. Positive VPI is different: it is refundable up tovpiAccrued, and no such allowance is written for it.SECURITY.md:1443says the lifetime clamp "intentionally zeroes otherwise extractable rebate-only round trips", so the protocol clearly intends VPI round trips not to extract LP value. The VPI limitations list (SECURITY.md:1434-1444) does not describe this mechanism.
Preconditions
- Junior share. At settlement the attacker must hold enough Junior supply that its redemption uplift beats the trading 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, sub-majority case only. The 0.3330 case needs an unrelated same-side position open when the attacker opens (0.2497 of depth in the test). The attacker doesn't control that flow.
- Room to open. The open must increase skew and fit under
maxSkewRatio(0.4 of depth). - No offsetting trade. Nobody 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.
- Free cash covers the rebate. If free pool cash is short, the rebate is partly waived (
CfdEnginePlanLib.sol:973-976). This never happened in the tests. - Price risk. With f = 0.5997 and 999,800 USDG of notional, 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. The position is only open for a few minutes.
Limitations of the testing
- Ordering risk. If a third party sells short half the attacker's size between settlement and the close, the attacker nets -1,610.310353 instead of +347.436539. This run is included only to show that risk. Its conservation check doesn't balance cleanly, so nothing in this report relies on its numbers.
- Share threshold. The sub-majority result uses one honest LONG of fixed size, and real order flow isn't modelled. The 0.43 break-even is arithmetic from the main run, not a measured sweep.
- Price path and basket. All runs use a flat basket price and the repository's two-feed test basket rather than the six-feed production basket. VPI depends on skew and depth, not on basket composition, but that isn't measured here.
- Environment. Tests run against local Foundry state, not a deployed build. Frozen-market and FAD windows, organic order flow, multi-cycle extraction at the 80% Senior cap (only one cycle was run at 50M) and gas costs are not covered.
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 (old value out, new value in, zero when the account goes flat). Then, in CfdEngineProtocolLens.getHousePoolInputSnapshot, subtract the positive part of that total from terminalLpPriceDeltaAssets while positions are open. Net positive live VPI then stays out of Junior equity until the position closes or is liquidated, while net negative live VPI stays unrecognised, as the docs already describe.
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;
+ }
Things to keep in mind:
- VPI stays LP revenue. Only the point at which it is recognised moves, from open to close or liquidation.
- If
TerminalNavBookV2is ever replaced while positions are open, the running total has to be seeded 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 runs then fail their attack-premise assertions, while the no-trade control and the fee-routing check still pass. I haven't run the sub-majority variant or the full regression suite against it, and a small residual uplift remains, so please treat it as a direction rather than a finished patch.
If you'd rather not touch the terminal book, a cheaper option is to stop pricing matured Junior deposits and redemptions off a principal that includes unsettled refundable VPI. For example, hold an explicit nonwithdrawable reserve for positive live vpiAccrued, mirroring the one that already exists for negative lifetime VPI, or defer epoch pricing while positions with positive live VPI are open.
Proof of concept
The PoC is one self-contained Foundry test file built on the repository's BasePerpTest. No change to src is needed.
How it is set up, so nothing looks smuggled in:
- Every actor is an unprivileged EOA created with
makeAddr. The keeper is unrelated to the attacker; it executes orders and callssettleLpEpoch. Victims only ever userequestDeposit/claimDepositandrequestRedeem/claimRedeem. - The only owner calls are in
setUp, and they only apply the 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 8000 bp Senior share. No owner, guardian, pauser or oracle-worker action happens during the attack. - Orders go through
LegacyOrderRouterHarness, the repository's test-only subclass of the productionOrderRouter. It builds a production V3OrderRequestwith every caller bound at its maximum and delegatecalls the production commit path. Any EOA can submit the same request directly. - Cheatcodes 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 run starts from the same snapshot as its control, so the two differ only in whether the attacker trades and when it closes.
Running it
From the repository root at commit a82d4fefb02768e5b3bddcc97dee371eee24fea8:
git submodule update --init --recursive
cd packages/perps
mkdir -p test/poc
# save the file below as test/poc/VpiNavJuniorExtractionPoC.t.sol
FOUNDRY_FFI=false FOUNDRY_DYNAMIC_TEST_LINKING=true forge test --match-path '**/VpiNavJuniorExtractionPoC.t.sol' -vv
All 11 tests pass with solc 0.8.35, via-IR and 200 optimizer runs, as configured in the repository.
What each test checks
test_Attack_UnprivilegedIncumbent_AbsoluteLoss: the main exploit (1M vs 1M). The incumbent ends below its own deposit and below control, and the redemption uplift matches f·c.test_Control_NoTrade: the same LP flows with no trade. The incumbent stays whole and the attacker doesn't profit.test_NegControl_SameTradesClosedBeforeSettlement: the same open and close, finished before settlement. The attacker loses money and the incumbent isn't harmed.test_SubMajorityShare_WithHonestSkew_Profitable: the attack with a 0.3330 share and honest same-side flow.test_DepthNeutral_DepositorOverpays: depth held flat by a concurrent deposit. The attack still works and the concurrent depositor overpays.test_PriceSensitivity: the break-even adverse close move, with and without oracle confidence.test_OrderingRisk_Disclosed: a third party reduces skew before the attacker's close, and the attacker loses.test_Scale_D20M_S75_f060_RealizedClaims,test_Scale_D20M_S75_f060_EightCyclesPerDay_RealizedClaimsandtest_Scale_D50M_S80cap_f060_RealizedClaims: the 20M one-cycle, 20M eight-cycle and 50M runs, with victims realising through real claims.test_CloseFeeRouting: the close-leg execution fee stays in the pool when the close nets a rebate.
Proof of Concept
VpiNavJuniorExtractionPoC.t.sol
// 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)
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 counts the collected VPI charge in physical assets as distributable equity without booking the refundable liability the open position is still entitled to.
Impact
Other Junior holders and same-epoch depositors could lose value to the attacker's redemption uplift, with measured losses of hundreds to tens of thousands of USDG per cycle depending on pool size, though the attacker's profit depends on holding a sufficient Junior share and on price risk during the short open window.
What the attacker needed
Junior LP share above break-even (~0.43); Position open at epoch settlement; Room to open under maxSkewRatio; No offsetting trade before close
The fix
Track live positive VPI and keep it out of distributable Junior equity until the matching position closes or is liquidated, for example by subtracting the positive running total of live vpiAccrued from terminalLpPriceDeltaAssets while positions are open.
How it was found
- Deposit into the Junior vault at fair NAV while holding no position.
- Request redemption of all shares after the deposit cooldown, maturing at the next epoch boundary.
- Shortly before the boundary, open a skew-increasing position that pays a positive VPI charge into the pool.
- After the boundary, an unrelated keeper calls the permissionless settleLpEpoch, pricing the matured redemption from the inflated principal.
- Close the position after settlement to reclaim the charge via the lifetime clamp.
- Claim the redemption, which was priced 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.
When someone opens a trade that pushes the pool's balance in one direction, they pay a small fee into the pool. That fee is meant to be returned when they close the trade. The bug is that the pool counts this fee as real profit belonging to the liquidity providers, so their shares look more valuable than they are. A person who is both a liquidity provider and a trader can cash out at that inflated value and then get the fee back too, taking money from the other liquidity providers.
What is Business logic?
The application works as coded but not as intended: a negative price, a skipped payment step, a limit that can be crossed.