When a smart contract calls CrossChainRelayerArbitrum.processCalls , excess submission fees may be lost
The CrossChainRelayerArbitrum.processCalls function sets the excess fee refund address and call value refund address to msg.sender. If a smart contract calls this function, any excess submission fees or call value refunds may be lost because the contract may not have a corresponding address on L2 to receive the refund.
Submitted by cccz, also found by joestakey, enckrish, and Chom
When the user calls CrossChainRelayerArbitrum.processCalls, ETH is sent as the submission fee.
According to the documentation : https://github.com/OffchainLabs/arbitrum/blob/master/docs/L1_L2_Messages.md#retryable-transaction-lifecycle
Credit-Back Address: Address to which all excess gas is credited on L2; i.e., excess ETH for base submission cost (MaxSubmissionCost - ActualSubmissionCostPaid) and excess ETH provided for L2 execution ( (GasPrice x MaxGas) - ActualETHSpentInExecution).
...
Submission fee is collected: submission fee is deducted from the sender’s L2 account; MaxSubmissionCost - submission fee is credited to Credit-Back Address.
The excess submission fee is refunded to the address on L2 of the excessFeeRefundAddress provided when calling createRetryableTicket.
* @notice Put a message in the L2 inbox that can be reexecuted for some fixed amount of time if it reverts
* @dev all msg.value will deposited to callValueRefundAddress on L2
* @param destAddr destination L2 contract address
* @param l2CallValue call value for retryable L2 message
* @param maxSubmissionCost Max gas deducted from user's L2 balance to cover base submission fee
* @param excessFeeRefundAddress maxgas x gasprice - execution cost gets credited here on L2 balance
* @param callValueRefundAddress l2Callvalue gets credited here on L2 if retryable txn times out or gets cancelled
* @param maxGas Max gas deducted from user's L2 balance to cover L2 execution
* @param gasPriceBid price bid for L2 execution
* @param data ABI encoded data of L2 message
* @return unique id for retryable transaction (keccak256(requestID, uint(0) )
*/
function createRetryableTicket(
address destAddr,
uint256 l2CallValue,
uint256 maxSubmissionCost,
address excessFeeRefundAddress,
address callValueRefundAddress,
uint256 maxGas,
uint256 gasPriceBid,
bytes calldata data
) external payable virtual override onlyWhitelisted returns (uint256) {
In CrossChainRelayerArbitrum.processCalls, excessFeeRefundAddress == msg.sender.
uint256 _ticketID = inbox.createRetryableTicket{ value: msg.value }(
address(executor),
0,
_maxSubmissionCost,
msg.sender, // @audit : excessFeeRefundAddress
msg.sender, // @audit: callValueRefundAddress
_gasLimit,
_gasPriceBid,
_data
);
For EOA accounts, the excess submission fees are correctly refunded to their address on L2. However, for smart contracts, since there may not exist a corresponding address on L2, these excess submission fees will be lost.
Also, since the callValueRefundAddress is also msg.sender, according to the documentation, if the Retryable Ticket is cancelled or expired, then the smart contract caller may lose all the submission fees
If the Retryable Ticket is cancelled or expires before it is redeemed, Callvalue is credited to Beneficiary.
Proof of Concept
Recommended Mitigation Steps
Consider allowing the user to specify excessFeeRefundAddress and callValueRefundAddress when calling CrossChainRelayerArbitrum.processCalls.
Alex the Entreprenerd (judge) commented:
Making primary for quality of info.
Ultimately boils down to the idea that contracts won’t get a refund. Will have to think about whether this Med (submitted as such), or Low (self-inflicted).
PierrickGT (PoolTogether) confirmed and commented:
Fixed in this PR: https://github.com/code-423n4/2022-12-pooltogether-findings/issues/63
The
processCallsfunction was intended to be called by an EOA only but it’s true that a contract may want to call it while providing the required_gasLimit,_maxSubmissionCostand_gasPriceBidby an EOA. Passing arefundAddressvariable will allow a contract to refund the EOA that called it.Regarding the severity, I think 2 (Med Risk) is appropriate since the contract would leak value.
Alex the Entreprenerd (judge) commented:
Agree with finding, am conflicted on severity:
- Low -> User sends more than necessary
- Med -> Behaviour, is inconsistent to expected / intended functionality
Will think about it further.
Alex the Entreprenerd (judge) commented:
More specifically, the fact that the system wants to allow refunds and has a bug that prevents that, which would qualify as Medium. (We care if you send more, we will send it back, but because of bug we cannot)
While the pre-condition, in case of a less sophisticated system, would most likely be Low (we don’t care if you send more, don’t send more)
Alex the Entreprenerd (judge) commented:
The Warden has shown an incorrect implementation, which can cause excess fees to be lost.
While the loss of excess fees could be considered Low Severity (self-inflicted), the integration mistake is worth flagging and warrants the increased severity.
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 function hardcodes the refund addresses to msg.sender, which may not be valid on the destination chain for contract callers.
Impact
Excess submission fees and call value refunds may be lost when a smart contract calls the function, as the refund addresses are set to the contract's address which may not exist on L2.
What the attacker needed
Smart contract calls processCalls; excess fees are paid
The fix
The function should allow the caller to specify the excess fee refund address and call value refund address, so that a contract can direct refunds to an EOA.
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 some blockchains, you pay a fee upfront. If you pay more than needed, the extra is usually refunded to your address. In this case, the refund address is set to the caller's address. If the caller is a smart contract, it might not have a matching address on the destination chain, so the refund cannot be delivered and the extra fee is lost.
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.