CrossChainExecutor contracts do not update the necessary states for failing transactions
The CrossChainExecutor contracts do not record that a batch of calls was already attempted, so a failing batch leaves no state change and the transport layer keeps retrying it. An attacker could relay calls that always fail, draining the transport layer client's gas, and a retried batch reverts with the wrong error instead of indicating it was already executed.
AkshaySrivastav Follow with ladboy233, hihen and 1 other
Originally disclosed on Code4rena
Submitted by AkshaySrivastav, also found by ladboy233, hihen, and csanuragjain
EthereumToOptimismExecutor.sol#L45-L59 EthereumToArbitrumExecutor.sol#L31-L45
The CrossChainExecutorArbitrum and CrossChainExecutorOptimism contracts both use CallLib library to invoke Calls on external contract. As per the CallLib library implementation, any failing Call results in the entire transaction getting reverted.
The CrossChainExecutor contracts does not store whether the calls in CallLib.Call[] were already attempted which failed.
This creates several issues for CrossChainExecutor contracts.
- Offchain components can be tricked to submit failing
Call[]s again and again. This can be used to drain the offchain component of gas. - Once a failing
Call[]was invoked (which failed) and if again the sameCall[]is invoked, the transaction should revert withCallsAlreadyExecutederror but it reverts withCallFailureerror. - It is difficult to determine whether a to-be executed
Call[]is pending or the invocation was already tried but failed.
PoCs for the above issues are listed below.
Proof of Concept
Scenario 1
contract Foo {
function bar() public {
for(uint256 i; ; i++) {}
}
}
- The attacker relays the
Foo.bar()call in theCrossChainRelayercontract withmaxGasLimitas the_gasLimitparameter. - The transport layer tries to invoke the
Foo.bar()call by calling theCrossChainExecutor.executeCalls(). This transaction reverts costing the transport layer clientmaxGasLimitgas. - Since no state updates were performed in
CrossChainExecutor, the transport layer still assumes the relayed call as pending which needs to be executed. The transport layer client again tries to execute the pending relayed call which reverts again. - Repeated execution of the above steps can deplete the gas reserves of transport layer client.
Scenario 2
contract Foo {
function bar() public {
revert();
}
}
- The attacker relays the
Foo.bar()call in theCrossChainRelayercontract. - The transport layer tries to invoke the
Foo.bar()call by calling theCrossChainExecutor.executeCalls(). This transaction gets reverted. - Since the relayed calls still seems as pending, the transport layer tries to invoke the
Foo.bar()call again. This call should get reverted withCallsAlreadyExecutederror but it gets reverted withCallFailureerror.
Recommended Mitigation Steps
The CrossChainExecutor contract should store whether a relayed call was attempted to be executed to make sure the execution cannot be tried again.
The CallLib library can be changed to not completely revert the transaction when any individual Call gets failed.
Alex the Entreprenerd (judge) commented:
Not convinced by High Severity but the fact that you cannot determine whether calls were already attempted seems valid.
PierrickGT (PoolTogether) confirmed, but disagreed with severity and commented:
Indeed, in the current implementation, it’s pretty difficult to know which calls succeeded and which calls failed.
So we’ve added two events:
event CallSuccess(uint256 callIndex, bytes successData);event CallFailure(uint256 callIndex, bytes errorData);When a Call fails, we emit the
CallFailureevent and exit early the loop going through the batch calls.CallLib.executeCallswill returnfalseand then the transaction will revert with the custom errorExecuteCallsFailed.If all calls have executed successfully,
CallLib.executeCallswill returntrueand then theExecutedCallsevent will be emitted.This way, it’s possible to know which calls succeeded and which didn’t. If one Call fails, the entire transaction must revert cause the user may have intended to execute all the calls in one transaction and maybe some calls depends on others to succeed.
I think this issue should be labeled as 2 (Med Risk) since it would indeed have been difficult for the transport layer client to figure out why the transaction failed and if it was worth replaying in the future.
Alex the Entreprenerd (judge) commented:
I think the finding was well thought out and can tell it helped shaped the protocol.
I believe Medium severity could be reasonably marked, however I think Low Severity to be the most appropriate one.
Specifically:
- No loss of funds (beside gas happens)
- Similar architectures (e.g Chainlink Keepers), share the similar “cannot tell if failed or not”
- The responsibility for determining if the tx will fail is on the caller (relayer)
For those reasons I believe QA Low (Notable finding for Relayer / Service Operators) to be the most appropriate.
I will flag this during triage to get more opinions.
Alex the Entreprenerd (judge) commented:
Some additional thinking I’m having is that a failed tx could remain un-broadcasted for an indefinite amount of time, and this could create issues for the receiving contract if / when the contract is made to not revert.
Specifically the fact that a failed tx can be relayed in the future (no expiration) seems to create a risk that can cause loss of value, which leads to me believe there is a valid argument for Medium Severity.
Alex the Entreprenerd (judge) decreased severity to Medium and commented:
After further thinking, I believe the most appropriate severity is Medium.
The Warden has shown how the code allows the execution of old failed txs, while that is fine, I believe the lack of expiry can create situations in which a old message could be broadcasted and the broadcasting of it could cause a non idempotent behavior.
The simplest example I can think of would be an unpause tx, that fails up until a set of contracts are paused, which would put a paused system (probably because of an exploit or the need for immediate stop) back into the unpaused state.
While the externalities are multiple, I believe because:
- The general nature of the system
- The lack of expiration for old calls
That Medium Severity is the most appropriate.
Personally I would recommend considering a way to make calls expire after some time to avoid potential gotchas (or integrators may want to verify that via a nonce system or similar)
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 executor reverts the whole transaction on any failed call and never persists that the batch was attempted, so failed batches remain indistinguishable from pending ones.
Impact
Repeated retries of failing batches could deplete the transport layer client's gas reserves, and a failed batch could be relayed later without expiry, potentially causing non-idempotent behaviour; no funds are lost beyond gas.
What the attacker needed
Attacker can relay calls; transport layer retries failed batches
The fix
The executor should record that a batch was attempted so it cannot be retried, and the call library should not revert the whole transaction on a single failed call; the team added success and failure events and an early exit on failure.
How it was found
- The attacker relays a call to a function that always fails, such as one that loops forever or reverts.
- The transport layer calls the executor to run the batch, and the transaction reverts, costing the gas limit.
- Because no state was updated, the batch still looks pending and the transport layer retries it, reverting again.
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 relayer service sends batches of calls to a contract on another chain. If one call in the batch fails, the whole transaction is undone, including any note that the batch was tried. So the service cannot tell whether the batch is still waiting or already failed, and it may keep paying gas to retry it forever.
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.