Batch order execution reverts completely when the reused price basket is not covered by stored Pyth feeds
The batch order execution router reuses a cached price basket for later orders without checking that all stored Pyth feeds are at least as recent as the basket's publish time. When one feed is a second older, the oracle reverts with a StoredFeedBehind error, causing the entire batch transaction to fail and roll back orders already processed.
- Disclosed after under an hour
#99311 [SC-Medium] Batch order execution reverts completely when the reused price basket is not covered by stored Pyth feeds
Submitted on Nov 13th 2026 at 03:59:03 UTC by @Krish00 for Audit Competition | Plether
- Report ID: #99311
- Report Type: Smart Contract
- Report severity: Medium
- Target: https://github.com/immunefi-team/audit-comp-plether/tree/a82d4fefb02768e5b3bddcc97dee371eee24fea8/packages/perps/src
- Impacts:
- Contract fails to deliver promised returns, but doesn't lose value
Description
Brief/Intro
When executeOrderBatch processes multiple orders, it can reuse the price data from the first order for the remaining orders in the batch.
However, the oracle requires all stored price feeds to be at least as recent as the newest feed in the reused data. Since different feeds are updated a second or two apart, this requirement can fail and trigger a StoredFeedBehind error.
As a result, the entire batch transaction reverts, including orders that were already processed earlier in the same batch..
Vulnerability Details The issue occurs because the router reuses previously resolved oracle price data without checking whether all stored feeds meet the required timestamp.
The relevant code paths are:
-
Historical price reuse: In
OrderRouterExecutionSidecar._canReuseHistoricalBatchBasket(around line 1074), the router checks whether the previous price basket can be reused. However, it does not verify that all stored feeds are sufficiently up to date. -
Oracle timestamp validation: In
PletherOracle.updateBatchOrderExecutionPrice(around lines 262–266), the oracle requires every stored feed to have a timestamp greater than or equal tocache.publishTime. -
Initial price resolution: The
_resolveHistoricalOrderBasketfunction (around lines 619–626) initially checks each feed against its own timestamp. It does not guarantee that every feed meets the newest timestamp when the basket is reused for another order. -
Error handling: In
OrderRouterExecutionSidecar(around lines 1020–1028), the router only handles the 68-byte parser error. However, theStoredFeedBehinderror is 100 bytes, so it is not handled by this fallback logic. Instead, the error causes the entire batch transaction to revert. -
Documentation mismatch: The
ORACLE_SYNCHRONIZATION.mddocument, under the "Batch reuse" section, describes that the router should request a fresh historical resolution instead of continuing with an outdated batch basket.
This means the existing reuse logic does not properly handle differences in publication times between oracle feeds. Impact Details When this issue occurs, the entire batch transaction fails, even if some orders were successfully processed before the failure.
The practical impact is:
- The keeper loses the gas spent on the reverted transaction.
- Previously processed orders are rolled back along with the rest of the batch.
- Keepers may need to execute orders individually instead of batching them.
- Individual execution requires additional transactions and may require paying the Pyth update fee for each execution.
- An order committed shortly after another order can trigger this condition when the keeper attempts to execute both together.
No direct loss of user funds has been demonstrated. The issue affects batch execution reliability, increases keeper costs, and prevents the router from behaving as described in its oracle synchronization documentation.
Based on the demonstrated impact, this report is classified as Low severity. References
- OrderRouterExecutionSidecar.sol
- PletherOracle.sol
- ORACLE_SYNCHRONIZATION.md
Link to Proof of Concept
https://gist.github.com/unknownshadow2011/19c8a824879e2c71e8e564e5fb3f76b4
Proof of Concept
Test file: BatchCacheCoverage.t.sol
The complete test code is available in the attached Gist.
Place the file in:
packages/perps/test/perps/poc/
Run the test using repository commit:
a82d4fefb02768e5b3bddcc97dee371eee24fea8
The test uses the repository's existing OracleSynchronizationTestBase and MockPyth to simulate oracle price updates. Since Pyth is outside the scope of this issue, using a mock for testing is appropriate.
No in-scope contract has been changed.
Command to run:
cd packages/perps
FOUNDRY_MATCH_CONTRACT=BatchCacheCoveragePoC FOUNDRY_VERBOSITY=2 forge test
Test Scenario
Test: test_PoC_BatchReuseRevertsWholeBatchWithoutThirdPartyStorageRefresh
- Alice commits an order at time C. Bob commits another order at C+3.
- At C+6, a keeper calls
executeOrderBatchwith a valid price payload.- Feed 0 has a publish time of C+4.
- The other five feeds have a publish time of C+5.
- The difference between feed timestamps is one second, within the allowed five-second limit.
- The router processes Alice's order and resolves the price data. It caches the basket with
publishTime = C+5. However, Pyth storage still contains feed 0 with a timestamp of C+4. - Bob's order uses the cached basket. The oracle checks the stored feeds and finds that feed 0 is older than the required timestamp.
- The oracle reverts with
StoredFeedBehind(feed0, C+4, C+5). - The router does not handle this error, so the entire batch transaction reverts. Alice's order is also rolled back, even though it was processed first.
Additional Tests
I added two more tests to check whether the problem is specifically related to cached price data reuse.
1. Individual order execution
Test: test_PoC_SingleExecutionsSucceedWithSamePayload
The same price payload is used to execute both orders separately through two executeOrder calls.
Both executions succeed, and both orders reach the Executed status.
2. Batch execution with matching feed timestamps
Test: test_Control_BatchSucceedsWhenAllComponentsShareOneSecond
The same scenario is tested again, but all six feeds have the same publish time of C+5.
This time, the batch executes both orders successfully. The second order reuses the cached basket, and the historical price data is parsed only once.
Test Results
All three tests passed at repository commit a82d4fe, when rechecked on 13 November 2026.
The attached screenshot shows the successful test results.
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 router reuses a cached price basket without verifying that every stored feed's timestamp is at least the basket's publish time, and the resulting StoredFeedBehind error is not handled by the fallback logic.
Impact
The entire batch transaction reverts, rolling back already processed orders and wasting keeper gas; no direct loss of user funds is demonstrated, and keepers may need to execute orders individually, paying the Pyth update fee each time.
What the attacker needed
Two or more orders committed close together; keeper executes them as a batch; price feeds have slightly different timestamps
The fix
The router should request a fresh historical resolution instead of continuing with an outdated batch basket, as described in the oracle synchronisation documentation.
How it was found
- Alice commits an order at time C and Bob commits another at C+3.
- At C+6 a keeper calls executeOrderBatch with a price payload where feed 0 has publish time C+4 and the other five feeds have C+5.
- The router processes Alice's order and caches the basket with publishTime C+5, while Pyth storage still has feed 0 at C+4.
- Bob's order reuses the cached basket and the oracle finds feed 0 older than required.
- The oracle reverts with StoredFeedBehind and the router does not handle it, so the whole batch reverts.
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 smart contract router tries to save work by reusing price data from the first order in a batch for the remaining orders. The oracle, however, insists that every stored price feed be at least as new as the reused data. Because different price feeds update a second or two apart, this check can fail and the whole batch is cancelled, even orders that had already gone through.
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.