Oracle rotation resets accepted feed timestamps and permits a forced liquidation
After a legitimate oracle rotation, the replacement oracle forgets which Pyth feed timestamps the old oracle had already accepted, so a still-fresh but older signed price component can be replayed. A keeper can then use that higher-confidence older component to push a near-maintenance trader's liquidation price above the maintenance threshold and force a liquidation, taking a bounty from the trader's collateral.
- Disclosed after under an hour
#99687 [SC-Critical] Oracle rotation resets accepted feed timestamps and permits a forced liquidation
Submitted on Nov 14th 2026 at 19:58:41 UTC by @Ailenia for Audit Competition | Plether
- Report ID: #99687
- Report Type: Smart Contract
- Report severity: Critical
- Target: https://github.com/immunefi-team/audit-comp-plether/tree/a82d4fefb02768e5b3bddcc97dee371eee24fea8/packages/perps/src
- Impacts:
- Direct theft of any user funds, whether at-rest or in-motion, other than unclaimed yield
Description
Impact: Direct theft of any user funds, whether at-rest or in-motion, other than unclaimed yield.
Summary
I can force-liquidate a near-maintenance trader immediately after a legitimate Oracle rotation by replaying a still-fresh Pyth component that the old Oracle already rejected. The rotation resets accepted feed timestamps. My PoC first proves the older component was harmless when it was accepted and when it was last admissible on the old Oracle. A small later price change makes it harmful, but only the replacement Oracle admits it. The neutral basket mark stays unchanged between attack and control, while the older component's higher confidence raises the adverse liquidation price and pays the keeper a 499.996725 USDG bounty from the trader's collateral.
Root cause
I found that the live Oracle records each accepted Pyth component's publish time and rejects a component older than its last accepted value, but this protection disappears during the supported 72-hour Oracle rotation. OrderLiquidationBatchLogic.applyOracleConfig copies the active pricing policy without carrying forward the accepted component timestamps. OrderRouter.applyOracleConfig then installs the fresh Oracle with zero component watermarks. The next permissionless keeper can submit a still-fresh signed component older than one the old Oracle already accepted on-chain.
The neutral basket's aggregate price and publish time can remain identical in both reports, so the equal-time mark guard does not catch the rewind. Confidence is not bound to that equal-time guard. For a long position, PletherOracle adds 25% of aggregate confidence to the liquidation price. A higher-confidence older component can therefore turn a solvent position into a liquidatable one after rotation. The first faulty transition is the Router's installation of the replacement Oracle without preserving the active Oracle's accepted-feed state or enforcing a predecessor watermark.
Reproduction
- Fund Junior with a 10,000,000 USDG deposit and open the target's 1,000,000-unit long with 4,000.6 USDG margin through public V3 calls under the release risk settings. During an already proposed, mature Oracle rotation, track the EUR/USD move with four public mark updates spaced 15 minutes apart while the position remains solvent.
- At
T-1, the old Oracle accepts a complete higher-confidence report with EUR/USD at 1.17721370. A public liquidation reverts as solvent both then and atT, before the older component is superseded. AtT, accept a lower-confidence second component at the same EUR/USD price. AtT+1, accept another lower-confidence report with EUR/USD at 1.17721470, only about 0.0085 bp higher. The old Oracle rejects a public liquidation call with the higher-confidenceT-1second component and currentT+1other feeds withPletherOracle__FeedTimeOutOfOrder. - The owner finalizes the timelocked rotation. The new Oracle has a zero accepted timestamp for that component. From the same post-rotation state, the current report gives a 1.00109222 liquidation price and leaves the trader solvent. The mixed older report gives a 1.00109280 liquidation price, above the measured 1.00109251 maintenance threshold, and lets a permissionless keeper liquidate through
OrderRouter.executeLiquidation. Both reports have the same neutral basket mark and basket timestamp.
The local Pyth mock supplies complete reports with the stated times and confidence values, and they meet the release freshness, divergence, and aggregate-confidence limits. Baseline confidence ratios are scaled from a checked-in six-feed Pyth update fixture. A separate checked-in signed Pyth fixture contains adjacent-second GBP/USD and USD/SEK updates with unchanged prices but higher older confidence; combining their intact older proofs with four newer feed proofs yields the same neutral basket mark and a 58-tick higher liquidation price under release weights. The Junior deposit uses public request, epoch-settlement, and claim calls. The owner performs documented release configuration and rotation; the adversarial report choice and liquidation are permissionless.
The economic PoC models the roughly 18.85-bp EUR/USD movement over one hour with accepted marks every 15 minutes; the final two-second step is about 0.0085 bp. This market path and a legitimate owner rotation are prerequisites; the keeper does not control them. The signed fork sample demonstrates the watermark reset with real Pyth proofs, but its sampled position is not close enough to maintenance to liquidate.
Impact and accounting
My PoC starts both outcomes from one snapshot. In the control, the lower-confidence report cannot liquidate, and the trader closes through a public V3 order one second later with 8,100.027395 USDG left in the margin account. In the attack, liquidation at that same one-second-later execution time leaves 6,999.997362 USDG. The measured trader-balance difference between those complete branches is 1,100.030033 USDG: 499.996725 USDG credited to the keeper, 600.033308 USDG added to Pool cash and Junior LP assets, and 0 to the treasury. This branch comparison includes the control close's charges and the one second elapsed in both branches; it is the exact outcome for those public paths, not a decomposition of the confidence shift alone. The PoC checks the Clearinghouse and Pool token movements against their accounted balances, unchanged token supply and LP shares, and no hidden trader claim. The keeper withdraws its bounty; the trader can withdraw only the residual balance. The forced liquidation cannot be reversed by a later fresh price update.
This bypasses the accepted-component monotonicity mitigation described in the published MED-7 response. The higher-confidence component was accepted on-chain while it was harmless, and public liquidation was still solvent immediately before the lower-confidence successor superseded it. The small later EUR/USD step first makes the harmful mixed report possible after the old Oracle's timestamp floor has already advanced. The old Oracle explicitly rejects that mix; only rotation makes it admissible. MED-13 concerns changed protection thresholds under a semantically different Oracle; my PoC rotates to an identical Oracle and targets liquidation. The published MED-18 equal-time mark fix also remains active: the two marks are equal, while confidence-dependent liquidation prices differ.
Remediation
Before installing a replacement Oracle, carry forward the active per-feed accepted timestamps and accepted basket state for matching feeds, or enforce the active Oracle's accepted-feed timestamps as a Router-level floor across rotations. Reject a rotation that cannot preserve that floor while live positions can be liquidated. Bind equal-time confidence-dependent prices to a consistent accepted basket when deciding liquidation.
Link to Proof of Concept
https://gist.github.com/niafreu/324af5f3f0d3f00941d181b5b30814a8
Proof of Concept
Step-by-step reproduction
- Fund Junior with a 10,000,000 USDG deposit and open the target's 1,000,000-unit long with 4,000.6 USDG margin through public V3 calls under the release risk settings. During an already proposed, mature Oracle rotation, track the EUR/USD move with four public mark updates spaced 15 minutes apart while the position remains solvent.
- At
T-1, the old Oracle accepts a complete higher-confidence report with EUR/USD at 1.17721370. A public liquidation reverts as solvent both then and atT, before the older component is superseded. AtT, accept a lower-confidence second component at the same EUR/USD price. AtT+1, accept another lower-confidence report with EUR/USD at 1.17721470, only about 0.0085 bp higher. The old Oracle rejects a public liquidation call with the higher-confidenceT-1second component and currentT+1other feeds withPletherOracle__FeedTimeOutOfOrder. - The owner finalizes the timelocked rotation. The new Oracle has a zero accepted timestamp for that component. From the same post-rotation state, the current report gives a 1.00109222 liquidation price and leaves the trader solvent. The mixed older report gives a 1.00109280 liquidation price, above the measured 1.00109251 maintenance threshold, and lets a permissionless keeper liquidate through
OrderRouter.executeLiquidation. Both reports have the same neutral basket mark and basket timestamp.
The local Pyth mock supplies complete reports with the stated times and confidence values, and they meet the release freshness, divergence, and aggregate-confidence limits. Baseline confidence ratios are scaled from a checked-in six-feed Pyth update fixture. A separate checked-in signed Pyth fixture contains adjacent-second GBP/USD and USD/SEK updates with unchanged prices but higher older confidence; combining their intact older proofs with four newer feed proofs yields the same neutral basket mark and a 58-tick higher liquidation price under release weights. The Junior deposit uses public request, epoch-settlement, and claim calls. The owner performs documented release configuration and rotation; the adversarial report choice and liquidation are permissionless.
The economic PoC models the roughly 18.85-bp EUR/USD movement over one hour with accepted marks every 15 minutes; the final two-second step is about 0.0085 bp. This market path and a legitimate owner rotation are prerequisites; the keeper does not control them. The signed fork sample demonstrates the watermark reset with real Pyth proofs, but its sampled position is not close enough to maintenance to liquidate.
Runnable PoC
Secret PoC gist: https://gist.github.com/niafreu/324af5f3f0d3f00941d181b5b30814a8
The runnable Foundry test is in OracleRotationFeedRewind.t.sol. To reproduce from a clean directory with Foundry and Solc 0.8.35 available to Forge's offline compiler resolver, place the five gist files beside the pinned upstream checkout and run:
git clone --recurse-submodules https://github.com/immunefi-team/audit-comp-plether code
git -C code checkout a82d4fefb02768e5b3bddcc97dee371eee24fea8
git -C code submodule update --init --recursive
mkdir -p findings/oracle-rotation-feed-rewind
git clone https://gist.github.com/324af5f3f0d3f00941d181b5b30814a8.git findings/oracle-rotation-feed-rewind/PoC
bash findings/oracle-rotation-feed-rewind/PoC/run.sh
The runner copies the test into the pinned Foundry checkout without changing production contracts. The test uses public Router, admin, order, liquidation, and Clearinghouse calls. Its only mock is the out-of-scope Pyth endpoint and settlement token supplied by the repository fixture.
For an additional signed-Pyth integration check on the Arbitrum Sepolia fork, run bash findings/oracle-rotation-feed-rewind/PoC/run-fork.sh. The runner uses the documented public RPC unless ARB_SEPOLIA_RPC_URL is set. Its two tests parse intact signed proofs with the deployed Pyth contract and show the old Oracle rejecting a regressed feed while the replacement accepts it through public Router calls. The accepted mark is unchanged, and the source-derived adverse price rises 58 ticks. This fixture leaves the position solvent in both branches, so the economic loss measurement above comes from the deterministic public-call PoC.
Expected result: the current report leaves the trader solvent, the older mixed report liquidates, and the test measures 499.996725 USDG keeper credit, 600.033308 USDG Pool/Junior gain, and 1,100.030033 USDG trader loss against the same-state control.
Oracle rotation resets accepted feed timestamps and permits a forced liquidation
Context
Plether is a perps-style protocol whose pricing comes from Pyth price feeds. The in-scope code is the packages/perps/src tree of the audit competition repository, pinned at commit [redacted].
The live Oracle records the publish time of each accepted Pyth component and rejects a component older than the last accepted value for that feed. That monotonicity check is the defence against replaying an old, still-fresh signed price. The protocol also supports a 72-hour Oracle rotation, and the owner finalises a timelocked rotation in the PoC. The rotation is the feature that breaks the defence: the replacement Oracle starts with zero component watermarks, so a component the old Oracle had already accepted and then superseded becomes admissible again.
Setup
The PoC is a Foundry test, OracleRotationFeedRewind.t.sol, run against the pinned upstream checkout. The runner copies the test into the checkout without changing production contracts. The test uses public Router, admin, order, liquidation and Clearinghouse calls. Its only mock is the out-of-scope Pyth endpoint and settlement token supplied by the repository fixture.
Preconditions:
- A Junior deposit of 10,000,000 USDG, made through public request, epoch-settlement and claim calls.
- A target position: 1,000,000-unit long with 4,000.6 USDG margin, opened through public V3 calls under the release risk settings.
- An already proposed, mature Oracle rotation, which the owner finalises during the attack.
- A market path: roughly 18.85 bp of EUR/USD movement over one hour, with accepted marks every 15 minutes, ending in a two-second step of about 0.0085 bp.
The market path and the legitimate owner rotation are prerequisites; the keeper does not control them. The adversarial report choice and the liquidation itself are permissionless.
Finding it
The accepted-component timestamp floor is held in the live Oracle's state and is not carried across a rotation. OrderLiquidationBatchLogic.applyOracleConfig copies the active pricing policy without carrying forward the accepted component timestamps, and OrderRouter.applyOracleConfig then installs the fresh Oracle with zero component watermarks. The first faulty transition is the Router's installation of the replacement Oracle without preserving the active Oracle's accepted-feed state or enforcing a predecessor watermark.
That alone would be a replay window. What makes it profitable is confidence. The neutral basket's aggregate price and publish time can be identical in both reports, so the equal-time mark guard does not catch the rewind. Confidence is not bound to that equal-time guard. For a long position, PletherOracle adds 25% of aggregate confidence to the liquidation price. A higher-confidence older component therefore raises the liquidation price and can turn a solvent position into a liquidatable one after rotation.
Exploitation
Step 1: set up the position and the market path
Fund Junior with a 10,000,000 USDG deposit and open the target's 1,000,000-unit long with 4,000.6 USDG margin through public V3 calls under the release risk settings. During an already proposed, mature Oracle rotation, track the EUR/USD move with four public mark updates spaced 15 minutes apart while the position remains solvent.
The economic PoC models the roughly 18.85-bp EUR/USD movement over one hour with accepted marks every 15 minutes; the final two-second step is about 0.0085 bp.
Step 2: plant a higher-confidence component, then supersede it
At T-1, the old Oracle accepts a complete higher-confidence report with EUR/USD at 1.17721370. A public liquidation reverts as solvent both then and at T, before the older component is superseded. At T, accept a lower-confidence second component at the same EUR/USD price. At T+1, accept another lower-confidence report with EUR/USD at 1.17721470, only about 0.0085 bp higher.
The old Oracle rejects a public liquidation call with the higher-confidence T-1 second component and current T+1 other feeds with PletherOracle__FeedTimeOutOfOrder. This is the key control: while the old Oracle is live, the mix is not admissible, and the position is solvent both then and at T.
Step 3: rotate, then liquidate with the mixed report
The owner finalises the timelocked rotation. The new Oracle has a zero accepted timestamp for that component. From the same post-rotation state:
- The current report gives a 1.00109222 liquidation price and leaves the trader solvent.
- The mixed older report gives a 1.00109280 liquidation price, above the measured 1.00109251 maintenance threshold, and lets a permissionless keeper liquidate through
OrderRouter.executeLiquidation.
Both reports have the same neutral basket mark and basket timestamp, so the equal-time mark guard sees nothing wrong.
Supporting evidence
The local Pyth mock supplies complete reports with the stated times and confidence values, and they meet the release freshness, divergence and aggregate-confidence limits. Baseline confidence ratios are scaled from a checked-in six-feed Pyth update fixture.
A separate checked-in signed Pyth fixture contains adjacent-second GBP/USD and USD/SEK updates with unchanged prices but higher older confidence. Combining their intact older proofs with four newer feed proofs yields the same neutral basket mark and a 58-tick higher liquidation price under release weights. The signed fork sample demonstrates the watermark reset with real Pyth proofs, but its sampled position is not close enough to maintenance to liquidate.
Running the PoC
The runnable Foundry test is in OracleRotationFeedRewind.t.sol. To reproduce from a clean directory with Foundry and Solc 0.8.35 available to Forge's offline compiler resolver, place the five gist files beside the pinned upstream checkout and run:
git clone --recurse-submodules https://github.com/immunefi-team/audit-comp-plether code
git -C code checkout [redacted]
git -C code submodule update --init --recursive
mkdir -p findings/oracle-rotation-feed-rewind
git clone https://gist.github.com/[redacted].git findings/oracle-rotation-feed-rewind/PoC
bash findings/oracle-rotation-feed-rewind/PoC/run.sh
For an additional signed-Pyth integration check on the Arbitrum Sepolia fork, run:
bash findings/oracle-rotation-feed-rewind/PoC/run-fork.sh
The fork runner uses the documented public RPC unless ARB_SEPOLIA_RPC_URL is set. Its two tests parse intact signed proofs with the deployed Pyth contract and show the old Oracle rejecting a regressed feed while the replacement accepts it through public Router calls. The accepted mark is unchanged, and the source-derived adverse price rises 58 ticks. This fixture leaves the position solvent in both branches, so the economic loss measurement comes from the deterministic public-call PoC.
Expected result: the current report leaves the trader solvent, the older mixed report liquidates, and the test measures 499.996725 USDG keeper credit, 600.033308 USDG Pool/Junior gain, and 1,100.030033 USDG trader loss against the same-state control.
Root cause
The live Oracle records each accepted Pyth component's publish time and rejects a component older than its last accepted value. That protection disappears during the supported 72-hour Oracle rotation:
OrderLiquidationBatchLogic.applyOracleConfigcopies the active pricing policy without carrying forward the accepted component timestamps.OrderRouter.applyOracleConfiginstalls the fresh Oracle with zero component watermarks.
The next permissionless keeper can submit a still-fresh signed component older than one the old Oracle already accepted on-chain. The equal-time mark guard does not catch it because the neutral basket's aggregate price and publish time can remain identical in both reports. Confidence is not bound to that guard, and for a long position PletherOracle adds 25% of aggregate confidence to the liquidation price, so the higher-confidence older component moves the liquidation price above maintenance.
The report also explains why the published mitigations do not cover this:
- MED-7 (accepted-component monotonicity): bypassed. The higher-confidence component was accepted on-chain while it was harmless, and public liquidation was still solvent immediately before the lower-confidence successor superseded it. The small later EUR/USD step first makes the harmful mixed report possible after the old Oracle's timestamp floor has already advanced. The old Oracle explicitly rejects that mix; only rotation makes it admissible.
- MED-13 (changed protection thresholds under a semantically different Oracle): not applicable. The PoC rotates to an identical Oracle and targets liquidation.
- MED-18 (equal-time mark fix): still active but insufficient. The two marks are equal, while confidence-dependent liquidation prices differ.
Impact
The impact category is direct theft of user funds, whether at rest or in motion, other than unclaimed yield. A permissionless keeper can force-liquidate a near-maintenance trader immediately after a legitimate Oracle rotation, using a still-fresh Pyth component the old Oracle already rejected.
The PoC starts both outcomes from one snapshot:
| Branch | Outcome |
|---|---|
| Control | The lower-confidence report cannot liquidate; the trader closes through a public V3 order one second later with 8,100.027395 USDG left in the margin account. |
| Attack | Liquidation at the same one-second-later execution time leaves 6,999.997362 USDG. |
The measured trader-balance difference between the complete branches is 1,100.030033 USDG: 499.996725 USDG credited to the keeper, 600.033308 USDG added to Pool cash and Junior LP assets, and 0 to the treasury. This branch comparison includes the control close's charges and the one second elapsed in both branches; it is the exact outcome for those public paths, not a decomposition of the confidence shift alone.
The PoC checks the Clearinghouse and Pool token movements against their accounted balances, unchanged token supply and LP shares, and no hidden trader claim. The keeper withdraws its bounty; the trader can withdraw only the residual balance. The forced liquidation cannot be reversed by a later fresh price update.
The attack requires the market path and a legitimate owner rotation as prerequisites; the keeper does not control them. The signed fork sample shows the watermark reset with real Pyth proofs, but its sampled position is not close enough to maintenance to liquidate, so the economic loss measurement comes from the deterministic public-call PoC.
Fix
The report proposes the following remediation:
- Before installing a replacement Oracle, carry forward the active per-feed accepted timestamps and accepted basket state for matching feeds, or enforce the active Oracle's accepted-feed timestamps as a Router-level floor across rotations.
- Reject a rotation that cannot preserve that floor while live positions can be liquidated.
- Bind equal-time confidence-dependent prices to a consistent accepted basket when deciding liquidation.
Variants to test
- Other stateful guards across upgrades. Any contract that keeps a monotonic watermark (timestamps, nonces, epochs, sequence numbers) and is swapped by an admin or timelock is a candidate. A positive result is a replacement instance that accepts an input the predecessor had already superseded, with the same downstream effect.
- Confidence or spread inputs outside the equality guard. Look for guards that compare only price and time while a separate input (confidence, spread, weight) feeds the liquidation or health calculation. A positive result is two reports with identical marks but different health outcomes.
- Rotation windows with live positions. Check whether the protocol allows rotation while positions are open and whether it enforces a predecessor floor. A positive result is a rotation that completes without preserving accepted-feed state.
- Replay of still-fresh signed data after any configuration change. Pyth-style signed updates remain valid until their publish time ages out. A positive result is a configuration change that resets the per-feed floor and admits an older-but-fresh proof.
- Fork checks with real signed proofs. Reproduce the watermark reset against the deployed Pyth contract, as the fork runner does, to separate a mock artefact from a real behaviour.
Hunting notes
This kind of bug hides where stateful validation meets administrative lifecycle: Oracle rotation, feed replacement, policy upgrades, and any timelocked configuration that installs a fresh contract instance. During recon, look for:
- Functions named like
applyOracleConfigon both a logic contract and a router, especially where one copies a policy and the other installs the instance. - Per-feed watermark or timestamp state that lives in the Oracle rather than in shared storage.
- Liquidation pricing that mixes a mark with a confidence or spread term, where the mark guard compares only price and time.
- Published mitigation responses (here MED-7, MED-13 and MED-18) and whether the new report actually falls inside their scope.
To show enough impact, the researcher did three things:
- Built a same-snapshot control and attack branch, so the loss figure is a branch comparison rather than an estimate.
- Checked accounting invariants (Clearinghouse and Pool token movements against accounted balances, unchanged token supply and LP shares, no hidden trader claim) so the loss is real and not a bookkeeping artefact.
- Added a signed-proof fork check with real Pyth proofs to demonstrate the watermark reset independently of the mock, while being explicit that the fork sample's position is not close enough to maintenance to liquidate and that the economic measurement comes from the deterministic public-call PoC.
What happened, in plain words
Plether is a trading protocol: people deposit money and open leveraged positions, and the protocol decides whether a position is healthy or must be closed by force. To decide prices, Plether reads price data from Pyth, a service that publishes signed price updates. Each update is a small package of numbers with a signature, so anyone can hand it to the protocol and the protocol can check it is genuine.
A signed price update stays valid for a while after it is published. That creates a risk: someone could keep an old update and hand it in later, when it is no longer the newest price. To stop that, the protocol's Oracle (the contract that decides which prices count) remembers the publish time of the last update it accepted for each feed and refuses anything older. Think of a bouncer at a door who writes down the time on each ticket and only lets in tickets stamped later than the last one.
Plether also has a feature called Oracle rotation: the owner can, after a waiting period, swap the Oracle contract for a new one. The new Oracle starts with an empty notebook. It has forgotten the times the old bouncer wrote down. So an old ticket that the old bouncer had already turned away becomes acceptable again.
This forgotten notebook can be abused. A trader's position sits close to the line where it becomes liquidatable. A keeper (anyone who runs the liquidation step and gets paid for it) can, right after a legitimate rotation, hand in a mix of price updates: one older, higher-confidence update that the old Oracle had already rejected, plus current updates for the other feeds. The mixed report produces the same overall basket price and the same timestamp as the honest current report, so the check that compares price and time sees nothing wrong. But confidence is a separate number, and for a long position the protocol adds 25% of the aggregate confidence to the liquidation price. The older update has higher confidence, so the liquidation price is pushed up, above the maintenance threshold, and the position becomes liquidatable. The keeper liquidates, takes a bounty, and the trader loses money.
The report measures the loss precisely: 1,100.030033 USDG of trader balance difference between an attack branch and a control branch, of which 499.996725 USDG goes to the keeper and 600.033308 USDG to the Pool and Junior liquidity providers.
The product and the feature
Plether is described in the report as a perps-style protocol. "Perps" means perpetual futures: a way to bet on a price going up or down without an expiry date, usually with leverage, meaning you put up a small margin and control a larger position. If the position moves against you far enough, the protocol closes it by force. That forced close is called liquidation.
Prices come from Pyth price feeds. A price feed is a stream of signed price updates. Each update contains, for each market (for example EUR/USD), a price, a publish time, and a confidence value. Confidence is a number that says how sure the publisher is about the price: a wider spread of source prices means lower confidence. The protocol uses confidence in its maths, not just the price.
The in-scope code is the packages/perps/src tree of the audit competition repository, pinned at commit [redacted]. In plain terms: the competition gave researchers a fixed snapshot of the source code to review, and this commit identifies exactly which snapshot.
The live Oracle records the publish time of each accepted Pyth component and rejects a component older than the last accepted value for that feed. That monotonicity check (monotonic means "only moves forward, never back") is the defence against replaying an old, still-fresh signed price. Replay here means handing in a genuine but outdated piece of data again.
The protocol also supports a 72-hour Oracle rotation, in which the owner installs a replacement Oracle through a timelocked process. Timelocked means the change is announced and can only take effect after a waiting period, so users have time to react. The rotation is the feature that breaks the defence: the replacement Oracle starts with zero component watermarks. A watermark here is the remembered "last accepted time" per feed. Zero means "nothing accepted yet", so anything looks newer.
Setup
The PoC (proof of concept, a working demonstration) is a Foundry test, OracleRotationFeedRewind.t.sol, run against the pinned upstream checkout. Foundry is a toolkit for writing and running tests against Ethereum-style smart contracts. The runner copies the test into the checkout without changing production contracts, so the test exercises the real code as shipped. The test uses public Router, admin, order, liquidation and Clearinghouse calls. Its only mock is the out-of-scope Pyth endpoint and settlement token supplied by the repository fixture. A mock is a stand-in that behaves like the real thing; a fixture is prepared test data that ships with the repository.
Preconditions:
- A Junior deposit of 10,000,000 USDG, made through public request, epoch-settlement and claim calls. Junior is a liquidity pool tier: depositors put money in and earn from the protocol. USDG is the stablecoin used in the test.
- A target position: 1,000,000-unit long with 4,000.6 USDG margin, opened through public V3 calls under the release risk settings. Long means betting the price goes up. Margin is the collateral the trader puts up.
- An already proposed, mature Oracle rotation, which the owner finalises during the attack. Mature means the timelock waiting period has passed.
- A market path: roughly 18.85 bp of EUR/USD movement over one hour, with accepted marks every 15 minutes, ending in a two-second step of about 0.0085 bp. A bp is a basis point, one hundredth of a percent. A mark is the price the protocol records as current.
The market path and the legitimate owner rotation are prerequisites; the keeper does not control them. The adversarial report choice and the liquidation itself are permissionless, meaning anyone can do them without special rights.
Finding it
The researcher noticed that the accepted-component timestamp floor is held in the live Oracle's state and is not carried across a rotation. The floor is the minimum acceptable publish time per feed. OrderLiquidationBatchLogic.applyOracleConfig copies the active pricing policy without carrying forward the accepted component timestamps, and OrderRouter.applyOracleConfig then installs the fresh Oracle with zero component watermarks. The first faulty transition is the Router's installation of the replacement Oracle without preserving the active Oracle's accepted-feed state or enforcing a predecessor watermark. In everyday terms: the new bouncer is hired, but nobody hands over the notebook of ticket times.
That alone would be a replay window. What makes it profitable is confidence. The neutral basket's aggregate price and publish time can be identical in both reports, so the equal-time mark guard does not catch the rewind. A basket here is the combined set of feeds used to value the position; neutral means the combined price is the same in both cases. Confidence is not bound to that equal-time guard. For a long position, PletherOracle adds 25% of aggregate confidence to the liquidation price. A higher-confidence older component therefore raises the liquidation price and can turn a solvent position into a liquidatable one after rotation. Solvent means healthy enough to stay open.
Exploitation
Step 1: set up the position and the market path
Fund Junior with a 10,000,000 USDG deposit and open the target's 1,000,000-unit long with 4,000.6 USDG margin through public V3 calls under the release risk settings. During an already proposed, mature Oracle rotation, track the EUR/USD move with four public mark updates spaced 15 minutes apart while the position remains solvent.
The economic PoC models the roughly 18.85-bp EUR/USD movement over one hour with accepted marks every 15 minutes; the final two-second step is about 0.0085 bp.
Step 2: plant a higher-confidence component, then supersede it
At T-1, the old Oracle accepts a complete higher-confidence report with EUR/USD at 1.17721370. A public liquidation reverts as solvent both then and at T, before the older component is superseded. At T, accept a lower-confidence second component at the same EUR/USD price. At T+1, accept another lower-confidence report with EUR/USD at 1.17721470, only about 0.0085 bp higher.
The old Oracle rejects a public liquidation call with the higher-confidence T-1 second component and current T+1 other feeds with PletherOracle__FeedTimeOutOfOrder. This is the key control: while the old Oracle is live, the mix is not admissible, and the position is solvent at every point before the older component is superseded.
Why this step: the researcher first proves the older component was harmless when it was accepted, and that the position was solvent then and at T. Then a tiny price move makes the older component useful to an attacker, but the old Oracle still refuses the mix. The error name PletherOracle__FeedTimeOutOfOrder is the old Oracle saying "this feed is older than what I already accepted".
Step 3: rotate, then liquidate with the mixed report
The owner finalises the timelocked rotation. The new Oracle has a zero accepted timestamp for that component. From the same post-rotation state:
- The current report gives a 1.00109222 liquidation price and leaves the trader solvent.
- The mixed older report gives a 1.00109280 liquidation price, above the measured 1.00109251 maintenance threshold, and lets a permissionless keeper liquidate through
OrderRouter.executeLiquidation.
Both reports have the same neutral basket mark and basket timestamp, so the equal-time mark guard sees nothing wrong.
Why this step: the rotation is the moment the notebook is lost. The honest report keeps the trader safe; the mixed report pushes the liquidation price just above the maintenance threshold, which is the line where the position must be closed. The difference is tiny (1.00109280 versus 1.00109251) but enough.
Supporting evidence
The local Pyth mock supplies complete reports with the stated times and confidence values, and they meet the release freshness, divergence and aggregate-confidence limits. Freshness means the update is not too old; divergence means the feeds do not disagree too much; aggregate confidence is the combined confidence across feeds. Baseline confidence ratios are scaled from a checked-in six-feed Pyth update fixture.
A separate checked-in signed Pyth fixture contains adjacent-second GBP/USD and USD/SEK updates with unchanged prices but higher older confidence. Combining their intact older proofs with four newer feed proofs yields the same neutral basket mark and a 58-tick higher liquidation price under release weights. A tick is the smallest price increment. The signed fork sample demonstrates the watermark reset with real Pyth proofs, but its sampled position is not close enough to maintenance to liquidate.
Running the PoC
The runnable Foundry test is in OracleRotationFeedRewind.t.sol. To reproduce from a clean directory with Foundry and Solc 0.8.35 available to Forge's offline compiler resolver, place the five gist files beside the pinned upstream checkout and run:
git clone --recurse-submodules https://github.com/immunefi-team/audit-comp-plether code
git -C code checkout [redacted]
git -C code submodule update --init --recursive
mkdir -p findings/oracle-rotation-feed-rewind
git clone https://gist.github.com/[redacted].git findings/oracle-rotation-feed-rewind/PoC
bash findings/oracle-rotation-feed-rewind/PoC/run.sh
Line by line:
git clone --recurse-submodules ...downloads the Plether repository into a folder calledcode, including its submodules (other repositories it depends on).git -C code checkout a82d4f...switches that folder to the exact commit the competition pinned, so the test runs against the reviewed code.git -C code submodule update --init --recursivemakes sure every submodule is at the right version.mkdir -p findings/oracle-rotation-feed-rewindcreates a folder for the finding.git clone https://gist.github.com/[redacted].git ...downloads the five PoC files from the gist into that folder.bash findings/oracle-rotation-feed-rewind/PoC/run.shruns the test script, which copies the test into the checkout and executes it.
For an additional signed-Pyth integration check on the Arbitrum Sepolia fork, run:
bash findings/oracle-rotation-feed-rewind/PoC/run-fork.sh
This runs a second script. A fork is a copy of a live blockchain's state, so the test can talk to the real deployed Pyth contract. Arbitrum Sepolia is a public test network. The fork runner uses the documented public RPC unless ARB_SEPOLIA_RPC_URL is set. RPC is the remote procedure call endpoint a program uses to talk to a blockchain node. Its two tests parse intact signed proofs with the deployed Pyth contract and show the old Oracle rejecting a regressed feed while the replacement accepts it through public Router calls. The accepted mark is unchanged, and the source-derived adverse price rises 58 ticks. This fixture leaves the position solvent in both branches, so the economic loss measurement comes from the deterministic public-call PoC.
Expected result: the current report leaves the trader solvent, the older mixed report liquidates, and the test measures 499.996725 USDG keeper credit, 600.033308 USDG Pool/Junior gain, and 1,100.030033 USDG trader loss against the same-state control.
Root cause
The live Oracle records each accepted Pyth component's publish time and rejects a component older than its last accepted value. That protection disappears during the supported 72-hour Oracle rotation:
OrderLiquidationBatchLogic.applyOracleConfigcopies the active pricing policy without carrying forward the accepted component timestamps.OrderRouter.applyOracleConfiginstalls the fresh Oracle with zero component watermarks.
The next permissionless keeper can submit a still-fresh signed component older than one the old Oracle already accepted on-chain. The equal-time mark guard does not catch it because the neutral basket's aggregate price and publish time can remain identical in both reports. Confidence is not bound to that guard, and for a long position PletherOracle adds 25% of aggregate confidence to the liquidation price, so the higher-confidence older component moves the liquidation price above maintenance.
The report also explains why the published mitigations do not cover this. A mitigation is a fix or a guard added after an earlier report.
- MED-7 (accepted-component monotonicity): bypassed. The higher-confidence component was accepted on-chain while it was harmless, and public liquidation was still solvent immediately before the lower-confidence successor superseded it. The small later EUR/USD step first makes the harmful mixed report possible after the old Oracle's timestamp floor has already advanced. The old Oracle explicitly rejects that mix; only rotation makes it admissible.
- MED-13 (changed protection thresholds under a semantically different Oracle): not applicable. The PoC rotates to an identical Oracle and targets liquidation.
- MED-18 (equal-time mark fix): still active but insufficient. The two marks are equal, while confidence-dependent liquidation prices differ.
In plain words: MED-7 said "never accept an older feed". This attack respects that until the rotation, then uses the rotation to reset the rule. MED-13 was about swapping in a different kind of Oracle; here the Oracle is identical. MED-18 made sure two reports with the same price and time are treated the same, but confidence is not part of that comparison, so the two reports still lead to different liquidation prices.
Impact
The impact category is direct theft of user funds, whether at rest or in motion, other than unclaimed yield. In plain words: money that belongs to a user is taken, not just rewards that were never claimed.
A permissionless keeper can force-liquidate a near-maintenance trader immediately after a legitimate Oracle rotation, using a still-fresh Pyth component the old Oracle already rejected.
The PoC starts both outcomes from one snapshot. A snapshot is the same starting state, so the two branches differ only in the attack.
| Branch | Outcome |
|---|---|
| Control | The lower-confidence report cannot liquidate; the trader closes through a public V3 order one second later with 8,100.027395 USDG left in the margin account. |
| Attack | Liquidation at the same one-second-later execution time leaves 6,999.997362 USDG. |
The measured trader-balance difference between the complete branches is 1,100.030033 USDG: 499.996725 USDG credited to the keeper, 600.033308 USDG added to Pool cash and Junior LP assets, and 0 to the treasury. This branch comparison includes the control close's charges and the one second elapsed in both branches; it is the exact outcome for those public paths, not a decomposition of the confidence shift alone.
The PoC checks the Clearinghouse and Pool token movements against their accounted balances, unchanged token supply and LP shares, and no hidden trader claim. The Clearinghouse is the contract that settles trades and tracks balances; LP shares are the units that represent a liquidity provider's stake. The keeper withdraws its bounty; the trader can withdraw only the residual balance. The forced liquidation cannot be reversed by a later fresh price update.
The attack requires the market path and a legitimate owner rotation as prerequisites; the keeper does not control them. The signed fork sample shows the watermark reset with real Pyth proofs, but its sampled position is not close enough to maintenance to liquidate, so the economic loss measurement comes from the deterministic public-call PoC.
Fix
The report proposes the following remediation:
- Before installing a replacement Oracle, carry forward the active per-feed accepted timestamps and accepted basket state for matching feeds, or enforce the active Oracle's accepted-feed timestamps as a Router-level floor across rotations.
- Reject a rotation that cannot preserve that floor while live positions can be liquidated.
- Bind equal-time confidence-dependent prices to a consistent accepted basket when deciding liquidation.
In plain words: hand the notebook to the new bouncer, refuse the swap if the notebook cannot be handed over while positions are open, and make sure confidence is compared consistently when two reports have the same price and time.
The report does not state that any of these were implemented.
Variants to test
- Other stateful guards across upgrades. Any contract that keeps a monotonic watermark (timestamps, nonces, epochs, sequence numbers) and is swapped by an admin or timelock is a candidate. A positive result is a replacement instance that accepts an input the predecessor had already superseded, with the same downstream effect. A nonce is a number used once to keep things in order; an epoch is a numbered period.
- Confidence or spread inputs outside the equality guard. Look for guards that compare only price and time while a separate input (confidence, spread, weight) feeds the liquidation or health calculation. A positive result is two reports with identical marks but different health outcomes.
- Rotation windows with live positions. Check whether the protocol allows rotation while positions are open and whether it enforces a predecessor floor. A positive result is a rotation that completes without preserving accepted-feed state.
- Replay of still-fresh signed data after any configuration change. Pyth-style signed updates remain valid until their publish time ages out. A positive result is a configuration change that resets the per-feed floor and admits an older-but-fresh proof.
- Fork checks with real signed proofs. Reproduce the watermark reset against the deployed Pyth contract, as the fork runner does, to separate a mock artefact from a real behaviour.
Hunting notes
This kind of bug hides where stateful validation meets administrative lifecycle: Oracle rotation, feed replacement, policy upgrades, and any timelocked configuration that installs a fresh contract instance. Stateful validation means a check that depends on remembered state; administrative lifecycle means the steps an owner takes to change the system. During recon, look for:
- Functions named like
applyOracleConfigon both a logic contract and a router, especially where one copies a policy and the other installs the instance. - Per-feed watermark or timestamp state that lives in the Oracle rather than in shared storage.
- Liquidation pricing that mixes a mark with a confidence or spread term, where the mark guard compares only price and time.
- Published mitigation responses (here MED-7, MED-13 and MED-18) and whether the new report actually falls inside their scope.
To show enough impact, the researcher did three things:
- Built a same-snapshot control and attack branch, so the loss figure is a branch comparison rather than an estimate.
- Checked accounting invariants (Clearinghouse and Pool token movements against accounted balances, unchanged token supply and LP shares, no hidden trader claim) so the loss is real and not a bookkeeping artefact. An invariant is a property that must always hold.
- Added a signed-proof fork check with real Pyth proofs to demonstrate the watermark reset independently of the mock, while being explicit that the fork sample's position is not close enough to maintenance to liquidate and that the economic measurement comes from the deterministic public-call PoC.
Glossary
- Arbitrum Sepolia: a public test network that mimics Arbitrum, used to try things without real money.
- Basket: the combined set of price feeds used to value a position.
- Basis point (bp): one hundredth of a percent (0.01%).
- Bounty: a reward paid to someone who reports or demonstrates a security problem.
- Clearinghouse: the contract that settles trades and tracks balances.
- Commit: a fixed snapshot of a code repository, identified by a hash.
- Confidence (Pyth): a number in a price update saying how sure the publisher is about the price.
- Control branch: the version of a test without the attack, used for comparison.
- Deterministic: producing the same result every time it is run.
- Divergence: how much different feeds disagree with each other.
- Epoch: a numbered period used to group events.
- Equal-time mark guard: a check that treats two reports with the same price and time as equivalent.
- Feed: a stream of price updates for one market.
- Fixture: prepared test data that ships with a repository.
- Floor (timestamp floor): the minimum acceptable publish time per feed.
- Fork: a copy of a live blockchain's state used for testing.
- Foundry: a toolkit for writing and running tests against Ethereum-style smart contracts.
- Freshness: whether a signed update is recent enough to be accepted.
- Gist: a small public code snippet hosted by GitHub.
- Invariant: a property that must always hold true.
- Junior: a liquidity pool tier whose depositors earn from the protocol.
- Keeper: anyone who runs a permissionless step such as liquidation and is paid for it.
- Leverage: controlling a larger position with a smaller amount of collateral.
- Liquidation: a forced close of a position that has become too risky.
- Liquidation price: the price at which a position becomes liquidatable.
- Long: a position that profits when the price goes up.
- LP shares: units representing a liquidity provider's stake in a pool.
- Maintenance threshold: the line above or below which a position must be closed.
- Margin: the collateral a trader puts up for a position.
- Mark: the price the protocol records as current.
- Mature (rotation): a timelocked change whose waiting period has passed.
- MED-7, MED-13, MED-18: identifiers of earlier published mitigation responses.
- Mitigation: a fix or guard added after an earlier report.
- Mock: a stand-in that behaves like the real thing in a test.
- Monotonic: only moves forward, never back.
- Nonce: a number used once to keep things in order.
- Oracle: the contract that decides which prices count.
- Perps (perpetual futures): a way to bet on a price with no expiry date, usually with leverage.
- Permissionless: anyone can do it without special rights.
- PoC (proof of concept): a working demonstration of a bug.
- Pool: a contract holding liquidity that the protocol uses.
- Pyth: a service that publishes signed price updates.
- Recon: the research phase where you study a target before attacking it.
- Replay: handing in a genuine but outdated piece of data again.
- RPC: the remote procedure call endpoint a program uses to talk to a blockchain node.
- Rotation (Oracle): swapping the Oracle contract for a new one after a timelock.
- Router: the contract that routes user actions to the right logic.
- Snapshot: the same starting state for two test branches.
- Solc: the Solidity compiler.
- Solvent: healthy enough for a position to stay open.
- Stateful validation: a check that depends on remembered state.
- Submodule: another repository that a repository depends on.
- Tick: the smallest price increment.
- Timelock: a change that is announced and can only take effect after a waiting period.
- Treasury: the protocol's own fund account.
- USDG: the stablecoin used in the test.
- V3 calls: the public functions of the protocol's trading interface used in the test.
- Watermark: the remembered last accepted time per feed.
- Yield: rewards earned from deposited funds.