The Sender of an outbound cctx originating from the zEVM is potentially set to an incorrect sender address resulting in lost assets during a refund
The sender of an outbound cross-chain transaction from the zEVM is set to the transaction signer instead of the actual sender contract, so refunds for failed transactions go to the wrong address. An attacker can craft a failing transaction to steal refunded assets.
berndartmueller Follow with p0wd3r
Originally disclosed on Code4rena
Submitted by berndartmueller, also found by p0wd3r
If an intermediary contract is used on the zEVM when interacting with the ZetaConnectorZEVM contract or ZRC-20 tokens, potential refunds are sent to the transaction signer instead of the intermediary contract, allowing users to steal assets by crafting a cctx that fails and refunds the assets to them.
Determining the validity of the message call via the ZetaInteractor.isValidMessageCall modifier is unreliable.
Proof of Concept
zEVM transactions are post-processed in the PostTxProcessing function of the x/crosschain module. Specifically, the goal is to parse and process ZetaSent and ZRC-20 Withdrawal events and send them to the corresponding, external receiver chains.
Any emitted ZetaSent events are parsed and processed in the ProcessZetaSentEvent function. Similarly, ZRC-20 Withdrawal events are processed in the ProcessZRC20WithdrawalEvent function.
Both functions create a MsgVoteOnObservedInboundTx message in lines 139-154 and 214-228.
However, the Sender is set to the emittingContract address in line 141 and 216, which is the address of the transaction signer (i.e., sender - tx.origin). In the very special case that the transaction is a contract creation transaction, the To address is set to nil, and thus the Sender is set to nil as well.
In both cases, it is problematic as the cctx’s Sender is used in case the outbound cctx is reverted and will be set as the receiver of the refund. As a result, the refund is potentially sent to the wrong recipient.
Moreover, the Sender is provided to the ZetaConnectorEth.onReceive (or non-eth connector) function as the zetaTxSenderAddress address. This sender address can be used to implement access protection on the receiving contract by using the ZetaInteractor.isValidMessageCall modifier. However, as the zetaTxSenderAddress is unreliably set (always to the transaction signer’s address), this limits the functionality and prevents the use of an intermediary contract on the zEVM.
Similarly, in the HandleEVMDeposit function, calling the ProcessLogs function to process any logs that are a result of a zEVM deposit, and providing the msg.Receiver (i.e., to) as the emittingContract address, results in similar issues.
Summary
Using an intermediary contract on the zEVM that interacts with the ZetaConnectorZEVM contract causes refund issues and access protection issues on the receiving contract.
Additionally, interacting with the ZetaConnectorZEVM contract on the zEVM, as part of a contract creation transaction, is discouraged and leads to lost assets when attempting to refund a failed cctx. This should be clearly documented to prevent users from losing assets.
Recommended mitigation steps
Consider using the zetaTxSenderAddress address of the ZetaSent event as well as the from address of the Withdrawal event as the Sender of the cctx.
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 code sets the cctx Sender to the transaction signer (tx.origin) rather than the address that emitted the event, so refunds and access checks use the wrong address.
Impact
Refunds for failed outbound transactions could be sent to the wrong recipient, allowing theft of assets, and access protection on receiving contracts is unreliable.
What the attacker needed
Intermediary contract on zEVM; craft a failing cctx
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 assets across chains, a record called a cross-chain transaction (cctx) is created. If something goes wrong, the assets are refunded to the sender address stored in that record. Here, that address is set to the person who signed the transaction, not the contract that actually sent the assets, so refunds can go to the wrong place and be stolen.
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.