Attacker can overwrite legitimate refundsInfo by triggering `GatewayTransferNative::onRevert`
The onRevert function in GatewayTransferNative does not check if a refund record already exists for a given externalId, allowing an attacker to overwrite a legitimate pending refund's wallet address. This means the rightful owner cannot withdraw their refunded funds.
0xc0ffEE Follow with 0xdice91, 0xiehnnkta and 27 others
Originally disclosed on Sherlock
Source: https://github.com/sherlock-audit/2025-05-dodo-cross-chain-dex-judging/issues/855
Found by
0xc0ffEE, 0xdice91, 0xiehnnkta, 0xlucky, 4n0nx, Abhan1041, AestheticBhai, AnomX, EgisSecurity, King_9aimon, Nomadic_bear, Ob, Oxsadeeq, PNS, Phaethon, X0sauce, Yaneca_b, elolpuer, grandson, harry, hiroshi1002, iamandreiski, jongwon, n08ita, patitonar, phrax, roadToWatsonN101, sheep, shushu, silver_eth
Summary
The GatewayTransferNative::onRevert function allows an attacker to overwrite legitimate, pending refunds. This is because GatewayTransferNative used RevertMessage to do accounting of refunds. However, the revertMessage should be validated.
Root Cause
The onRevert function does not validate whether a RefundInfo already exists for a given externalId before creating a new one. It blindly overwrites the storage slot.
Internal Pre-conditions
None.
External Pre-conditions
None.
Attack Path
-
Attacker monitors for a legitimate user's transaction to fail, causing
onAbortto be called. ARefundInfois stored with the keyVICTIM_EXTERNAL_ID. The contract now holds, for example, 1000e6 zUSDC that is meant for the victim inrefundInfo. -
The attacker initiates a cross-chain transaction that is designed to fail and trigger
GatewayTransferNatice::onRevert.
He can make any contract on destination evm chain as follows
contract AttackerContract{
constructor(){
}
function onCall ( MessageContext calldata context,
address zrc20,
uint256 amount,
bytes calldata message
) external override onlyGateway {
// always revert
revert();
}
}
This can be done by calling GatewayZEVM::withdrawAndCall specifying the following details:
function withdrawAndCall(
bytes memory receiver, // attackerContract
uint256 amount, // 1
address zrc20,// zUSDC
bytes calldata message,
CallOptions calldata callOptions,
//CallOptions({
// isArbitraryCall: false,
// gasLimit: 100_000
// }),
RevertOptions calldata revertOptions
// RevertOptions({
// revertAddress: address(GatewayTransferNatie)
// callOnRevert: true,
// abortAddress: address(GatewayTransferNative)
// revertMessage: bytes.concat(VICTIM_EXTERNAL_ID, bytes32(uint256(123456789)),
// onRevertGasLimit: 100_000
// })
)
- This will cause
GatewayTransferNative::onRevertto be called, where theelsestatement is executed as shown here. This will overriderefundinfo[VICTIM_EXTERNAL_ID].walletAddressto be overriden to thebytes32(uint256(123456789)), at the cost of only 1 wei of zUSDC.
Impact
Legitimate User's funds that were refunded via onAbort cannot be withdrawn back to the rightful owner as the refundInfo[VICTIM_EXTERNAL_ID].walletAddress had been posioned by an attacker.
PoC
Please refer to Attack Path.
Mitigation
Fix is non trivial as RevertMessage cannot be trusted.
Discussion
sherlock-admin2
The protocol team fixed this issue in the following PRs/commits: https://github.com/Skyewwww/omni-chain-contracts/pull/25
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 onRevert function lacks a check to prevent overwriting an existing RefundInfo for the same externalId.
Impact
Legitimate users' refunded funds cannot be withdrawn by the rightful owner because the refund wallet address has been overwritten by the attacker.
What the attacker needed
Victim's transaction fails and refund is pending; attacker can initiate cross-chain transaction
The fix
The fix is non-trivial because the RevertMessage cannot be trusted; the protocol team fixed this issue in a pull request.
How it was found
- Attacker monitors for a legitimate user's transaction to fail, causing onAbort to be called and a RefundInfo to be stored with the victim's externalId.
- Attacker initiates a cross-chain transaction designed to fail and trigger onRevert, using a contract on the destination chain that always reverts.
- The attacker calls withdrawAndCall with the victim's externalId in the revertMessage, causing onRevert to overwrite the victim's refund wallet address.
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 a cross-chain transaction fails, the system records who should get a refund. The attacker can trigger a failure with a fake identifier that matches a victim's pending refund, causing the system to replace the victim's address with the attacker's. Then the victim cannot claim their refund.
What is Access control?
A user can do something their role should not allow: reach an admin function, act on a feature they have not paid for, or skip a permission check. IDOR is the special case where the object belongs to someone else.