Valid batches revert on staggered Pyth publication times
When two delayed orders are executed as a batch, the router reuses the price cache from the first order for the second. If the Pyth price feeds for the basket components were published a few seconds apart, the second order's stricter timestamp check fails and the whole batch reverts, including the first valid order.
- Disclosed after under an hour
#100030 [SC-Medium] Valid batches revert on staggered Pyth publication times
Submitted on Nov 16th 2026 at 05:21:47 UTC by @gandu for Audit Competition | Plether
- Report ID: #100030
- Report Type: Smart Contract
- Report severity: Medium
- Target: https://github.com/immunefi-team/audit-comp-plether/tree/a82d4fefb02768e5b3bddcc97dee371eee24fea8/packages/perps/src
- Impacts:
- Griefing (e.g. no profit motive for an attacker, but damage to the users or the protocol)
Description
Brief/Intro
Two valid delayed orders can fail as a batch when their signed Pyth components publish a few seconds apart. The first order accepts the basket, but reuse for the second applies a stricter timestamp condition and reverts the whole transaction. On mainnet, this wastes keeper gas and delays a valid trader order, potentially until another executor retries it individually.
Vulnerability Details
- Delayed-order pricing uses the first eligible post-commit Pyth update for each currency-basket component.
- The six components may have different publication times if their spread stays within the configured divergence limit.
- During batch execution, the Router can keep the basket resolved for the first order and offer it to a later eligible order.
- The first historical resolution checks each stored feed against that feed's own parsed publication time.
- In the PoC, Alice commits at t, Mallory at t+1, one component publishes at t+2, and the other five at t+4.
- Every update follows both commitments, and the two-second separation is within the permitted five-second component divergence.
- Alice's order resolves successfully. The resulting cache records the basket's newest publication time, t+4.
- The Router accepts that cache for Mallory's order, but updateBatchOrderExecutionPrice requires all stored feeds to cover the cache's t+4 time.
- The component stored at t+2 fails the new requirement with StoredFeedBehind although it was valid for the first resolution.
- The revert unwinds the entire batch, including Alice's valid execution. Separate single-order calls with the same signed payload succeed, and an equal-time control succeeds as a batch.
for (uint256 i; i < pythFeedIds.length; ++i) {
_requireStoredFeedCoverage(pythFeedIds[i], cache.publishTime);
}
Impact Details
The demonstrated result is a failed batch transaction: the keeper pays gas, Alice's valid order remains at the FIFO head, and both orders remain pending. A new executor can recover by processing them separately. If no successful retry occurs before an order deadline, an affected order may expire, but the PoC proves immediate disruption, not guaranteed expiry or loss of trader funds. This supports confirmed Medium Griefing without claiming a permanent queue lock.
Proof of Concept
Proof of Concept
Place Oracle_BatchCacheCoverageRevert.t.sol at packages/perps/test/poc/. The attack test checks StoredFeedBehind, unchanged pending orders, and successful separate executions. The control makes component publication times equal and confirms batch reuse succeeds. No in-scope source contract is changed.
forge test --root packages/perps --offline --match-path 'test/poc/Oracle_BatchCacheCoverageRevert.t.sol' -vv
The submitted report records 2 passed, 0 failed. This suite was not rerun for this rewrite.
// SPDX-License-Identifier: AGPL-3.0
pragma solidity 0.8.35;
import {OracleSynchronizationTestBase} from "../perps/shared/OracleSynchronizationTestBase.sol";
import {OrderV3Types} from "@plether/perps/OrderV3Types.sol";
import {IPletherOracle} from "@plether/perps/interfaces/IPletherOracle.sol";
import {MockPyth} from "@plether/test-utils/MockPyth.sol";
/// @notice Batch cache reuse checks every stored feed against the NEWEST component time, while a fresh
/// historical resolution checks each feed against its own parsed time. With honest unequal component
/// times and a payload carrying only the commit-window ticks, the Router decides to reuse (time rules
/// pass, fee 0) and the Oracle reverts StoredFeedBehind, which the batch re-throws, reverting the
/// whole batch including the first, already-valid execution. The same orders execute fine one by one.
contract Oracle_BatchCacheCoverageRevert is OracleSynchronizationTestBase {
function test_BatchRevertsOnHonestUnequalComponentTimesButSingleExecutionsSucceed() public {
uint64 firstCommit = uint64(block.timestamp);
uint64 aliceId = _commit(ALICE, 0);
_advance(firstCommit + 1);
uint64 bobId = _commit(BOB, 0); // later order, commit strictly before the oldest component
_advance(firstCommit + 6);
// First post-commit ticks: feed0 publishes at +2, feeds1..5 publish at +4 (2s apart, < 5s divergence).
bytes[] memory historical = _payload(firstCommit + 4, firstCommit);
MockPyth.FeedUpdate[] memory updates = abi.decode(historical[0], (MockPyth.FeedUpdate[]));
updates[0].price.publishTime = firstCommit + 2;
historical[0] = abi.encode(updates);
uint256 keeperBefore = address(this).balance;
// Funding for two independent resolutions is supplied; reuse would need none.
vm.expectRevert(
abi.encodeWithSelector(
IPletherOracle.PletherOracle__StoredFeedBehind.selector,
updates[0].id,
uint256(firstCommit + 2),
uint256(firstCommit + 4)
)
);
router.executeOrderBatch{value: 4 * FEE}(bobId, historical);
// Nothing progressed: both orders still pending, Alice's valid fill rolled back.
assertEq(router.nextExecuteId(), aliceId, "batch made no progress");
assertEq(uint256(router.lifecycleBook().lifecycleStatus(aliceId)), uint256(OrderV3Types.LifecycleStatus.Pending));
assertEq(uint256(router.lifecycleBook().lifecycleStatus(bobId)), uint256(OrderV3Types.LifecycleStatus.Pending));
(uint256 aliceSize,,,,,,) = engine.positions(ALICE);
assertEq(aliceSize, 0);
assertEq(address(this).balance, keeperBefore, "reverted call returns ETH; only gas is lost");
// The identical payload executes both orders when submitted one at a time (fresh per-feed coverage).
OrderV3Types.ExecutionResult memory r1 = router.executeOrder{value: 2 * FEE}(aliceId, historical);
assertEq(uint256(r1.status), uint256(OrderV3Types.LifecycleStatus.Executed));
OrderV3Types.ExecutionResult memory r2 = router.executeOrder{value: 2 * FEE}(bobId, historical);
assertEq(uint256(r2.status), uint256(OrderV3Types.LifecycleStatus.Executed));
}
/// @notice Control: with equal component times the same two-order batch succeeds via reuse.
function test_ControlEqualComponentTimesBatchSucceeds() public {
uint64 firstCommit = uint64(block.timestamp);
_commit(ALICE, 0);
_advance(firstCommit + 1);
uint64 bobId = _commit(BOB, 0);
_advance(firstCommit + 6);
bytes[] memory historical = _payload(firstCommit + 4, firstCommit);
OrderV3Types.BatchResult memory result = router.executeOrderBatch{value: 4 * FEE}(bobId, historical);
assertEq(result.terminalCount, 2);
assertEq(baseMockPyth.parseUniqueCallCount(), 1);
}
}
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 batch cache reuse path validates every stored feed against the cache's newest publication time, while a fresh single-order resolution validates each feed against its own parsed publication time.
Impact
A keeper wastes gas and both orders stay pending; a later executor can recover by processing them separately, but if no retry happens before a deadline an order could expire.
What the attacker needed
Two delayed orders in the same batch; Pyth component times differ by a few seconds; difference within the divergence limit
How it was found
- Alice commits an order at time t.
- Mallory commits an order at time t+1.
- One Pyth component publishes at t+2 and the other five at t+4, within the allowed divergence.
- Alice's order resolves and the cache records the newest time, t+4.
- The router reuses that cache for Mallory's order, but the t+2 feed fails the coverage check and the batch reverts.
- Submitting the same orders individually succeeds.
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 batch lets a keeper submit several orders in one transaction. The first order builds a price cache, and the second order reuses it. But the second order checks that every price feed is at least as new as the newest feed in the cache. If one feed is a couple of seconds older, that check fails and the entire batch is undone, so even the first good order is cancelled.
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.