Skip to content
Business logic Audit finding Intermediate

Refunds for unconsumed gas will be lost due to incorrect refund chain ID

The WormholeDepositProcessorL1 contract passed the EVM chain ID instead of the Wormhole chain ID as the refund chain when sending tokens via Wormhole. As a result, refunds for unconsumed gas were sent to the wrong chain or lost, causing users to overpay.

EV_om Follow with haxatron

Originally disclosed on Code4rena

Submitted by EV_om, also found by haxatron

The WormholeDepositProcessorL1 contract allows sending tokens and data via the Wormhole bridge from L1 to L2. It uses the sendTokenWithPayloadToEvm() function from the TokenBase contract in the Wormhole Solidity SDK to send the tokens and payload.

The sendTokenWithPayloadToEvm() function takes several parameters, including:

  • targetChain - the Wormhole chain ID of the destination chain.
  • refundChain - the Wormhole chain ID of the chain where refunds for unconsumed gas should be sent.

In the WormholeDepositProcessorL1._sendMessage() function, the refundChain parameter is incorrectly set to l2TargetChainId, which is the EVM chain ID of the receiving L2 chain:

File: WormholeDepositProcessorL1.sol
94:         // The token approval is done inside the function
95:
96:         sequence = sendTokenWithPayloadToEvm(uint16(wormholeTargetChainId), l2TargetDispenser, data, 0,
97:             gasLimitMessage, olas, transferAmount, uint16(l2TargetChainId), refundAccount);

However, it should be set to wormholeTargetChainId, which is the Wormhole chain ID classification corresponding to the L2 chain ID. Passing the l2TargetChainId as targetChain and casting it to uint16 will lead to refunds for unconsumed gas being sent to an altogether different chain (only if they are sufficient to be delivered, as explained in the Wormhole docs here) or lost.

Impact

Refunds for unconsumed gas paid by users when sending tokens from L1 to L2 via the Wormhole bridge will likely be lost. This results in users overpaying for gas.

Proof of Concept

  1. User calls claimStakingIncentives() on the Dispenser contract for a nominee on Celo.
  2. WormholeDepositProcessorL1._sendMessage() is called internally, which calls TokenBase.sendTokenWithPayloadToEvm().
  3. The refundChain parameter in sendTokenWithPayloadToEvm() is set to l2TargetChainId instead of wormholeTargetChainId.
  4. Refunds for unconsumed gas are sent to the wrong chain ID or lost.

Recommended Mitigation Steps

Change the refundChain parameter in the sendTokenWithPayloadToEvm() call to use wormholeTargetChainId instead of l2TargetChainId.

kupermind (Olas) confirmed and commented:

This is correct.

Olas mitigated

Varun_05 (warden) commented:

Fixed.


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

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

The code used the EVM chain ID (l2TargetChainId) instead of the Wormhole chain ID (wormholeTargetChainId) for the refundChain parameter.

Impact

Refunds for unconsumed gas paid by users when sending tokens from L1 to L2 via the Wormhole bridge will likely be lost, resulting in users overpaying for gas.

What the attacker needed

User sends tokens from L1 to L2 via Wormhole; Unconsumed gas refund is generated

The fix

The refundChain parameter in the sendTokenWithPayloadToEvm() call should be changed to use wormholeTargetChainId instead of l2TargetChainId; the project mitigated this in a pull request and a warden confirmed it as fixed.

How it was found

  1. User calls claimStakingIncentives() on the Dispenser contract for a nominee on Celo.
  2. WormholeDepositProcessorL1._sendMessage() is called internally, which calls TokenBase.sendTokenWithPayloadToEvm().
  3. The refundChain parameter in sendTokenWithPayloadToEvm() is set to l2TargetChainId instead of wormholeTargetChainId.
  4. Refunds for unconsumed gas are sent to the wrong chain ID or lost.

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 you send tokens across blockchains, you pay extra gas, and any unused gas is supposed to be refunded to you on the chain you choose. This contract accidentally told the bridge to send the refund to a different chain, so the refund never arrived. Users ended up paying more than necessary.

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 EV_om

View all

23 more disclosed reports, best first.

More from Olas

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.