Skip to content
Business logic Audit finding Beginner

OrderRouter NatSpec says the oracle refunds excess ETH, but the Router refunds it into a ledger that emits no credit event

The OrderRouter's documentation states that the oracle refunds excess ETH, but the Router actually refunds it itself and, if the refund call fails, credits an internal ledger that emits no event. A keeper following the documentation would look in the wrong place and find no record of the deferred refund.

W3B_SR_0xki Follow

Originally disclosed on Immunefi

Informational View original
  • Disclosed after under an hour

#97796 [SC-Insight] OrderRouter NatSpec says the oracle refunds excess ETH, but the Router refunds it into a ledger that emits no credit event

Submitted on Nov 3rd 2026 at 08:43:42 UTC by @W3B_SR_0xki for Audit Competition | Plether

Description

Target: packages/perps/src tree at a82d4fefb02768e5b3bddcc97dee371eee24fea8 (OrderRouter.sol, OrderRouterAdmin.sol, router/OrderLiquidationBatchLogic.sol) Impact: Insight — Documentation improvements / Security best practices

Description

1. The NatSpec names the wrong refunder

OrderRouter.updateMarkPrice says: "The oracle handles the Pyth fee and normally refunds unused ETH to the caller" (OrderRouter.sol:424-425). executeLiquidation says: "The oracle handles Pyth fees and ETH refunds" (OrderRouter.sol:490).

In the code, the Router sends the oracle exactly the Pyth fee, so the oracle never sees the excess:

  • The call is oracle.updatePrice{value: pythFee}(...) (router/OrderLiquidationBatchLogic.sol:603-608).
  • The Router refunds msg.value - pythFee itself via _sendEth (router/OrderLiquidationBatchLogic.sol:621, :846-858).
  • If that 30,000-gas call fails, _sendEth credits the amount to OrderRouterAdmin.claimableEth (also router/OrderExecutionHandler.sol:30-43).

2. The Router's deferral ledger is silent

  • OrderRouterAdmin.creditClaimableEth increases claimableEth[beneficiary] and emits nothing (OrderRouterAdmin.sol:264-275).
  • claimBalance() emits nothing either (OrderRouterAdmin.sol:279-281, :293-306).
  • Only claimBalanceTo emits an event, EthRefundClaimedTo (OrderRouterAdmin.sol:290).
  • The oracle's ledger, by contrast, emits EthRefundDeferred when it credits and EthRefundClaimed / EthRefundClaimedTo when it pays out (interfaces/IPletherOracle.sol:231-240).

Impact

Consider a keeper whose fallback reverts or uses more than 30,000 gas. It follows the NatSpec and looks for its deferred refund in PletherOracle.claimableEth, or watches for EthRefundDeferred. Neither ever shows the refund. The ETH sits in OrderRouterAdmin.claimableEth with no event to reveal it.

Nothing is lost, because the beneficiary can still call claimBalance(). But the funds are hard to discover, and claims made through claimBalance() cannot be audited from logs.

Recommendation

  • Update OrderRouter.sol:424-425 and :490 to say that the Router pays the oracle exactly the Pyth fee and refunds the rest, crediting OrderRouterAdmin.claimableEth if the refund call fails.
  • Emit an event in creditClaimableEth (for example EthRefundDeferred(beneficiary, amount)) and in claimBalance() (for example EthRefundClaimed(msg.sender, amount)), mirroring the oracle's ledger.

Proof of Concept

Proof of Concept

The original report as published on Immunefi, by W3B_SR_0xki. Images and videos are our own copies; raw HTML is shown as text. View it on Immunefi.

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's deferred-refund ledger functions were written without emitting events, and the NatSpec comments were not updated to match the actual refund flow.

Impact

Nothing is lost because the beneficiary can still claim, but the funds are hard to discover and claims made through `claimBalance()` cannot be audited from logs.

What the attacker needed

A keeper whose refund call fails; the refund call uses over 30,000 gas

The fix

The documentation should be corrected to describe the Router's own refund behaviour, and events should be emitted when crediting and claiming the deferred ETH.

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.

When someone sends more ETH than needed for a fee, the extra should be returned. Here the extra is kept in a list of amounts owed, but no notification is sent when that happens, so the person owed the money may not realise it is waiting for 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.

More by W3B_SR_0xki

View all

13 more disclosed reports, best first.

More from Plether

View all

The newest disclosed reports for this program.

Similar reports

View all

Same bug class and techniques, clearest first.

Business logic flaws

The lesson behind this report.

The application works as coded but not as intended: a negative price, a skipped payment step, a limit that can be crossed.