Virtual-offset Senior redemption diverts a surviving LP's principal recovery to Junior after the MED-11 fix
After the MED-11 fix, a Senior redemption priced with virtual ERC-4626 offsets can remove more high-water-mark recovery entitlement than the fraction of Senior shares actually burned. A second Senior holder who stays in the impaired tranche then receives less of the later recovery cash, which is diverted to the exiting holder's Junior position.
- Disclosed after under an hour
#99146 [SC-Low] Virtual-offset Senior redemption diverts a surviving LP's principal recovery to Junior after the MED-11 fix
Submitted on Nov 12th 2026 at 04:50:41 UTC by @Rrudy for Audit Competition | Plether
- Report ID: #99146
- Report Type: Smart Contract
- Report severity: Low
- 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
Root cause
The MED-11 fix reduces Senior high-water mark (H) and principal (P) by the same funded asset fraction when a Senior redemption receives A assets: P' = P - A and H' = H - floor(H*A/P). The Senior vault separately prices the payout with virtual ERC-4626 offsets: floor(burnedShares*(P+1)/(preBurnSupply+1000)). When P is tiny while H remains large after a loss, A/P can exceed the fraction of actual Senior shares burned. The HWM reduction then removes recovery priority attached to shares held by an unrelated Senior LP. HWM writer, vault conversion.
The accounting specification defines HWM as Senior entitlement to be restored by future Pool surplus before Junior receives that surplus. This PoC follows the redirected cash through funded LP redemptions: the unrelated Senior LP B receives less USDG and the attacker-controlled Senior plus Junior LP A receives more. The balances are actual token payouts, not a view-only NAV difference.
Reproduction and realized harm
- A initially funds 160,000 USDG of Senior shares and 200,000 USDG of Junior shares. Unrelated B funds 40,000 USDG of Senior shares. The common setup includes an authorized Owner
recapitalizePool(3,000,000 USDG)before the loss-producing trades that wipe current Senior and Junior principal while preserving Senior HWM. The Owner is not controlled by A. - A transfers 12 USDG atoms to the Pool. The Owner subsequently uses the documented
accountExcess()route, and a public LP epoch recognizesP = freeAssets = 12 atoms,J = 0, andH = 200,006,481,502 atoms. A cannot compel the Owner to admit that excess rather than sweep or ignore it. - From the same EVM snapshot, the control keeps A's Senior shares. The attack has A redeem its Senior shares first and receive 10 atoms. This is
10/12of current principal although A burns about 80% of issued Senior shares. The pinned formula leavesH' = 33,334,413,584 atoms; scaling the pre-existing recovery target by the actual burned-share fraction would leave40,002,097,915 atoms. The difference, 6,667,684,331 atoms, is the aggregate surviving Senior HWM difference, not a separate 6,667.68 USDG claim owned by B alone. - An unrelated, self-funded trader D then makes the same 40 loss-producing round trips in both branches. The Pool receives exactly
256,995,052,582 atomsfrom those trades in each. At the same final timestamp, A and B submit their remaining LP shares for redemption and claim the funded USDG. B's final residual share quote is zero in both branches.
| Final USDG | Control: no early A exit | Attack: A exits first | Attack minus control |
|---|---|---|---|
| B's actual wallet payout | 40,001.095896 | 33,333.578586 | −6,667.517310 |
| A's Senior plus Junior wallets | 336,990.051956 | 343,655.657021 | +6,665.605065 |
| Pool raw USDG | 2,797,432.696751 | 2,797,434.608996 | +1.912245 |
The three deltas sum to zero in USDG atoms. D's final wallet, credit and claim, Treasury credit, Keeper credit, and final time match between branches. B deposited 40,000 USDG. Its control payout includes 1.095896 USDG above that deposit, whereas the attack payout is 6,666.421414 USDG below its original contribution. The 6,667.517310 USDG branch difference is primarily lost principal recovery, with the control's 1.095896 USDG excess kept distinct. B's immediate pre-recovery quote is only 2 atoms in both branches; the claimed diversion occurs after D's real USDG payments enter the Pool, when lowered Senior HWM routes that recovery cash to A's Junior position. We do not claim theft of the 2-atom quote, permanent freezing, or an end-to-end gas-adjusted profit figure.
Why the selected impact is direct loss of principal recovery
The same later trading receipts enter the Pool in both branches. The earlier Senior exit changes who receives that real USDG: B's funded redemption falls by 6,667.517310 USDG while A's Junior-funded wallet rises. The separate zero-Senior-coupon control still leaves B 6,667.334631 USDG below its 40,000 USDG contribution after A exits. The claim is diversion of cash that would restore B's earlier principal contribution, not theft of a Senior coupon or B's immediately redeemable 2-atom quote. B's pre-recovery principal is already impaired; the loss is realized when the subsequent recovery cash is allocated and paid.
An auxiliary zero Senior coupon control sets seniorRateBps = 0 through the ordinary timelock in the test fixture. It is not the release-setting impact run. In that control, B receives 39,999.999999 USDG without A's early exit and 33,332.665369 USDG after it: a 6,667.334630 USDG branch difference, and the latter is 6,667.334631 USDG below B's 40,000 USDG deposit. A's wallet increases by 6,665.422431 USDG and Pool raw USDG by 1.912199. This isolates principal recovery from the Senior coupon; it does not assert that all forms of yield or trading revenue disappear.
Auxiliary check: public dust creation with observed feed values
An independently rerun second Foundry test reaches the impaired Senior principal through public order and LP settlement calls without an accountExcess() call or any Owner call after the initial wipeout. The common setup still includes an authorized 3,000,000 USDG Owner recapitalization before the wipeout; it is not an Owner-free end-to-end attack. After the synthetic wipeout, the test opens a 1,255-lot LONG using saved six-feed raw price/confidence values at tick 10, settles an LP epoch at tick 11, closes 284 lots at tick 17 and 971 lots at tick 19, then settles at tick 20 approximately seven weeks later. The resulting Senior principal is 647 USDG atoms, with HWM 200,006,481,502 atoms. A burns 159,559,820,458,974 Senior shares and receives 518 atoms; the funded-asset HWM formula leaves 39,877,644,689 atoms, whereas scaling by the shares actually burned would leave 40,124,757,091 atoms.
The five relevant saved observations are listed below in feed order EUR, JPY, GBP, CAD, SEK, CHF. Their exponents are [-5, -3, -5, -5, -5, -5]; the mock uses publishTime = originalTime - 79,228,800 and prevPublishTime = publishTime - 1.
| Tick | Original publishTime | Raw prices | Raw confidences |
|---|---|---|---|
| 10 | 1789581699 | 115156, 155289, 134210, 139527, 979132, 81979 | 8, 13, 16, 6, 402, 8 |
| 11 | 1789583356 | 114997, 155521, 134108, 139693, 981625, 82210 | 2, 4, 3, 5, 78, 6 |
| 17 | 1789583436 | 114968, 155547, 134082, 139706, 981742, 82230 | 2, 4, 4, 2, 116, 3 |
| 19 | 1789583449 | 114964, 155570, 134068, 139724, 981866, 82240 | 4, 7, 4, 5, 69, 6 |
| 20 | 1793635973 | 111938, 157854, 134132, 139707, 979444, 82008 | 3, 6, 4, 4, 89, 3 |
From the same snapshot, B's final funded cash is 40,001.095896 USDG if A stays and 39,754.745075 USDG if A exits first (−246.350821 USDG). The attacker coalition's actual wallets, including its trader, gain 244.359352 USDG relative to the control, and Pool raw cash rises 1.991469 USDG; these three differences sum to zero in atoms. D's wallet and Treasury/Keeper credits match. The independent offline replay passed 1/1 with the pinned src files unchanged. This is a separate, smaller impact check, not the 6,667.517310 USDG main-test result.
A further matched-epoch control also passed 1/1: both branches submit the same Junior refund request and settle the same tick-20 LP epoch with the same price, while only the attack branch adds A's Senior exit. Its final B, attacker-coalition, Pool, D, Treasury and Keeper amounts are atom-for-atom identical to the figures above. The original control's mark-only call therefore did not cause this measured difference.
These auxiliary checks support reachability and control alignment; their full test sources are not embedded below. Appendices A–C are the self-contained reproduction of the primary 6,667.517310 USDG payout difference.
The test re-encodes saved observations into unsigned MockPyth updates and shifts their timestamps by 131 weeks while retaining order and intervals. The first tick predates the recorded v2.0.0 deployment; the wipeout and subsequent recovery trades still use synthetic prices. This check removes post-wipeout accountExcess() and atom-level price tuning for the dust step, but it is not a complete signed, deployed-market attack sequence.
Published MED-11 boundary
Cecuro MED-11 identified an earlier mismatch between burned-share HWM scaling and net principal debits, including loss of retained-fee protection. PR #123 replaced the writer with the funded-asset fraction A/P to preserve the aggregate H/P ratio. That formula is public. We do not claim it is evaluated incorrectly, and we do not claim PR #123's less-than-one-atom rounding bound is broken, because that bound concerns integer rounding within H*A/P.
PR #123 expressly chose net-funded-asset scaling for impaired redemptions and discussed virtual offsets. It did not show the following multi-holder cash-flow consequence at the pinned commit:
- The vault's
+1virtual asset lets the paid fraction exceed the burned-share fraction, which strips recovery entitlement from shares that were never redeemed. - The published remediation does not present a surviving Senior holder's funded payout after a second holder exits at a near-zero principal quote. This PoC compares that payout with the same-snapshot no-exit control.
- Neither the program's known-issues list nor the Known Limitations section of
SECURITY.mdcovers it.
Security property implicated by the payout.
- Senior-first recovery for a surviving holder.
SECURITY.mdlists "High-water-mark protection | Senior impairment must be restored before junior extracts surplus" among its Critical Protocol Invariants (SECURITY.md:394). The aggregate HWM formula executes as written, but A's 10-atom exit removes more HWM than the fraction of Senior shares burned. Subsequent revenue reaches Junior (A) while B receives only 33,333.578586 USDG against its original 40,000 USDG contribution. The claimed violation is the loss of B's surviving recovery entitlement, not an arithmetic failure in the aggregate formula. - Virtual-offset boundary.
SECURITY.md:1082-1083says healthy withdrawals must not create impairment through virtual-offset pricing and that conservative rounding can preserve an existing impairment (L1082-L1083). It does not explicitly guarantee a per-holder outcome for an already impaired tranche. This PoC tests that narrower, multi-holder case; its measured payout difference is the evidence for the proposed incomplete-fix impact. - Intended properties stated in the tests.
- "Senior recovery rights should survive wipeout" (
TrancheRecoveryBehavior.t.sol:76). - "All remaining Senior principal must recover first" (
SeniorWithdrawalProtection.t.sol:51).
- "Senior recovery rights should survive wipeout" (
- Not covered by the MED-11 tests named in PR #123. None has a second Senior holder who stays in an impaired tranche and is paid after recovery:
SeniorWithdrawalProtectionTesthas a single Senior holder.SeniorWithdrawalMathTestfuzzesscaleSeniorOnWithdrawwithassetsas a free input rather than the vault quote.SeniorRedemptionHighWaterTest(L162-L198) uses two holders in a healthy tranche and never pays Bob.
MED-11's remediation describes aligning the surviving Senior entitlement with the surviving ownership, offering the funded-asset fraction or a rule that mirrors the vault's virtual-share pricing as possible ways to do so (PDF pp. 31–32). This test checks the first option in the impaired multi-holder state: a 10-atom funded exit burns about 80% of shares but removes about 83.33% of HWM, and the discrepancy reaches B's funded payout. The issue is the economic result of the selected fix at this boundary, not an arithmetic error in evaluating A/P.
The reported issue is the incomplete or fix-induced outcome at the pinned commit. In the deeply impaired, multi-holder state, the repaired A/P fraction is larger than the redeemed ownership fraction. The original share-fraction writer would leave a higher HWM on this particular snapshot, while the pinned writer transfers later funded recovery away from B. The original formula is not proposed as a general repair. The measured second-holder payout is the result that matters. The competition's known-issue rule permits a report on a fixed/acknowledged root where the pinned fix is incomplete or creates a new bug. This PoC demonstrates that incomplete multi-holder recovery result.
Preconditions, feasibility, and cost boundary
- A must already own substantial Senior and Junior shares. The primary 6,667.517310 USDG example requires an Owner recapitalization before the severe loss and
accountExcess()afterward. The auxiliary 246.350821 USDG example removes the latter call, but still requires the earlier recapitalization.recapitalizePool()has no on-chain deficit/degraded precondition, but the documentation calls it a recovery action. The attacker cannot force that Owner contribution, and this test does not establish how often an Owner would pre-fund a healthy Pool. No malicious Owner action is assumed. The competition scope includes bugs triggered by legitimate documented trusted-role actions. - The main test uses the release's six feed IDs, weights, base prices, inversions, seed amounts and risk settings. It supplies synthetic unsigned
MockPythupdates withexpo = -8andconf = 0for all six feeds; those uniform mock exponents are not a replay of the varying exponents in signed market payloads. Mocking the out-of-scope Pyth input is allowed by the PoC rules, but a signed six-feed market time series reaching this exact state has not been demonstrated. That includes a sequence made only of post-deployment observations. The rules state that impact is calculated first, separately from feasibility. - The initial loss setup alternates a roughly 2.18% basket range across 48 order executions, and D's later cash generation uses 40 round trips across 80 executions. The test compresses those synthetic price changes into short simulated intervals. This establishes the pinned contracts' state transition and the same-snapshot cash impact; it does not establish that this exact price sequence occurs at that frequency in the real FX market. An organically reached impaired/recovery state would expose the same accounting boundary.
- At the final dust step A contributes 12 USDG atoms and receives 10 atoms in its Senior redemption. Foundry measured 963,025 gas for the redemption helper, including its keeper settlement call. These are marginal step measurements, not the total attack cost or Arbitrum fee. A's initial LP capital, prior loss exposure, oracle data, other transactions, and the Owner's 3,000,000 USDG recapitalization are separate prerequisites. The report does not treat the Owner's money as an attacker expense.
Suggested fix
Preserve the recovery entitlement attached to surviving Senior shares when virtual-offset pricing makes the paid-asset fraction differ from the burned-share fraction. Keep the actual cash debit to principal, and test any revised HWM rule against healthy and impaired multi-holder exits, frozen fees, partial funding, terminal dust, and later independent revenue paid to the surviving holder. This is a design direction, not an audited patch.
Proof of Concept
Save Appendices A, B and C below as OneAtomP12DonorFollowup.t.sol, patch_sixfeed_fixture.py and run_repro.sh in one directory. Against a checkout of the pinned commit with an offline Foundry toolchain and Solidity 0.8.35 binary, run on Linux or WSL:
bash run_repro.sh /absolute/path/to/pinned-source /absolute/path/to/offline-toolchain /absolute/path/to/solc-0.8.35 /absolute/path/to/new-output
The runner checks the pinned HousePool.sol hash, copies the checkout to disposable scratch space, adds the PoC, changes the copied test fixture to install the six-feed MockPyth configuration and production Router, and removes other test files only inside that scratch copy to keep compilation bounded. It runs forge --offline inside bwrap --unshare-net and does not modify packages/perps/src. Appendix A/B/C SHA-256 values are 46ccc862854a5e47461ea8f3f40eeaae61c8c956d0cb803ab76424dfe42bc64d, eb3f4e8607b914ab435f2881d4108a0909153827d6c443a20074380298725726, and 0ca1ea21cb69570e0a238963faad97e299cafce79557fd0ca2fd1ef1c9745e0a. The final isolated final-20261112/repro02 run exited 0 with empty stderr and Foundry 1/1 PASS. The Solidity test asserts A's 10-atom early payout, equal D outcomes and final time, the three exact payout/cash deltas in the table, and their atom-level conservation. The saved logs also show Pool/Treasury/Keeper balances.
Optional economic control: Add import {IHousePool} from "@plether/perps/interfaces/IHousePool.sol"; at file scope in Appendix A. Then, inside setUp, replace _setSeniorCapacity(40_000_000e6, 8000); with the block below. This is the auxiliary zero-coupon branch quoted above, not the release-setting run and not required for the primary reproduction.
IHousePool.PoolConfig memory poolConfig = _currentPoolConfig();
poolConfig.maxSeniorExposureAssets = 40_000_000e6;
poolConfig.maxSeniorShareBps = 8000;
poolConfig.seniorRateBps = 0;
pool.proposePoolConfig(poolConfig);
uint256 activation = pool.poolConfigActivationTime();
vm.warp(activation - 1);
_mark(1e8);
pool.finalizePoolConfig();
assertEq(pool.seniorRateBps(), 0, "zero coupon");
Appendix A — full Solidity PoC, OneAtomP12DonorFollowup.t.sol
// SPDX-License-Identifier: AGPL-3.0
pragma solidity 0.8.35;
import {BasePerpTest} from "../../BasePerpTest.sol";
import {CfdTypes} from "@plether/perps/CfdTypes.sol";
import {OrderV3Types} from "@plether/perps/OrderV3Types.sol";
import {IOrderRouterAdminHost} from "@plether/perps/interfaces/IOrderRouterAdminHost.sol";
contract OneAtomP12ScaledTest is BasePerpTest {
uint256 constant SCALE = 100;
address constant SENIOR_LP = address(0xB0B);
address constant SECOND_SENIOR = address(0xB0C);
address constant JUNIOR_LP = address(0xA11CE);
address constant TRADER = address(0xC0A01);
address constant DONOR = address(0xD0A0);
address constant KEEPER = address(0xB0A7D);
// These synthetic values sit within the extrema of saved signed six-feed observations.
uint256 constant HIGH = 98_598_508;
uint256 constant LOW = 96_497_594;
uint256 constant P = 30_000e6 * SCALE;
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 {
super.setUp();
CfdTypes.RiskParams memory risk = _riskParams();
risk.vpiFactor = 0.01e18;
risk.maintMarginBps = 10;
risk.initMarginBps = 20;
_setRiskParams(risk);
IOrderRouterAdminHost.RouterConfig memory config = _routerConfig();
config.adverseConfidenceMultiplierBps = 2500;
config.minOpenNotionalAssets = 1_000e6;
config.maxPendingOrders = 5;
routerAdmin.proposeRouterConfig(config);
vm.warp(vm.getBlockTimestamp() + 72 hours + 1);
routerAdmin.finalizeRouterConfig();
_setSeniorCapacity(40_000_000e6, 8000);
}
function _order(CfdTypes.Side side, bool close, uint256 size, uint256 margin, uint256 target, uint256 tag)
private view returns (OrderV3Types.OrderRequest memory r) {
r.clientOrderId = bytes32(tag);
r.side = side;
r.isClose = close;
r.sizeDelta = size;
r.marginDelta = margin;
r.targetPrice = target;
r.bounds = OrderV3Types.ExecutionBounds({
submitBy: uint64(vm.getBlockTimestamp() + 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
});
}
function _execute(CfdTypes.Side side, bool close, uint256 size, uint256 margin, uint256 price, uint256 tag) private {
uint256 target = side == CfdTypes.Side.LONG ? (close ? engine.CAP_PRICE() : 1) : (close ? 1 : engine.CAP_PRICE());
OrderV3Types.OrderRequest memory r = _order(side, close, size, margin, target, tag);
vm.prank(TRADER);
uint64 id = router.commitOrder(r);
bytes[] memory tick = _mockPythUpdateData(price);
vm.prank(KEEPER);
OrderV3Types.ExecutionResult memory result = router.executeOrder(id, tick);
assertEq(uint8(result.status), uint8(OrderV3Types.LifecycleStatus.Executed), "ordinary public order");
}
function _executeFor(address account, CfdTypes.Side side, bool close, uint256 size, uint256 margin, uint256 price, uint256 tag) private {
uint256 target = side == CfdTypes.Side.LONG ? (close ? engine.CAP_PRICE() : 1) : (close ? 1 : engine.CAP_PRICE());
OrderV3Types.OrderRequest memory r = _order(side, close, size, margin, target, tag);
vm.prank(account);
uint64 id = router.commitOrder(r);
bytes[] memory tick = _mockPythUpdateData(price);
vm.prank(KEEPER);
OrderV3Types.ExecutionResult memory result = router.executeOrder(id, tick);
assertEq(uint8(result.status), uint8(OrderV3Types.LifecycleStatus.Executed), "independent donor public order");
}
function _mark(uint256 price) private returns (bytes[] memory tick) {
tick = _mockPythUpdateData(price);
vm.prank(KEEPER);
router.updateMarkPrice(tick);
}
function _log(string memory label) private {
emit log_string(label);
emit log_named_uint("cash", pool.totalAssets());
emit log_named_uint("unassigned", pool.unassignedAssets());
emit log_named_uint("free", pool.getFreeAssets());
emit log_named_uint("Senior P", pool.seniorPrincipal());
emit log_named_uint("Junior J", pool.juniorPrincipal());
emit log_named_uint("Senior HWM", pool.seniorHighWaterMark());
emit log_named_uint("pending revenue", pool.pendingTradingRevenueAssets());
emit log_named_uint("Trader claim", engine.traderClaimBalanceAssets(TRADER));
}
function _requestJuniorRefundRound(uint256 previousId) private returns (uint256 id) {
uint256 shares = juniorVault.refundableRedeemRequest(previousId, JUNIOR_LP);
assertGt(shares, 0, "zero-quote Junior epoch returns shares");
vm.prank(JUNIOR_LP);
assertEq(juniorVault.claimRedeemRefund(previousId, JUNIOR_LP, JUNIOR_LP), shares, "Junior refund");
vm.warp(vm.getBlockTimestamp() + 3601);
_mark(HIGH);
vm.prank(JUNIOR_LP);
id = juniorVault.requestRedeem(shares, JUNIOR_LP, JUNIOR_LP);
if (vm.getBlockTimestamp() < pool.lpEpochStart(id)) vm.warp(pool.lpEpochStart(id));
}
function test_P12Scaled() public { _run(0); }
function _run(int256 shareDelta) private {
settlementToken.mint(JUNIOR_LP, 2_000e6 * SCALE);
vm.startPrank(JUNIOR_LP);
settlementToken.approve(address(juniorVault), 2_000e6 * SCALE);
uint256 jid = juniorVault.requestDeposit(2_000e6 * SCALE, JUNIOR_LP);
vm.stopPrank();
if (vm.getBlockTimestamp() < pool.lpEpochStart(jid)) vm.warp(pool.lpEpochStart(jid));
bytes[] memory tick = _mark(1e8);
vm.prank(KEEPER);
router.settleLpEpoch(tick);
vm.prank(JUNIOR_LP);
juniorVault.claimDeposit(jid, 2_000e6 * SCALE, JUNIOR_LP, JUNIOR_LP);
// With 1 USDG permanent seeds, Senior capacity opens only after Junior activation.
settlementToken.mint(SENIOR_LP, 1_600e6 * SCALE);
vm.startPrank(SENIOR_LP);
settlementToken.approve(address(seniorVault), 1_600e6 * SCALE);
uint256 sid = seniorVault.requestDeposit(1_600e6 * SCALE, SENIOR_LP);
vm.stopPrank();
settlementToken.mint(SECOND_SENIOR, 400e6 * SCALE);
vm.startPrank(SECOND_SENIOR);
settlementToken.approve(address(seniorVault), 400e6 * SCALE);
uint256 bid = seniorVault.requestDeposit(400e6 * SCALE, SECOND_SENIOR);
vm.stopPrank();
assertEq(bid, sid, "independent B funds same Senior epoch");
if (vm.getBlockTimestamp() < pool.lpEpochStart(sid)) vm.warp(pool.lpEpochStart(sid));
tick = _mark(1e8);
vm.prank(KEEPER);
router.settleLpEpoch(tick);
vm.prank(SENIOR_LP);
seniorVault.claimDeposit(sid, 1_600e6 * SCALE, SENIOR_LP, SENIOR_LP);
vm.prank(SECOND_SENIOR);
seniorVault.claimDeposit(bid, 400e6 * SCALE, SECOND_SENIOR, SECOND_SENIOR);
assertGt(seniorVault.balanceOf(SECOND_SENIOR), 0, "B buys Senior shares with own USDG");
emit log_named_uint("B_SELF_FUNDED_SHARES", seniorVault.balanceOf(SECOND_SENIOR));
emit log_named_uint("A_START_SENIOR_SHARES", seniorVault.balanceOf(SENIOR_LP));
emit log_named_uint("OWNER_START_JUNIOR_SHARES", juniorVault.balanceOf(address(this)));
emit log_named_uint("OWNER_START_SENIOR_SHARES", seniorVault.balanceOf(address(this)));
vm.warp(vm.getBlockTimestamp() + 3601);
// The common seed adds 3,000,000 USDG of owner recapitalization before the wipeout.
settlementToken.mint(address(this), P);
settlementToken.approve(address(engine), P);
engine.recapitalizePool(P);
uint256 juniorShares = juniorVault.balanceOf(JUNIOR_LP);
uint256 firstRedeemShares = juniorShares * 3 / 5;
if (shareDelta < 0) firstRedeemShares -= uint256(-shareDelta);
else firstRedeemShares += uint256(shareDelta);
emit log_named_uint("FIRST_REDEEM_REQUEST_SHARES", firstRedeemShares);
vm.prank(JUNIOR_LP);
uint256 firstId = juniorVault.requestRedeem(firstRedeemShares, JUNIOR_LP, JUNIOR_LP);
if (vm.getBlockTimestamp() < pool.lpEpochStart(firstId)) vm.warp(pool.lpEpochStart(firstId));
tick = _mark(1e8);
vm.prank(KEEPER);
router.settleLpEpoch(tick);
uint256 firstClaimable = juniorVault.claimableRedeemRequest(firstId, JUNIOR_LP);
uint256 firstPaid;
if (firstClaimable > 0) {
vm.prank(JUNIOR_LP);
firstPaid = juniorVault.claimRedeem(firstId, firstClaimable, JUNIOR_LP, JUNIOR_LP);
}
emit log_named_uint("FIRST_REDEEM_PAID", firstPaid);
emit log_named_uint("A_JUNIOR_SHARES_AFTER_EARLY_REDEEM", juniorVault.balanceOf(JUNIOR_LP));
emit log_named_uint("A_JUNIOR_SHARE_BPS", juniorVault.balanceOf(JUNIOR_LP) * 10_000 / juniorVault.totalSupply());
emit log_named_uint("A_SENIOR_SHARE_BPS", seniorVault.balanceOf(SENIOR_LP) * 10_000 / seniorVault.totalSupply());
_fundTrader(TRADER, 5_000e6 * SCALE);
_mark(HIGH);
for (uint256 i; i < 12; ++i) {
uint256 size = (pool.totalAssets() / 1e6 * 32 / 100 / 100) * 100e18;
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 funded-asset fraction used to reduce the high-water mark can exceed the fraction of Senior shares burned, because virtual-offset pricing lets the paid fraction differ from the burned-share fraction.
Impact
The surviving Senior holder's funded payout falls by about 6,667 USDG while the attacker's wallets rise by a similar amount, though the main example needs an Owner recapitalisation and an excess-admission call, and the auxiliary check still needs the recapitalisation.
What the attacker needed
Attacker holds large Senior and Junior shares; Owner recapitalises pool before the loss; Owner admits excess via accountExcess(); synthetic oracle price sequence
The fix
The high-water-mark reduction should preserve the recovery entitlement attached to surviving Senior shares when virtual-offset pricing makes the paid fraction differ from the burned-share fraction.
How it was found
- Fund Senior and Junior positions, with an unrelated Senior holder also depositing, and have the Owner recapitalise the pool before loss-making trades wipe principal.
- Transfer a tiny amount to the Pool and have the Owner admit it as excess so principal is near zero while the high-water mark stays large.
- Have the attacker redeem Senior shares first, receiving most of the tiny principal while burning only part of the shares.
- Have an unrelated trader make the same loss-producing round trips in both branches so the Pool receives identical recovery cash.
- Redeem the remaining LP shares in both branches and compare the surviving Senior holder's payout.
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 splits money between a safer Senior group and a riskier Junior group. Senior investors are meant to get their lost principal back first before Junior takes any surplus. The report shows that when one Senior investor leaves at a tiny price, the pool forgets more of the remaining Senior investors' claim to that recovery than it should, so later profits go to Junior instead of the Senior investor who stayed.
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.