ThorChain will be informed wrongly about the unsuccessful ETH transfers due to the incorrect events emissions #191
Labels
3 (High Risk)
Assets can be stolen/lost/compromised directly
bug
Something isn't working
🤖_03_group
AI based duplicate group recommendation
sufficient quality report
This report is of sufficient quality
Lines of code
https://github.com/code-423n4/2024-06-thorchain/blob/e3fd3c75ff994dce50d6eb66eb290d467bd494f5/ethereum/contracts/THORChain_Router.sol#L196
https://github.com/code-423n4/2024-06-thorchain/blob/e3fd3c75ff994dce50d6eb66eb290d467bd494f5/ethereum/contracts/THORChain_Router.sol#L206
Vulnerability details
One of the main invariant of the protocol is:
In short, this means that, all the events
ThorChain_Router
emits, should be correct.This invariants breaks in the edge cases of the
transferOut()
,_transferOutV5()
,transferOutAndCall()
&_transferOutAndCallV5()
For the sake of simplicity, we will only gonna take a look at the
transferOut()
function.transferOut()
function is used by the vaults to transfer Native Tokens (ethers) or ERC20 Tokens to any addressto
. It first transfers the funds to the specifiedto
address and then emits theTransferOut
event for ThorChain. In case the Native Tokens transfer to theto
address fails, it just refunds or bounce back the ethers to the vault address (msg.sender). Transfer toto
address can fail oftenly, as the function uses solidity's.send
to transfer the funds, if theto
address is a contract which takes more than2300
gas to complete the execution then.send
will returnfalse
and the ethers will be bounced back to the vault address.The problem is that, In the case, when the
.send
will fail and the ethers will bounce back to the vault address, the eventTransferOut
will be wrong. As we can see, when the ethers receiver will be vault not the inputtedto
address, theto
doesn't get updated to the vault's address and the function in the end emits the sameto
, ThorChain is getting informed that the ether receiver is still inputtedto
:Technically, the ETH transfer is unsuccessful but the ThorChain is informed that its successful and the funds are successfully transferred to the specified
to
address. Also, not that thesmartcontract_log_parser
'sGetTxInItem()
function doesn't ignore these trxs at all, as it doesn't check iftxInItem.To
is equal to the calling vault or not.Impact
The network believes the outbound was successful and updates the vaults accordingly, but the outbound was not successful. Resulting in lose of funds for the users.
Proof of Concept
Add this test in the
1_Router.js
:Fund Yggdrasil, Yggdrasil Transfer Out
. Also make sure to deploy theNavich
Contract.Tools Used
Shaheen Vision
Recommended Mitigation Steps
There are multiple solutions to this issue:
.send
failureto
address to the vault when bounce back happenssmartcontract_log_parser
'sGetTxInItem()
.call
which will potentially lower the chance of failure while transferring the ethers (least recommended)Assessed type
Context
The text was updated successfully, but these errors were encountered: