ArbitrumBranchBridgeAgent::_performFallbackCall function does not refund users their excess native gas deposit
The ArbitrumBranchBridgeAgent's fallback function does not refund the excess native gas deposit to the user, unlike other branch bridge agents. An attacker could cause users to lose their excess gas fees when a settlement fails and fallback is triggered.
Submitted by Tendency, also found by QiuhaoLi, peakbolt, and rvierdiiev
When a user calls the RootBridgeAgent::retrySettlement function, to retry a failed settlement call to a root chain branch bridge agent (ArbitrumBranchBridgeAgent contract), msg.value (sent in native token) is passed as parameter in the internal call to the _performRetrySettlementCall function.
function retrySettlement(
uint32 _settlementNonce,
address _recipient,
bytes calldata _params,
GasParams calldata _gParams,
bool _hasFallbackToggled
) external payable override lock {
//SNIP
// Perform Settlement Retry
_performRetrySettlementCall(
_hasFallbackToggled,
settlementReference.hTokens,
settlementReference.tokens,
settlementReference.amounts,
settlementReference.deposits,
_params,
_settlementNonce,
payable(settlementReference.owner),
_recipient,
settlementReference.dstChainId,
_gParams,
msg.value // <-- HERE
);
}
In the _performRetrySettlementCall function, native gas tokens are sent to the local branch bridge agent (Arbitrum branch bridge agent contract):
function _performRetrySettlementCall(
bool _hasFallbackToggled,
address[] memory _hTokens,
address[] memory _tokens,
uint256[] memory _amounts,
uint256[] memory _deposits,
bytes memory _params,
uint32 _settlementNonce,
address payable _refundee,
address _recipient,
uint16 _dstChainId,
GasParams memory _gParams,
uint256 _value
) internal {
// SNIP
// Check if call to local chain
} else {
//Send Gas to Local Branch Bridge Agent
callee.call{value: _value}("");
//Execute locally
IBranchBridgeAgent(callee).lzReceive(0, "", 0, payload);
}
}
Assuming the execution fails at a point in ArbitrumBranchBridgeAgent, where fallback is toggled to true, ArbitrumBranchBridgeAgent::_performFallbackCall function is called.
The problem here is, on fallback, the _performFallbackCall function does not refund the excess/remaining native gas deposit to the user:
function _performFallbackCall(address payable, uint32 _settlementNonce) internal override {
//Sends message to Root Bridge Agent
IRootBridgeAgent(rootBridgeAgentAddress).lzReceive(
rootChainId, "", 0, abi.encodePacked(bytes1(0x09), _settlementNonce)
);
}
It’s important to note that in other branch bridge agents, users do receive a refund of their excess native gas deposit from Layer Zero when a similar situation occurs.
Proof of Concept
Recommended Mitigation Steps
Consider refunding users their native gas tokens when performing a fallback call due to a prior failed execution in ArbitrumBranchBridgeAgent:
function _performFallbackCall(address payable refundee, uint32 _settlementNonce) internal override {
//perform a refund
++ require(refundee.call{value: address(this).balance}(""), "Refund failed");
IRootBridgeAgent(rootBridgeAgentAddress).lzReceive(
rootChainId, "", 0, abi.encodePacked(bytes1(0x09), _settlementNonce)
);
}
Assessed type
ETH-Transfer
alcueca (judge) decreased severity to Medium and commented:
With the losses limited to the gas refunds, this can’t be High.
Addressed here.
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 _performFallbackCall function in ArbitrumBranchBridgeAgent does not include logic to refund the excess native gas deposit to the user, unlike other branch bridge agents.
Impact
Users could lose their excess native gas deposit when a settlement fails and fallback is triggered, but the loss is limited to gas refunds.
What the attacker needed
User calls retrySettlement with native gas; Execution fails and fallback is toggled
The fix
The issue was fixed by adding a refund of the native gas tokens in the _performFallbackCall function.
How it was found
- User calls RootBridgeAgent::retrySettlement with native gas deposit.
- The call is forwarded to ArbitrumBranchBridgeAgent.
- Execution fails and fallback is toggled to true.
- ArbitrumBranchBridgeAgent::_performFallbackCall is called.
- The excess native gas deposit is not refunded to the user.
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 a transaction on a blockchain, you pay a fee (gas) in the native token. If you send more than needed, you usually get the extra back. Here, in a specific fallback situation, the extra gas is not returned to the user, so they lose it.
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.