This repository has been archived by the owner on Sep 17, 2023. It is now read-only.
Jeiwan - XProvider
forces increased relayer fees when transferring tokens cross-chain
#325
Labels
Jeiwan
medium
XProvider
forces increased relayer fees when transferring tokens cross-chainSummary
When transferring tokens cross-chain,
XProvider
sends two cross-chain message, while only one can be sent. Whoever triggers cross-chain token transfers (which are required to complete rebalancing) will pay relayer fees twice.Vulnerability Detail
The protocol integrates with Connext to handle cross-chain interactions. XProvider is a contract that manages interactions between vaults deployed on all supported networks and
XChainController
.XProvider
is deployed on each of the network where a vault is deployed and is used to send and receive cross-chain messages via Connext. Among other things,XProvider
handles cross-chain token transfers during vaults rebalancing:XChainController
;XChainController
to a vault.The two functions, besides sending tokens, also update the state in the destination contract:
xTransferToController
callsXChainController.upFundsReceived
to update the counter of vaults that have sent tokens toXChainController
;xTransferToVaults
callsVault.receiveFunds
to set a "funds received" flag in the vault.Both sending tokens and triggering a state change send a cross-chain message by calling
IConnext.xcall
:xSend
callsIConnext.xcall
and sends relayer fee along the call;xTransfer
sends tokens by callingIConnext.xcall
, and it also requires paying relayer fee.Thus, the caller of
xTransferToController
andxTransferToVaults
will have to pay double relayer fee. Since these functions are mandatory for rebalancing, the extra fee will have to be paid by the guardian or any actor who manages vaults rebalancing. However, Connext allows to transfer tokens and make arbitrary calls in one message, while paying relayer fee only once.Impact
xTransferToController
andxTransferToVaults
incur double relayer fees on the caller. The extra cost will have to be paid by whoever manages rebalancing.Code Snippet
xTransferToController
callsxTransfer
andpushFeedbackToXController
–both of them create a cross-chain message:https://github.com/sherlock-audit/2023-01-derby/blob/main/derby-yield-optimiser/contracts/XProvider.sol#L321
xTransferToVaults
callsxTransfer
andpushFeedbackToVault
–both of them create a cross-chain message:https://github.com/sherlock-audit/2023-01-derby/blob/main/derby-yield-optimiser/contracts/XProvider.sol#L362
Tool used
Manual Review
Recommendation
According to the documentation of Connext, the
_callData
argument ofxcall
doesn't need to be empty when transferring tokens:xReceive
can handle both of them together:Also, judging by the implementation of the Connext contract, the passed calldata is executed even when tokens are transferred:
Thus, in
xTransferToController
andxTransferToVaults
, consider passing the calldata of the second calls toxTransfer
.The text was updated successfully, but these errors were encountered: