A later Junior deposit overflows a shared epoch quote and freezes an earlier depositor
A later Junior deposit into the same epoch as an earlier large deposit causes the cumulative share quote to overflow uint256 after an hour of Senior coupon accrual, making settlement revert. The earlier depositor cannot cancel or claim their funds for at least 24 hours, and a queued Senior redemption remains unfunded.
- Disclosed after under an hour
#99237 [SC-High] A later Junior deposit overflows a shared epoch quote and freezes an earlier depositor
Submitted on Nov 12th 2026 at 14:42:08 UTC by @Tradi3 for Audit Competition | Plether
- Report ID: #99237
- Report Type: Smart Contract
- Report severity: High
- Target: https://github.com/immunefi-team/audit-comp-plether/blob/a82d4fefb02768e5b3bddcc97dee371eee24fea8/packages/perps/src/TrancheVault.sol
- Impacts:
- Temporary freezing of funds for at least 24 hours
Description
A later Junior deposit overflows a shared epoch quote and freezes an earlier depositor
Brief/Intro
After a long sequence of Junior deposits at positive near-zero principal inflates share supply, an honest 145,000 USDG Junior request is quotable, mintable, and settles at the next hourly maturity if left alone. An attacker deposits 3,000 USDG into the same epoch one minute later. Although the combined request also fits in uint256 before coupon accrual, the matured cumulative quote overflows after an hour of Senior coupon. At live-market times 24 and 25 hours after the victim request, the victim cannot cancel or claim its 145,000 USDG, settlement panics, and a queued Senior redemption remains unfunded. The Pool owner can cure this exact state with a direct 300 USDG donation and accountExcess.
Target: Plether commit a82d4fefb02768e5b3bddcc97dee371eee24fea8; Junior TrancheVault and HousePool. Claimed impact: High — Temporary freezing of funds for at least 24 hours.
Vulnerability Details
TrancheVault._requestDeposit accepts each request and transfers its USDG into vault escrow. Requests sharing an LP epoch form one cumulative deposit head. HousePool._settleDepositPhase calls quoteDepositFromState on that head at maturity. Its Math.mulDiv(netAssets, pricingSupply + VIRTUAL_SHARES, denominator) reverts with Panic(0x11) if the mathematical share count exceeds uint256.max. The revert rolls back the entire LP settlement, including Senior redemption funding earlier in the transaction. After maturity, TrancheVault.cancelPendingDeposit rejects the victim while projected Junior principal remains positive and the head is neither rejected nor terminally wiped. The victim can cancel during the pre-maturity window, which is roughly 59 minutes after the attacker joins in this PoC.
The inline PoC deploys the production OrderRouter, PletherOracle, HousePool, and TrancheVault from the pin, using the repository's six-feed Pyth mock. It makes no Router trade, price move, production-source edit, or contract storage write. It seeds 250,000 USDG Junior and 990,000 USDG Senior, makes two old-holder top-ups of 1,953.331200 and 651.110400 USDG to align a live weekday trough, then activates eighteen hourly, coupon-sized Junior recaps at positive near-zero principal. A final ordinary 300 USDG recap leaves projected Junior principal at 300.010000 USDG and Junior supply at 229307071750201518342593886530234804275025079401074690707712758025950705505 shares.
The honest 145,000 USDG victim request has a finite share estimate, and the test checks that the estimate plus existing supply fits in uint256. From the same snapshot with no attacker request, its next-hour settlement activates the victim deposit and partially funds a 10,000 USDG Senior redemption, making a nonzero claim available. The attacker then joins the victim's epoch for 3,000 USDG. The combined pre-coupon quote also fits in uint256 together with existing supply. At the next hourly maturity the cumulative quote panics instead. A separate control from the state before the final recap substitutes a coupon-sized recap for 300 USDG; Junior reaches zero by 24 hours, a nonzero Senior claim becomes available, and the victim receives a full refund.
Impact Details
At 2027-06-04 05:00 UTC, exactly 24 hours after the victim request, the market is live and projected Junior principal is still 27.613512 USDG. settleLpEpoch reverts with Panic(0x11); the victim's cancelPendingDeposit reverts with TrancheVault__DepositEpochAlreadyActive; 145,000 USDG victim and 3,000 USDG attacker deposits remain in escrow; the Senior claim is zero. At +25 hours in a live market, Junior principal is still 16.263658 USDG and settlement and cancellation still revert. The attacker has tied up 3,000 USDG in the last request; this is not a measured net loss.
The owner-only HousePool.accountExcess() is a tested rescue. A direct 300 USDG transfer followed by that call at +25 hours raises projected Junior principal to 316.263658 USDG without minting shares. Ordinary settlement then succeeds; both deposits become claimable and the Senior redemption is partially funded. A direct transfer alone is unaccounted until the owner acts. The victim cannot make this owner-only call or cancel the active request.
The setup advances 100,645,200 seconds (1,164.875 days, about 3.19 years) from the fixture's March 2024 seed to the final recap and assumes little intervening LP activity. The 3,000 USDG late request is a conditional grief action once this share-supply state exists; it cannot create the state from a fresh Pool. The combined pre-coupon quote is about 97.75% of uint256.max, so changes in liquidity or timing matter. The PoC establishes the freeze in this state, not that the live deployment already has it or that the setup can finish during this competition. The mocked token and oracle feeds, and Foundry time advancement, are local test facilities; no live transaction was executed.
References
- Pinned
HousePool._settleDepositPhase, including the cumulative quote call. - Pinned
TrancheVault.quoteDepositFromState. - Pinned
TrancheVault.cancelPendingDepositand projected terminal wipe condition. - Pinned owner-only
HousePool.accountExcess. - Plether competition scope.
Proof of Concept
Place the following three files in packages/perps/test/perps/codexvault/ of the pinned checkout a82d4fefb02768e5b3bddcc97dee371eee24fea8. They use the repository's existing BasePerpTest.sol and LegacyOrderRouterHarness.sol type; V1xFixture deploys actual new OrderRouter and only casts the reference to the inherited field type. Production PletherOracle is deployed directly. No production source file is edited.
From packages/perps, with Foundry v1.5.1 and the repository dependencies installed, run:
forge test --offline --no-auto-detect --match-path test/perps/codexvault/CodexVaultOrganicAggregate.t.sol --match-test test_CFR_OrganicAggregatePoison -vv
Observed at the pin: 1 passed, 0 failed. The test asserts victim-alone first-maturity activation, finite and mintable victim and combined quotes at request time, same-epoch attacker request, next-maturity Panic(0x11), live-market +24-hour and +25-hour lock with blocked cancellation, intact 145,000 USDG victim and 3,000 USDG attacker escrows, zero Senior claim, owner-only 300 USDG donation cure, and a refundable small-recap control.
V1xFixture.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 {EmergencyPauseCoordinator} from "@plether/perps/EmergencyPauseCoordinator.sol";
import {PletherOracle} from "@plether/perps/PletherOracle.sol";
import {ICfdEngineTypes} from "@plether/perps/interfaces/ICfdEngineTypes.sol";
import {IHousePool} from "@plether/perps/interfaces/IHousePool.sol";
import {IOrderRouterAdminHost} from "@plether/perps/interfaces/IOrderRouterAdminHost.sol";
import {OrderV3Types} from "@plether/perps/OrderV3Types.sol";
import {IOrderRouterAccounting} from "@plether/perps/interfaces/IOrderRouterAccounting.sol";
import {IPositionProtectionActions} from "@plether/perps/interfaces/IPositionProtectionActions.sol";
import {IPositionProtectionViews} from "@plether/perps/interfaces/IPositionProtectionViews.sol";
import {PositionProtectionTypes} from "@plether/perps/interfaces/PositionProtectionTypes.sol";
import {MarketCalendarLib} from "@plether/perps/libraries/MarketCalendarLib.sol";
import {MockPyth} from "@plether/test-utils/MockPyth.sol";
import {LegacyOrderRouterHarness} from "../../utils/LegacyOrderRouterHarness.sol";
import {CfdOrderPolicyEvaluator} from "@plether/perps/CfdOrderPolicyEvaluator.sol";
import {OrderRouterExecutionSidecar} from "@plether/perps/OrderRouterExecutionSidecar.sol";
import {OrderLifecycleBook} from "@plether/perps/OrderLifecycleBook.sol";
import {OrderRouterLiquidationBatchSidecar} from "@plether/perps/OrderRouterLiquidationBatchSidecar.sol";
import {OrderRouter} from "@plether/perps/OrderRouter.sol";
abstract contract V1xFixture is BasePerpTest {
/// @dev BasePerpTest's field is harness-typed; deployed code here is production OrderRouter.
function _deployLegacyOrderRouter(
address engine_, address engineLens_, address pool_, address oracle_
) internal override returns (LegacyOrderRouterHarness deployedRouter) {
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 productionRouter = new OrderRouter(
engine_, engineLens_, pool_, oracle_, address(keeperSidecar), address(policyEvaluator),
address(orderExecutionSidecar), address(lifecycleBook)
);
assertEq(address(productionRouter), predictedRouter);
deployedRouter = LegacyOrderRouterHarness(address(productionRouter));
}
address internal constant RP1_GUARDIAN = address(0x6A27);
address internal constant RP1_KEEPER = address(0xE27C);
address internal constant RP1_RECIPIENT = address(0x27ACE);
address internal constant ALICE = address(0xA11CE);
address internal constant BOB = address(0xB0B);
address internal constant CAROL = address(0xCA201);
address internal constant DAVE = address(0xDA7E);
address internal constant TRADER = address(0x7A0E2);
address internal constant RP1_LP = address(0x1D27);
EmergencyPauseCoordinator internal coordinator;
function _riskParams() internal pure override returns (CfdTypes.RiskParams memory) {
return CfdTypes.RiskParams({
vpiFactor: 0.01e18,
maxSkewRatio: 0.4e18,
maintMarginBps: 10,
initMarginBps: 20,
fadMarginBps: 300,
baseCarryBps: 500,
minBountyAssets: 1e6,
bountyBps: 10,
keeperShareBps: 5000,
protocolShareBps: 0
});
}
function _initialJuniorSeedDeposit() internal pure override returns (uint256) {
return 1e6;
}
function _initialSeniorSeedDeposit() internal pure override returns (uint256) {
return 1e6;
}
function _initialJuniorDeposit() internal pure override returns (uint256) {
return 0;
}
function _initialSeniorDeposit() internal pure override returns (uint256) {
return 0;
}
function _releaseFeedIds() internal pure returns (bytes32[] memory ids) {
ids = new bytes32[](6);
ids[0] = 0xa995d00bb36a63cef7fd2c287dc105fc8f3d93779f062f09551b0af3e81ec30b;
ids[1] = 0xef2c98c804ba503c6a707e38be4dfbb16683775f195b091252bf24693042fd52;
ids[2] = 0x84c2dde9633d93d1bcad84e7dc41c9d56578b7ec52fabedc1f335d673df0a7c1;
ids[3] = 0x3112b03a41c910ed446852aacf67118cb1bec67b2cd0b9a214c58cc0eaa2ecca;
ids[4] = 0x8ccb376aa871517e807358d4e3cf0bc7fe4950474dbe6c9ffc21ef64e43fc676;
ids[5] = 0x0b1e3297e69f162877b577b0d6a47a0d63b2392bc8499e6540da4187a63e28f8;
}
function _releaseWeights() internal pure returns (uint256[] memory weights) {
weights = new uint256[](6);
weights[0] = 576e15;
weights[1] = 136e15;
weights[2] = 119e15;
weights[3] = 91e15;
weights[4] = 42e15;
weights[5] = 36e15;
}
function _releaseBasePrices() internal pure returns (uint256[] memory prices) {
prices = new uint256[](6);
prices[0] = 117_500_000;
prices[1] = 638_000;
prices[2] = 134_480_000;
prices[3] = 72_880_000;
prices[4] = 10_860_000;
prices[5] = 126_100_000;
}
function _releaseInversions() internal pure returns (bool[] memory inversions) {
inversions = new bool[](6);
inversions[1] = true;
inversions[3] = true;
inversions[4] = true;
inversions[5] = true;
}
function setUp() public virtual override {
super.setUp();
IHousePool.PoolConfig memory poolConfig = _currentPoolConfig();
poolConfig.maxSeniorExposureAssets = 40_000_000e6;
poolConfig.maxSeniorShareBps = 8000;
pool.proposePoolConfig(poolConfig);
_warpChecked(pool.poolConfigActivationTime());
pool.finalizePoolConfig();
IOrderRouterAdminHost.RouterConfig memory routerConfig = _routerConfig();
routerConfig.minOpenNotionalAssets = 1000e6;
routerConfig.adverseConfidenceMultiplierBps = 2500;
routerAdmin.proposeRouterConfig(routerConfig);
_warpChecked(routerAdmin.routerConfigActivationTime());
routerAdmin.finalizeRouterConfig();
juniorVault.proposeMaintenanceFeeConfig(0, PROTOCOL_TREASURY_ACCOUNT);
_warpChecked(juniorVault.maintenanceFeeConfigActivationTime());
juniorVault.finalizeMaintenanceFeeConfig();
PletherOracle releaseOracle = new PletherOracle(
address(engine),
address(pool),
address(baseMockPyth),
_releaseFeedIds(),
_releaseWeights(),
_releaseBasePrices(),
_releaseInversions()
);
routerAdmin.proposeOracleConfig(IOrderRouterAdminHost.OracleConfig(address(releaseOracle)));
_warpChecked(routerAdmin.oracleConfigActivationTime());
routerAdmin.finalizeOracleConfig();
pletherOracle = releaseOracle;
_warpChecked(SETUP_TIMESTAMP + 21 days);
_stageReleaseData(1e8, vm.getBlockTimestamp(), vm.getBlockTimestamp() - 1);
router.updateMarkPrice(_releaseData(1e8, vm.getBlockTimestamp(), vm.getBlockTimestamp() - 1));
coordinator = new EmergencyPauseCoordinator(address(routerAdmin), address(pool), address(this));
coordinator.setGuardian(RP1_GUARDIAN);
routerAdmin.setPauser(address(coordinator));
pool.setPauser(address(coordinator));
baseMockPyth.setFee(0);
rp1Actions = IPositionProtectionActions(address(router.positionProtectionBook()));
rp1Views = IPositionProtectionViews(address(router.positionProtectionBook()));
_assertReleaseConfig();
assertApproxEqAbs(engine.lastMarkPrice(), 1e8, 1e4, "release basket must price near 1.00, not CAP");
}
function _warpChecked(uint256 timestamp) internal {
require(timestamp >= vm.getBlockTimestamp(), "RP1 backwards warp");
vm.warp(timestamp);
assertEq(vm.getBlockTimestamp(), timestamp, "RP1 warp must survive via-IR");
}
function _rollNextBlock() internal {
uint256 nextBlock = vm.getBlockNumber() + 1;
vm.roll(nextBlock);
assertEq(vm.getBlockNumber(), nextBlock, "RP1 roll must survive via-IR");
}
function _componentPrice(uint256 indexPrice, uint256 basePrice) internal pure returns (int64) {
return int64(uint64((basePrice * indexPrice) / 1e8));
}
/// @dev Inverted release feeds publish USD/XXX; the oracle inverts them back to XXX/USD before normalization.
function _rawComponentPrice(uint256 indexPrice, uint256 i) internal pure returns (int64) {
uint256 normalized = (_releaseBasePrices()[i] * indexPrice) / 1e8;
if (_releaseInversions()[i]) {
return int64(uint64((1e16 + normalized / 2) / normalized));
}
return int64(uint64(normalized));
}
function _stageReleaseData(
uint256 indexPrice,
uint256 publishTime,
uint256 previousPublishTime
) internal returns (bytes[] memory data) {
data = _releaseData(indexPrice, publishTime, previousPublishTime);
bytes32[] memory ids = _releaseFeedIds();
uint256[] memory bases = _releaseBasePrices();
for (uint256 i; i < ids.length; ++i) {
baseMockPyth.setPrice(ids[i], _rawComponentPrice(indexPrice, i), int32(-8), publishTime);
}
}
function _releaseData(
uint256 indexPrice,
uint256 publishTime,
uint256 previousPublishTime
) internal view returns (bytes[] memory data) {
bytes32[] memory ids = _releaseFeedIds();
uint256[] memory bases = _releaseBasePrices();
MockPyth.FeedUpdate[] memory updates = new MockPyth.FeedUpdate[](ids.length);
for (uint256 i; i < ids.length; ++i) {
updates[i] = MockPyth.FeedUpdate(
ids[i],
MockPyth.MockPrice(
_rawComponentPrice(indexPrice, i), 0, -8, publishTime, previousPublishTime
)
);
}
data = new bytes[](1);
data[0] = abi.encode(updates);
}
function _executionData(uint256 indexPrice) internal returns (bytes[] memory data) {
_rollNextBlock();
_warpChecked(vm.getBlockTimestamp() + 1);
uint256 publishTime = _mockHistoricalPublishTime();
return _stageReleaseData(indexPrice, publishTime, publishTime - 1);
}
function _liveData(uint256 indexPrice) internal returns (bytes[] memory data) {
uint256 timestamp = vm.getBlockTimestamp();
if (timestamp <= engine.lastMarkTime()) {
timestamp = uint256(engine.lastMarkTime()) + 1;
}
_warpChecked(timestamp);
_rollNextBlock();
uint256 previous = engine.lastMarkTime();
if (previous == timestamp) {
previous = timestamp - 1;
}
return _stageReleaseData(indexPrice, timestamp, previous);
}
function _settlementData(uint256 indexPrice) internal returns (bytes[] memory data) {
uint256 timestamp = vm.getBlockTimestamp();
uint256 previous = engine.lastMarkTime();
if (previous >= timestamp) {
previous = timestamp - 1;
}
return _stageReleaseData(indexPrice, timestamp, previous);
}
function _commitOpenReal(
address account,
CfdTypes.Side side,
uint256 size,
uint256 margin
) internal returns (uint64 orderId) {
orderId = _commitV3(account, side, size, margin, false);
}
function _commitCloseReal(
address account,
CfdTypes.Side side,
uint256 size
) internal returns (uint64 orderId) {
orderId = _commitV3(account, side, size, 0, true);
}
uint256 internal v3ClientNonce;
function _commitV3(
address account, CfdTypes.Side side, uint256 size, uint256 margin, bool isClose
) internal returns (uint64 orderId) {
uint256 targetPrice = (side == CfdTypes.Side.LONG) == isClose ? 2e8 : 1;
uint32 window = uint32(router.maxExecutionWindowSeconds());
OrderV3Types.OrderRequest memory request = OrderV3Types.OrderRequest({
clientOrderId: keccak256(abi.encode("vault-overflow", account, ++v3ClientNonce)),
side: side,
sizeDelta: size,
marginDelta: margin,
targetPrice: targetPrice,
isClose: isClose,
bounds: OrderV3Types.ExecutionBounds({
submitBy: uint64(vm.getBlockTimestamp()) + window,
executionWindowSeconds: window,
allowedExecutionModes: 1,
expectedConfigHash: router.lifecycleBook().currentExecutionConfigHash(),
maxExecutionBountyAssets: 100e6,
maxExecutionNotionalAssets: 10_000_000e6,
maxGrossAccountDebitAssets: 1_000_000e6,
maxActionChargeAssets: 1_000_000e6,
maxExplicitFeesAssets: 100_000e6,
maxPostPositionSize: 10_000_000e18,
minPostSettlementBalanceAssets: 0,
minPostPositionEquityAssets: 0,
maxPostLeverageBps: 1_000_000
})
});
vm.prank(account);
orderId = router.commitOrder(request);
}
function _executeReal(uint64 orderId, uint256 indexPrice) internal returns (OrderV3Types.ExecutionResult memory result) {
result = router.executeOrder(orderId, _executionDataFor(orderId, indexPrice));
if (result.status != OrderV3Types.LifecycleStatus.Executed) {
emit log_named_uint("RP1 terminalReason", uint256(result.terminalReason));
}
}
function _executionDataFor(uint64 orderId, uint256 indexPrice) internal returns (bytes[] memory data) {
_rollNextBlock();
_warpChecked(vm.getBlockTimestamp() + 1);
uint256 publishTime = vm.getBlockTimestamp();
(IOrderRouterAccounting.PendingOrderView memory pending,) = router.getPendingOrderView(orderId);
if (pending.orderId != 0 && uint256(pending.commitTime) + 1 <= publishTime) {
publishTime = uint256(pending.commitTime) + 1;
}
return _stageReleaseData(indexPrice, publishTime, publishTime - 1);
}
function _openReal(
address account,
CfdTypes.Side side,
uint256 size,
uint256 margin
) internal returns (uint64 orderId) {
orderId = _commitOpenReal(account, side, size, margin);
OrderV3Types.ExecutionResult memory result = _executeReal(orderId, 1e8);
assertEq(uint8(result.status), uint8(OrderV3Types.LifecycleStatus.Executed), "real open must execute");
}
function _closeReal(
address account,
CfdTypes.Side side,
uint256 size,
uint256 indexPrice
) internal returns (uint64 orderId) {
orderId = _commitCloseReal(account, side, size);
OrderV3Types.ExecutionResult memory result = _executeReal(orderId, indexPrice);
assertEq(uint8(result.status), uint8(OrderV3Types.LifecycleStatus.Executed), "real close must execute");
}
function _positionSize(address account) internal view returns (uint256 size) {
(size,,,,,,) = engine.positions(account);
}
function _baseLp() internal returns (uint256 shares) {
return _seedJuniorLp(RP1_LP, 1_000_000e6);
}
function _seedJuniorLp(address owner, uint256 assets) internal returns (uint256 shares) {
uint256 requestId = _requestJuniorDeposit(owner, assets);
_settleReal(requestId);
return _claimJuniorDeposit(requestId, owner);
}
function _requestJuniorDeposit(address owner, uint256 assets) internal returns (uint256 requestId) {
settlementToken.mint(owner, assets);
vm.startPrank(owner);
settlementToken.approve(address(juniorVault), assets);
requestId = juniorVault.requestDeposit(assets, owner, owner);
vm.stopPrank();
}
function _claimJuniorDeposit(uint256 requestId, address controller) internal returns (uint256 shares) {
uint256 assets = juniorVault.claimableDepositRequest(requestId, controller);
assertGt(assets, 0, "claimable junior deposit required");
vm.prank(controller);
shares = juniorVault.claimDeposit(requestId, assets, controller, controller);
}
function _requestJuniorRedeem(address owner, uint256 shares) internal returns (uint256 requestId) {
vm.prank(owner);
requestId = juniorVault.requestRedeem(shares, owner, owner);
}
function _requestSeniorDepositReal(address owner, uint256 assets) internal returns (uint256 requestId) {
settlementToken.mint(owner, assets);
vm.startPrank(owner);
settlementToken.approve(address(seniorVault), assets);
requestId = seniorVault.requestDeposit(assets, owner, owner);
vm.stopPrank();
}
function _settleReal(uint256 requestId) internal returns (IHousePool.LpEpochSettlementResult memory result) {
uint256 timestamp = pool.lpEpochStart(requestId);
if (vm.getBlockTimestamp() < timestamp) {
_warpChecked(timestamp);
}
ICfdEngineTypes.TerminalNavSnapshot memory snapshot = engine.terminalNavSnapshot();
if (!snapshot.hasOpenPositions || engine.isOracleFrozen()) {
return pool.settleLpEpoch(0, 0);
}
uint256 indexPrice = snapshot.markPrice == 0 ? 1e8 : snapshot.markPrice;
router.settleLpEpoch(_settlementData(indexPrice));
return result;
}
function _claimRedeemReal(uint256 requestId, address controller) internal returns (uint256 assets) {
uint256 shares = juniorVault.claimableRedeemRequest(requestId, controller);
assertGt(shares, 0, "funded redemption shares required");
vm.prank(controller);
assets = juniorVault.claimRedeem(requestId, shares, controller, controller);
assertGt(assets, 0, "funded redemption assets required");
}
// ------------------------------------------------------------------
// rp1 additions: V3 requests, protections, batches, LP helpers, probes
// ------------------------------------------------------------------
address internal constant EVE = address(0xE7E);
address internal constant SENIOR_LP = address(0x5E11);
bytes32 internal constant RP1_REASON = keccak256("rp1 incident");
IPositionProtectionActions internal rp1Actions;
IPositionProtectionViews internal rp1Views;
/// @dev Cached in setUp so a preceding `vm.prank` is not consumed by the `positionProtectionBook()` view call.
function _actions() internal view returns (IPositionProtectionActions) {
return rp1Actions;
}
function _views() internal view returns (IPositionProtectionViews) {
return rp1Views;
}
function _v3Request(
CfdTypes.Side side,
uint256 size,
uint256 margin,
uint256 target,
bool isClose
) internal view returns (OrderV3Types.OrderRequest memory request) {
request.clientOrderId = bytes32(uint256(router.nextCommitId()));
request.side = side;
request.sizeDelta = size;
request.marginDelta = margin;
request.targetPrice = target;
request.isClose = isClose;
request.bounds = OrderV3Types.ExecutionBounds({
submitBy: uint64(vm.getBlockTimestamp()) + uint64(router.maxExecutionWindowSeconds()),
executionWindowSeconds: uint32(router.maxExecutionWindowSeconds()),
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 _protectionParams(uint256 tp, uint256 sl)
internal
pure
returns (PositionProtectionTypes.PositionProtectionParams memory params)
{
params.takeProfitTriggerPrice = tp;
params.stopLossTriggerPrice = sl;
params.closeLimits = PositionProtectionTypes.CloseFinancialLimits({
maxExecutionNotionalAssets: type(uint256).max,
maxGrossAccountDebitAssets: type(uint256).max,
maxActionChargeAssets: type(uint256).max,
maxExplicitFeesAssets: type(uint256).max
});
}
/// @dev LONG profits when the basket falls: TP 0.5% below the mark, SL 0.5% above. SHORT mirrored.
function _defaultTpSl(CfdTypes.Side side, uint256 mark) internal pure returns (uint256 tp, uint256 sl) {
if (side == CfdTypes.Side.LONG) {
return (mark * 995 / 1000, mark * 1005 / 1000);
}
return (mark * 1005 / 1000, mark * 995 / 1000);
}
function _commitProtectedOpen(
address account,
CfdTypes.Side side,
uint256 size,
uint256 margin,
uint256 mark
) internal returns (uint64 orderId, uint64 protectionId) {
(uint256 tp, uint256 sl) = _defaultTpSl(side, mark);
OrderV3Types.OrderRequest memory request = _v3Request(side, size, margin, side == CfdTypes.Side.LONG ? 1 : 2e8, false);
vm.prank(account);
(orderId, protectionId) = _actions().commitOpenOrderWithProtection(request, _protectionParams(tp, sl));
}
function _createProtection(address account, CfdTypes.Side side, uint256 mark) internal returns (uint64 protecti
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 share quote uses a multiplication that can exceed the maximum integer size when many near-zero-principal deposits inflate the share supply, and the code does not cap or reject the overflowing cumulative request.
Impact
The victim's 145,000 USDG and the attacker's 3,000 USDG remain stuck in escrow for at least 24 hours, settlement reverts, and a queued Senior redemption stays unfunded; the owner can cure the state with a 300 USDG donation and accountExcess call.
What the attacker needed
A long sequence of Junior deposits inflates share supply; attacker can deposit into the same epoch; victim has a pending Junior deposit; owner intervention needed to cure
The fix
The code should prevent the cumulative share quote from overflowing, for example by capping or rejecting requests whose combined quote would exceed uint256.max, or by using a wider arithmetic type.
How it was found
- Seed the Junior and Senior tranches and perform top-ups to align a live weekday trough.
- Activate eighteen hourly coupon-sized Junior recaps at positive near-zero principal, then a final ordinary 300 USDG recap.
- Submit an honest 145,000 USDG Junior deposit request and verify its quote is finite and mintable.
- One minute later, deposit 3,000 USDG into the same epoch as the victim.
- At the next hourly maturity, observe that settlement reverts with Panic(0x11).
- At +24 and +25 hours in a live market, confirm the victim cannot cancel or claim and the Senior claim is zero.
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 vault combines several deposit requests made in the same time window and calculates how many shares they should receive all at once. If that combined calculation produces a number too large for the computer to store, the whole settlement fails and everyone's deposits stay stuck. The attacker only needs to add a small deposit to push the total over that limit.
What is DoS?
A request that exhausts resources or crashes a component. Many programs forbid testing it; reports usually show it from code, not by attacking.