Refundable open VPI is priced into LP exits as final revenue, letting a Junior LP who trades steal other LPs' funds
A positive VPI (price-impact charge) from opening a position is immediately booked as LP revenue, but the same position can later reclaim that charge when it closes, so an LP that also trades can open a position just before its own redemption, redeem at a price that includes the charge, then close and receive the charge back, stealing funds from other LPs.
Originally disclosed on Immunefi
- Disclosed after under an hour
#99745 [SC-Critical] Refundable open VPI is priced into LP exits as final revenue, letting a Junior LP who trades steal other LPs' funds
Submitted on Nov 15th 2026 at 04:25:59 UTC by @itsactuallyomar for Audit Competition | Plether
- Report ID: #99745
- Report Type: Smart Contract
- Report severity: Critical
- Target: https://github.com/immunefi-team/audit-comp-plether/tree/a82d4fefb02768e5b3bddcc97dee371eee24fea8/packages/perps/src
- Impacts:
- Direct theft of any user funds, whether at-rest or in-motion, other than unclaimed yield
Description
Brief/Intro
An open's positive VPI (the price-impact charge) is booked as LP revenue the moment the position opens, and the LP share price has no term for it, although the same position's close can rebate up to the whole charge out of pool cash. A Junior LP that also trades opens a skew-widening position just before its own redemption is funded, redeems at a price that contains the charge, then closes and is rebated the whole charge out of the cash of the LPs who stayed. On a market deployed with the release parameters, the PoC's attacker ends with 2,779.027696 USDG more than all the USDG it brought, in one cycle and with no price move, and the other LPs lose principal: an LP that entered during the window exits 6,423.466462 USDG below its 6,500,000 deposit (6,228.351096 below its exit without the attack), and after three cycles a stayer exits 2,732.868082 USDG below its 1,000,000 deposit.
Vulnerability Details
1. An open books its VPI as pool revenue at once. executeOpen records the trade cost, minus the execution fee credited to the treasury, as Revenue with CashArrived (packages/perps/src/CfdEngineSettlementSidecar.sol:454-464):
if (delta.tradeCostAssets > 0) {
uint256 poolCashInflowAssets = uint256(delta.tradeCostAssets) - protocolFeeCreditedAssets;
if (poolCashInflowAssets > 0) {
IHousePool(host.pool())
.recordClaimantInflow(
poolCashInflowAssets,
IHousePool.ClaimantInflowKind.Revenue,
IHousePool.ClaimantInflowCashMode.CashArrived
);
}
}
recordClaimantInflow adds the amount to accountedAssets (HousePool.sol:640-641), and totalAssets() is the lesser of the raw balance and accountedAssets (HousePool.sol:426-429), so pool assets rise by the charge immediately. The same amount becomes the position's lifetime VPI (CfdEngineSettlementSidecar.sol:517):
vpiAccrued: currentPosition.vpiAccrued + delta.posVpiAccruedDelta,
2. The LP price treats the charge as final. Every Junior entry and exit is priced from one reconcile snapshot: pool assets minus trader claims, plus or minus the marked price delta (HousePoolAccountingLib.sol:60-78, fed by CfdEngineProtocolLens.sol:59-73, where physicalAssets = pool.totalAssets()):
uint256 terminalAssets = engineSnapshot.physicalAssets;
uint256 terminalLiabilities = engineSnapshot.traderClaimBalanceAssets;
int256 terminalDelta = engineSnapshot.terminalLpPriceDeltaAssets;
...
if (terminalAssets >= terminalLiabilities) {
snapshot.distributable = terminalAssets - terminalLiabilities;
There is no term for VPI that an open position can still take back. The epoch settlement reconciles (HousePool.sol:835), prices Junior redemptions at the reconciled juniorPrincipal (HousePool.sol:840-841), and then prices Junior deposits at the principal left after the exits (HousePool.sol:914-919). Revenue goes to Junior once Senior is at its high-water mark (HousePoolWaterfallAccountingLib.sol:140-159).
3. The same position takes the charge back at its close, out of pool cash. The close gives the closed part its share of lifetime VPI, evaluates a fresh curve delta at the current skew and depth, and clamps only so that lifetime VPI cannot go below zero (CloseAccountingLib.sol:103-118):
state.proportionalAccrualAssets =
(inputs.position.vpiAccrued * int256(inputs.sizeDelta)) / int256(inputs.position.size);
...
state.vpiDeltaAssets = CfdMath.calculateVPI(
inputs.preSkewAssets, inputs.postSkewAssets, inputs.poolDepthAssets, inputs.vpiFactor
);
...
if (state.proportionalAccrualAssets + state.vpiDeltaAssets < 0) {
state.vpiDeltaAssets = -state.proportionalAccrualAssets;
}
A close that narrows the skew is therefore rebated up to the whole charge. The planner nets the VPI delta with the execution fee, the frozen spread and carry, and treats a negative result as a rebate (CfdEnginePlanLib.sol:1036-1061), pays it from free pool cash (CfdEnginePlanLib.sol:970-978), and the sidecar pays it out of the pool (CfdEngineSettlementSidecar.sol:621-624; payOut lowers accountedAssets and transfers, HousePool.sol:604-613).
Between an open and its close, a charge that the position can still reclaim sits in Junior principal as if it were final. An LP that exits in that window is paid a share of it, an LP that enters in that window pays for a share of it, and the LPs in the pool at the close fund the refund.
The attack. It needs no role and no flash loan: order execution and LP epoch settlement are permissionless (OrderRouter.sol:233-247, OrderRouter.sol:474-484).
- The attacker deposits into Junior. After the 1 h deposit cooldown (
TrancheVault.sol:38) it queues a full redemption, which matures at the next hourly epoch boundary (HousePool.sol:178). - Shortly before that boundary it opens a skew-widening position and executes the order itself. The VPI is booked as revenue.
- The epoch is settled, and the redemption is paid at a Junior principal that contains the charge.
- It closes the position. The close's VPI is minus the whole charge, and the pool pays the rebate.
The attacker is paid its own charge twice: its share of it through the redemption price, and all of it through the rebate. The LPs who stay pay the difference.
Impact Details
Selected impact: Critical, "Direct theft of any user funds, whether at-rest or in-motion, other than unclaimed yield". The funds taken are other LPs' deposits held by HousePool.
All figures are from the PoC, in USDG, on unmodified contracts deployed and configured as the repository's deploy script does (release parameters: vpiFactor 1 %, skew cap 40 % of depth, execution fee 4 bps), on a market seeded through public entry points with 12,000,303.713891 of LP assets (Junior principal 4,000,000.999982).
Principal loss.
- An LP that deposits 6,500,000 into Junior, activated in the attacker's exit settlement, exits with 6,493,576.533538: 6,423.466462 below its deposit, and 6,228.351096 below its exit in the same timeline without the attack (
test_depthKept). - After three attack cycles, the stayer
lpJunior2(1,000,000 deposited) exits with 997,267.131918: 2,732.868082 below its deposit, and 3,954.737551 below its exit without the attack (test_repeatedCycles). - After one cycle the same stayer exits with 999,970.990600, against 1,001,287.649740 without the attack: 1,316.659140 less, and below its deposit (
test_attack).
Attacker profit (test_attack). The attacker holds 60 % of Junior (6,000,000 deposited). Its 6,000,000 LONG, opened 58 s before the settlement that funds its redemption, moves the book skew from 855,100.246500 to 6,855,087.176118 (3,808 bps of depth; the cap is 4,000 bps) and pays 12,849.948255 of VPI. The redemption pays 6,007,634.974119, against 5,999,912.373449 without the trade (7,722.600670 more). The close's VPI is -12,849.948255, and the pool pays a net rebate of 10,449.942343 in full, after withholding 2,400.005912 of close fee and carry. The attacker brought 6,610,000.000000 and holds 6,612,779.027696 at the end: +2,779.027696 absolute, and +2,866.654247 against the no-trade control, after both execution fees. All other LPs together lose 5,266.637877; the test asserts that this equals the attacker's gain plus the treasury's execution fee on the open (2,399.983630). Senior principal is unchanged (0.000000): the loss falls on Junior.
Scale and repetition.
- At the release Senior cap (Senior 39,990,220.179461 and Junior 11,505,210.096430 before the attacker), the attacker gains +9,355.786495 per cycle (+8,917.607346 absolute) and the other LPs lose 19,460.247941 (
test_releaseScale). - Three consecutive cycles (32,389 s) end at +2,779.027696, +2,785.365753 and +2,791.719508 (
test_repeatedCycles). - A day-long hold also pays: with the redemption funded 89,997 s after the open, the gain is +2,505.098748 and the stayer exits 1,226.270288 lower, below its deposit (
test_hold25h). - Depositing just before the open works too: +3,647.114276 over the deposit-only timeline, with the stayer 1,711.815978 lower (
test_freshDepositPath). - The transfer itself needs no attacker: an LP that exits while an unrelated trader's skew-widening LONG is open is paid 2,185.420985 more, and a stayer 206.386339 less, than without the trade (
test_passiveExit).
Conditions.
- The attacker needs a large share of Junior. The gain grows with the share, and break-even lies between the sweep's rows at 35 % (gain -172.923923) and 40 % (3,999 bps, gain +319.285320); the stayer pays in every row (
test_juniorShareSweep). The programme's rules state that "A high capital requirement is generally not a valid reason to downgrade a report" and that feasibility limitations "do not change the impact or severity of a finding". - It is not an artefact of a flat price: over 32 seeded random walks of the basket (sigma 0.17 bp per sqrt(second), price exposure unhedged), every seed gains over its control and ends in absolute profit; the two 16-seed halves have mean gains of +2,649.732224 and +2,849.615808, and the worst seed gains +1,783.778435 (
test_movingBasket_seeds01to16,test_movingBasket_seeds17to32). - It is not an artefact of a tight oracle confidence: on a flat basket, at per-feed Pyth confidence of 0.25, 2, 5, 8 and 10 bp of price, the attack gains +2,866.654247, +2,492.896384, +1,857.834455, +1,229.215221 and +805.924345 over its same-confidence control, ends in absolute profit at every level, and the stayer loses 1,316.659140 down to 801.329902 against its control; the last level sits at the oracle's 10 bp admission cap (
PletherOracle.sol:869-873; aggregate 997 hundredths of a bp), the widest confidence the oracle admits (test_widerPythConfidence).
Nearest known items.
- The AI-scan item AI-31, "Temporary pool-liquidity reduction can amplify a skew-reducing close rebate" (
audits/scan-plether-fi-plether-core-d4541b49.md:1742, a known issue under programme known issue #2), is about temporarily cutting pool depth to enlarge a skew-reducing close's rebate, whereas here the depth change adds only 9.047481 to the rebate (31 bps of the gain; +2,857.606766 without it,test_depthCutShareOfRebate), the attack still gains +2,516.079004 and the entrant still loses principal when depth at the close exceeds depth at the open (18,505,518.688027 against 18,000,303.713891) and the clamp does not bind (close VPI -12,499.250615,test_depthKept), and the fix below, which adds no depth guard and only defers when an open's VPI becomes revenue, makes every attack test fail. - M10 in the repository's history ("JIT LP attack via unrealized PnL", commit
e93999ee: "Mitigated by C3 deposit cooldown (1-hour capital lockup). Full fix (streaming revenue) deferred to V2.") names a different cause: here the attacker waits out the cooldown, the basket is flat so there is no unrealized PnL, the cause is a refundable charge booked as final revenue, and a hold that outlasts a 24 h streaming window still pays (test_hold25h; a supplementary check with a streaming sketch applied is at the end of this description). - The documented collection-time accounting ("Positive VPI increases physical pool assets",
WHITEPAPER.md:411-412) is not what this report disputes: the bug is that a collected charge the position can still reclaim is paid out as final, which breaks the stated property that new LPs "do not inherit old trader obligations at a higher deposit NAV" (SECURITY.md:859-860; the entrant intest_depthKept), while the documents accept a collection-time cohort transfer in words for carry (ACCOUNTING_SPEC.md:737-740) and keep the opposite-sign VPI reserve out of the price "so LPs cannot withdraw it as marked equity before the matching position obligation settles" (WHITEPAPER.md:887-888).
Recommendation
Keep a position's positive lifetime VPI out of LP equity until that position releases it. At an open, record as revenue only the part of the trade cost that is not a new increase in positive lifetime VPI. When the position lowers its lifetime VPI (a reduce, a close, a liquidation), record the released part as revenue before any rebate is paid.
diff --git a/packages/perps/src/CfdEngineSettlementSidecar.sol b/packages/perps/src/CfdEngineSettlementSidecar.sol
index 64a4710..6e123f1 100644
--- a/packages/perps/src/CfdEngineSettlementSidecar.sol
+++ b/packages/perps/src/CfdEngineSettlementSidecar.sol
@@ -378,6 +378,38 @@ contract CfdEngineSettlementSidecar is ICfdEngineSettlementSidecar {
}
}
+ function _positiveVpiPart(
+ int256 vpiAssets
+ ) private pure returns (uint256) {
+ return vpiAssets > 0 ? uint256(vpiAssets) : 0;
+ }
+
+ /// @dev A position's positive lifetime VPI is refundable by that position, so its cash stays outside
+ /// LP NAV (unrecorded pool cash) until the position releases it (reduce, close, liquidation, rebate on open).
+ function _deferredVpiIncrease(
+ int256 beforeAssets,
+ int256 afterAssets
+ ) private pure returns (uint256) {
+ uint256 b = _positiveVpiPart(beforeAssets);
+ uint256 a = _positiveVpiPart(afterAssets);
+ return a > b ? a - b : 0;
+ }
+
+ function _recognizeDeferredVpi(
+ ICfdEngineSettlementHost host,
+ int256 beforeAssets,
+ int256 afterAssets
+ ) private {
+ uint256 b = _positiveVpiPart(beforeAssets);
+ uint256 a = _positiveVpiPart(afterAssets);
+ if (b > a) {
+ IHousePool(host.pool())
+ .recordClaimantInflow(
+ b - a, IHousePool.ClaimantInflowKind.Revenue, IHousePool.ClaimantInflowCashMode.CashArrived
+ );
+ }
+ }
+
function _liveMark(
ICfdEngineAccountActionView engine,
ICfdEngineSettlementHost host
@@ -439,6 +471,7 @@ contract CfdEngineSettlementSidecar is ICfdEngineSettlementSidecar {
);
}
+ _recognizeDeferredVpi(host, currentPosition.vpiAccrued, currentPosition.vpiAccrued + delta.posVpiAccruedDelta);
if (delta.poolRebatePayoutAssets > 0) {
IHousePool(host.pool()).payOut(host.clearinghouse(), delta.poolRebatePayoutAssets);
}
@@ -452,7 +485,8 @@ contract CfdEngineSettlementSidecar is ICfdEngineSettlementSidecar {
delta.executionFeeAssets
);
if (delta.tradeCostAssets > 0) {
- uint256 poolCashInflowAssets = uint256(delta.tradeCostAssets) - protocolFeeCreditedAssets;
+ uint256 poolCashInflowAssets = uint256(delta.tradeCostAssets) - protocolFeeCreditedAssets
+ - _deferredVpiIncrease(currentPosition.vpiAccrued, currentPosition.vpiAccrued + delta.posVpiAccruedDelta);
if (poolCashInflowAssets > 0) {
IHousePool(host.pool())
.recordClaimantInflow(
@@ -618,6 +652,11 @@ contract CfdEngineSettlementSidecar is ICfdEngineSettlementSidecar {
if (delta.pricePayoutAssets > 0) {
host.settlementRecordTraderClaim(delta.account, delta.pricePayoutAssets, !delta.deletePosition);
}
+ _recognizeDeferredVpi(
+ host,
+ currentPosition.vpiAccrued,
+ delta.deletePosition ? int256(0) : currentPosition.vpiAccrued - delta.posVpiAccruedReduction
+ );
if (delta.actionRebatePaidAssets > 0) {
IHousePool(host.pool()).payOut(address(clearinghouse), delta.actionRebatePaidAssets);
clearinghouse.settleAssets(delta.account, int256(delta.actionRebatePaidAssets));
@@ -783,6 +822,10 @@ contract CfdEngineSettlementSidecar is ICfdEngineSettlementSidecar {
ICfdEngineSettlementHost host = ICfdEngineSettlementHost(msg.sender);
host.settlementApplyCarryAndMark(delta.price, publishTime);
IMarginClearinghouse clearinghouse = IMarginClearinghouse(host.clearinghouse());
+ {
+ (,,,,,, int256 vpiBeforeLiquidation) = ICfdEngineAccountActionView(ENGINE).positions(delta.account);
+ _recognizeDeferredVpi(host, vpiBeforeLiquidation, 0);
+ }
uint256 marginBefore = clearinghouse.pnlPledgeAssets(delta.account);
if (marginBefore != delta.posMargin) {
revert CfdEngineSettlementSidecar__SettlementMismatch();
With this diff applied, every attack test in the PoC fails at its first gain assertion and test_honestFlows passes (1 passed, 12 failed).
The diff demonstrates the rule; it is not a production patch. It keeps the deferred cash outside accountedAssets, so every totalAssets() read, including the pool depth used for VPI and the skew cap, leaves it out. A production version can instead keep an Engine aggregate of open positions' positive lifetime VPI and subtract it as a liability in buildReconcileSnapshot (not tested).
Proof of Concept: tests, expected output and checks
What each test proves (all on unmodified code)
test_attack: one cycle at 60 % of Junior. The attacker ends with more USDG than it brought and gains more than 2,000 over the no-trade control; the close is rebated exactly the open's charge and the pool pays it in full; the stayer exits below its control and below its deposit; the other LPs lose more than the attacker gains, exactly its gain plus the treasury's fee on the open.test_releaseScale: the same at the release Senior cap (Senior above 39,000,000): absolute profit, gain above 5,000, the stayer below its control and its deposit.test_repeatedCycles: three cycles in a row, each ending in absolute profit; the stayer then exits below its control and its deposit.test_depthKept: an unrelated 6,500,000 Junior deposit activates in the attacker's exit settlement, so the close runs at more depth than the open and its curve rebate is below the charge (the clamp does not bind); the attack still gains more than 2,000, and the new LP exits below its control and its deposit.test_depthCutShareOfRebate: the rebate the depth change adds is less than 1 % of the gain, and without it the gain is still above 2,000.test_passiveExit: no attacker; an LP that exits while an unrelated trader's skew-widening position is open is paid more than 1,000 above the no-trade run, and a stayer less.test_freshDepositPath: deposit, open right after activation, redeem, close: absolute profit, a gain above 2,000 over the deposit-only timeline, and the pool and the stayer end lower.test_hold25h: the redemption is funded at least 24 h after the open: absolute profit, a gain above 2,000, and the stayer more than 1,000 lower and below its deposit.test_juniorShareSweep: the attacker's share of Junior at 30 / 35 / 40 / 45 / 60 / 75 %: 30 % loses, 45 / 60 / 75 % gain, the gain grows with the share, and the stayer pays in every row.test_movingBasket_seeds01to16,test_movingBasket_seeds17to32: 16 seeded random walks of the basket each, price exposure unhedged: mean gain above 2,000, every seed gains over its control and ends in absolute profit.test_widerPythConfidence: per-feed Pyth confidence of 0.25, 2, 5, 8 and 10 bp of price, attack and control at the same confidence: at every level the attack gains, ends in absolute profit, and the stayer exits below its control; the last level is at the oracle's cap (aggregate at least 9.95 bp).test_honestFlows: control for the fix run: the seeded traders close, and LPs exit and enter normally.
Output (-vv, Forge 1.5.1; compiler warnings omitted, ... marks omitted log lines)
Ran 1 test for test/perps/poc/VpiRefundLpExit.t.sol:VpiRefundLpExitWiderConfidenceTest
[PASS] test_widerPythConfidence() (gas: 179815193)
Logs:
WIDER PYTH CONFIDENCE: the attack and its no-trade control at the same per-feed confidence
per-feed confidence 0.25 bp of price (raw price / 40000)
aggregate basket confidence the oracle accepted (hundredths of a bp of price): 18
attacker gain over the control (USDG): 2866.654247
attacker net, attack (USDG): 2779.027696
...
stayer lpJunior2 change vs the control (USDG): -1316.659140
per-feed confidence 2 bp of price (raw price / 5000)
aggregate basket confidence the oracle accepted (hundredths of a bp of price): 196
attacker gain over the control (USDG): 2492.896384
attacker net, attack (USDG): 2405.269833
...
stayer lpJunior2 change vs the control (USDG): -1223.193056
per-feed confidence 5 bp of price (raw price / 2000)
aggregate basket confidence the oracle accepted (hundredths of a bp of price): 498
attacker gain over the control (USDG): 1857.834455
attacker net, attack (USDG): 1770.207904
...
stayer lpJunior2 change vs the control (USDG): -1064.382345
per-feed confidence 8 bp of price (raw price / 1250)
aggregate basket confidence the oracle accepted (hundredths of a bp of price): 796
attacker gain over the control (USDG): 1229.215221
attacker net, attack (USDG): 1141.588670
...
stayer lpJunior2 change vs the control (USDG): -907.182767
per-feed confidence 10 bp of price (raw price / 1000)
aggregate basket confidence the oracle accepted (hundredths of a bp of price): 997
attacker gain over the control (USDG): 805.924345
attacker net, attack (USDG): 718.297794
...
stayer lpJunior2 change vs the control (USDG): -801.329902
Suite result: ok. 1 passed; 0 failed; 0 skipped; finished in 215.41ms (206.16ms CPU time)
Ran 12 tests for test/perps/poc/VpiRefundLpExit.t.sol:VpiRefundLpExitTest
[PASS] test_attack() (gas: 133742194)
Logs:
boot: pool assets / Junior principal / Senior principal (USDG):
12000303.713891 4000000.999982 8000001.000018
ATTACK: 60% of Junior, 6,000,000 LONG
claim-net pool depth right before the open (USDG): 18000303.713891
open: VPI paid by the attacker's LONG (lifetime VPI after the open, USDG): 12849.948255
book skew right before the open, |long - short| at the mark (USDG): 855100.246500
book skew right after the open (USDG): 6855087.176118
book skew after the open, share of the depth before it (bps): 3808
open: USDG the open cost the attacker, VPI + execution fee (USDG): 15249.931885
open -> settlement that funds the redemption (seconds): 58
redemption paid, attack (USDG): 6007634.974119
redemption paid, no-trade control (USDG): 5999912.373449
redemption paid above the control (USDG): 7722.600670
claim-net pool depth right before the close (USDG): 12005518.688027
close: VPI of the close, preview right before it (USDG, negative = rebate): -12849.948255
close: net action rebate assessed, event (USDG): 10449.942343
close: net action rebate paid out of the pool, event (USDG): 10449.942343
close: net action rebate waived, event (USDG): 0.000000
close: execution fee and carry withheld from the VPI rebate, kept by the pool (USDG): 2400.005912
attacker: USDG brought, deposit + margin + buffer (USDG): 6610000.000000
attacker: USDG held at the end (USDG): 6612779.027696
attacker net, attack (USDG): 2779.027696
attacker net, no-trade control (USDG): -87.626551
attacker gain over the control (USDG): 2866.654247
attacker LP leg, redeemed - deposited (USDG): 7634.974119
attacker trading leg, clearinghouse out - in (USDG): -4855.946423
stayer lpJunior2 (deposited 1,000,000) real exit, attack (USDG): 999970.990600
stayer lpJunior2 real exit, no-trade control (USDG): 1001287.649740
stayer lpJunior2 change vs the control (USDG): -1316.659140
other Junior principal after that settlement, change vs the control (USDG): -3949.978737
Senior principal after that settlement, change vs the control (USDG): 0.000000
all stayers (every LP but the attacker), change vs the control (USDG): -5266.637877
protocol treasury, change vs the control (USDG): 2399.983630
gas of the whole attack cycle as run here (every call incl. the keeper's, plus test overhead): 8440989
[PASS] test_depthCutShareOfRebate() (gas: 133534643)
Logs:
DEPTH CUT: share of the close rebate and of the gain
open: VPI charged (USDG): 12849.948255
claim-net depth right before the open (USDG): 18000303.713891
pool assets right before the funding settlement (USDG): 18013153.662146
...
close VPI at unchanged depth, preview after the open and before the funding (USDG): -12840.900774
close VPI at unchanged depth, simulateClose at the close's instant (USDG): -12840.900603
close VPI the real close receives, clamped (USDG): -12849.948255
rebate added by the depth cut, against the pre-funding preview (USDG): 9.047481
rebate added by the depth cut, against simulateClose at the close's instant (USDG): 9.047652
rebate without the depth cut, as a share of the charge (basis points): 9992
redemption paid above the control (USDG): 7722.600670
attacker gain over the control (USDG): 2866.654247
attacker gain without the depth cut's addition (USDG): 2857.606766
depth cut's addition as a share of the gain (basis points): 31
[PASS] test_depthKept() (gas: 136986464)
Logs:
DEPTH KEPT: unrelated 6,500,000 Junior deposit activates in the attacker's exit settlement
claim-net pool depth right before the open (USDG): 18000303.713891
open: VPI paid by the attacker's LONG (lifetime VPI after the open, USDG): 12849.948255
...
claim-net pool depth right before the close (USDG): 18505518.688027
close: VPI of the close, preview right before it (USDG, negative = rebate): -12499.250615
...
attacker gain over the control (USDG): 2516.079004
...
stayer lpJunior2 (deposited 1,000,000) real exit, attack (USDG): 1001627.038607
stayer lpJunior2 real exit, no-trade control (USDG): 1001298.951333
stayer lpJunior2 change vs the control (USDG): 328.087274
...
entrant lpJunior3 (deposited 6,500,000) real exit, attack (USDG): 6493576.533538
entrant lpJunior3 real exit, no-trade control (USDG): 6499804.884634
entrant lpJunior3 change vs the control (USDG): -6228.351096
[PASS] test_freshDepositPath() (gas: 132759431)
Logs:
FRESH DEPOSIT: 20,000,000 Junior, 8,000,000 LONG right after activation
attacker net, deposit + trade (USDG): 3525.373235
attacker net, deposit only (USDG): -121.741041
attacker gain over the deposit-only timeline (USDG): 3647.114276
...
pool assets change (USDG): -6847.265623
...
stayer lpJunior2 change (USDG): -1711.815978
[PASS] test_hold25h() (gas: 134210006)
Logs:
HOLD 25 H: redemption funded about 25 h after the open
...
open -> settlement that funds the redemption (seconds): 89997
...
close: net action rebate paid out of the pool, event (USDG): 10449.942343
close: net action rebate waived, event (USDG): 0.000000
close: execution fee and carry withheld from the VPI rebate, kept by the pool (USDG): 2400.005912
attacker: USDG brought, deposit + margin + buffer (USDG): 6610000.000000
attacker: USDG held at the end (USDG): 6611365.953589
attacker net, attack (USDG): 1365.953589
attacker net, no-trade control (USDG): -1139.145159
attacker gain over the control (USDG): 2505.098748
attacker LP leg, redeemed - deposited (USDG): 6583.455511
attacker trading leg, clearinghouse out - in (USDG): -5217.501922
stayer lpJunior2 (deposited 1,000,000) real exit, attack (USDG): 999885.890918
stayer lpJunior2 real exit, no-trade control (USDG): 1001112.161206
stayer lpJunior2 change vs the control (USDG): -1226.270288
other Junior principal after that settlement, change vs the control (USDG): -3678.812090
...
[PASS] test_honestFlows() (gas: 132284864)
...
[PASS] test_juniorShareSweep() (gas: 187373277)
Logs:
JUNIOR SHARE SWEEP
Junior share 3000 bps, deposit 1715000.000000, LONG 4351700.000000
attacker gain over the control (USDG): -632.713332
stayer lpJunior2 real exit, lower than the control by (USDG): 276.985123
Junior share 3500 bps, deposit 2153847.000000, LONG 4518461.860000
attacker gain over the control (USDG): -172.923923
stayer lpJunior2 real exit, lower than the control by (USDG): 408.611850
Junior share 3999 bps, deposit 2666667.000000, LONG 4713333.460000
attacker gain over the control (USDG): 319.285320
stayer lpJunior2 real exit, lower than the control by (USDG): 551.150260
Junior share 4501 bps, deposit 3275000.000000, LONG 4944500.000000
attacker gain over the control (USDG): 853.555769
stayer lpJunior2 real exit, lower than the control by (USDG): 707.835613
Junior share 5999 bps, deposit 6000000.000000, LONG 5980000.000000
attacker gain over the control (USDG): 2837.148468
stayer lpJunior2 real exit, lower than the control by (USDG): 1307.280767
Junior share 7499 bps, deposit 12000000.000000, LONG 8260000.000000
attacker gain over the control (USDG): 6206.922473
stayer lpJunior2 real exit, lower than the control by (USDG): 2377.722847
[PASS] test_movingBasket_seeds01to16() (gas: 364348445)
Logs:
MOVING BASKET: seeded random walks, sigma 0.17 bp per sqrt(second); seeds 1 to 16
...
seeds: 16
mean gain
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
Impact
An attacker who holds a large share of Junior can steal other LPs' funds, with the PoC showing a profit of 2,779 USDG in one cycle and other LPs losing principal; the attack works across price movements and oracle confidence levels, though it requires a large capital share (break-even between 35% and 40% of Junior).
What the attacker needed
Large share of Junior (break-even ~35-40%); deposit cooldown of 1 hour; permissionless order execution and epoch settlement
The fix
The report recommends deferring a position's positive lifetime VPI from LP equity until the position releases it, recording as revenue only the part of the trade cost that is not a new increase in positive lifetime VPI, and recognising the released part as revenue when the position lowers its VPI.
How it was found
- Deposit into Junior and wait for the 1-hour cooldown, then queue a full redemption that matures at the next hourly epoch boundary.
- Shortly before that boundary, open a skew-widening position and execute the order yourself, so the VPI is booked as revenue.
- Let the epoch settle, so the redemption is paid at a Junior principal that includes the charge.
- Close the position; the close's VPI is negative for the whole charge, and the pool pays the rebate.
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, they pay a fee called VPI that is supposed to compensate liquidity providers (LPs) for the price impact. The system immediately counts this fee as profit for LPs, so the LP share price goes up. But if the trader later closes the position, the system gives back that same fee from the pool's cash. An attacker who is also an LP can exploit this: they open a big trade just before their own LP withdrawal is processed, so they get a share of the fee in their withdrawal, then close the trade and get the fee refunded, leaving other LPs to cover the loss.
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.