CrosschainDistributor: Not paying relayer fee when calling xcall to claim tokens to other domains
The CrosschainDistributor contract calls xcall to claim tokens on another domain without paying the relayer fee. As a result, the transaction is not relayed on the target chain and the user does not receive the claimed tokens unless they manually bump the fee.
0xhacksmithh Follow with AkshaySrivastav, Czar102 and 10 others
Originally disclosed on Sherlock
Source: https://github.com/sherlock-audit/2023-06-tokensoft-judging/issues/143
Found by
0xhacksmithh, AkshaySrivastav, Czar102, GREY-HAWK-REACH, Vagner, jkoppel, kutugu, n33k, pengun, pep7siup, qbs, r0bert, tsvetanovv
Summary
CrosschainDistributor is not paying relayer fee when calling xcall to claim tokens to other domains. The transaction will not be relayed on target chain to finnalize the claim. User will not receive the claimed tokens unless they bump the transaction fee themself.
Vulnerability Detail
In _settleClaim, the CrosschainDistributor is using xcall to claim tokens to another domain. But relayer fee is not payed.
id = connext.xcall( // <------ relayer fee should be payed here
_recipientDomain, // destination domain
_recipient, // to
address(token), // asset
_recipient, // delegate, only required for self-execution + slippage
_amount, // amount
0, // slippage -- assumes no pools on connext
bytes('') // calldata
);
Without the relayer fee, the transaction will not be relayed. The user will need to bump the relayer fee to finnally settle the claim by following the instructions here in the connext doc.
Impact
User will not receive their claimed tokens on target chain.
Code Snippet
Tool used
Manual Review
Recommendation
Help user bump the transaction fee in Satellite.
Discussion
cr-walker
Hmm, this would be a valid issue in general but Connext is paying for relayer fees in this case, i.e. a zero fee cross-chain transaction is valid in this case (and on https://docs.connext.network/developers/guides/estimating-fees). @LayneHaber any thoughts on validity?
cr-walker
I am marking this as valid since auditors would not know the plan to have Connext pay this fee in this case and we'll change this anyway (it seems strictly better to make the function payable and pass along message value like this:
function _settleClaim(
address _beneficiary,
address _recipient,
uint32 _recipientDomain,
uint256 _amount
) internal virtual {
bytes32 id;
if (_recipientDomain == 0 || _recipientDomain == domain) {
token.safeTransfer(_recipient, _amount);
} else {
id = connext.xcall{value: msg.value}(
_recipientDomain, // destination domain
_recipient, // to
address(token), // asset
_recipient, // delegate, only required for self-execution + slippage
_amount, // amount
0, // slippage -- assumes no pools on connext
bytes('') // calldata
);
}
emit CrosschainClaim(id, _beneficiary, _recipient, _recipientDomain, _amount);
}
LayneHaber
Agree that it is strictly better to have the fees be an option on the contract itself. We can always pass in 0 and the xcall will not fail, which works for our distribution but likely not for others.
Shogoki
Is there a hint to this behaviour in the connext docs to this behaviour?
LayneHaber
docs on the relayer fee behavior can be found here -- this specifically outlines bumping fees, but that implies if the fee is low enough the xcall goes through, it's just not processed on the destination chain.
there is no documentation on fee-sponsoring though, and agree that we should make this payable!
LayneHaber
Fixed: https://github.com/SoftDAO/contracts/pull/8
cr-walker
Closing because fix has been merged into repo.
cr-walker
Reopening - I think I'm supposed to leave this open until the fix has been reviewed!
maarcweiss
Fixed by sending the value directly from the _settleClaim function.
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 contract calls xcall without attaching a relayer fee, so the cross-chain message is not processed on the destination chain.
Impact
Users will not receive their claimed tokens on the target chain unless they bump the relayer fee themselves.
What the attacker needed
Claiming tokens to another domain
The fix
The function was made payable so that the relayer fee can be passed along with the xcall.
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 claim tokens on a different blockchain, a relayer service delivers the message. That service usually needs a small fee. Here the contract sent the message without any fee, so the relayer ignored it and the tokens never arrived.
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.