# ThorChain will be informed wrongly about the unsuccessful ETH transfers due to the incorrect events emissions

THORChain_Router emits TransferOut with the intended recipient even when ETH .send fails and funds bounce back to the vault, so THORChain records a successful outbound that never happened.

- Payout: Audit contest
- Severity: high
- Program: Thorchain
- Found by: Shaheen
- Disclosed: 2024-08-05
- Write-up quality: 7/10
- Original: https://github.com/code-423n4/2024-06-thorchain-findings/issues/17
- Library page: https://bugbountylibrary.com/r/c4%3A2024-06-thorchain%3AH-02
- Tags: area:web3 domain:web3 impact:funds-loss impact:integrity kind:contest platform:code4rena sev:high tech:evm tech:solidity technique:source-review vuln:accounting-error vuln:business-logic

**Target:** THORChain_Router.sol transferOut/_transferOutV5/transferOutAndCall on Ethereum
**Root cause:** transferOut uses to.send() and on failure refunds the vault via msg.sender.transfer(), but still emits TransferOut(msg.sender, to, ...) with the original `to` address instead of the vault, and the log parser's GetTxInItem does not reject events where To equals the calling vault.
**Steps:**
1. Deploy a contract whose receive() reverts or consumes >2300 gas (e.g. `require(msg.value == 0)`).
2. Call `ROUTER1.transferOut(navichAddr, ETH, 400, "ygg+:123", {from: ASGARD1, value: 400})`.
3. Observe navich balance unchanged and vault refunded (minus gas).
4. Inspect tx.logs[0]: event TransferOut with args.to == navichAddr, amount 400, vault ASGARD1 — despite no ETH reaching navich.
**How found:** Read the transferOut flow against the stated invariant that only valid Router events populate txInItem; noticed the failure branch refunds to msg.sender but the emit still uses the original `to`, and that GetTxInItem lacks a check that To != calling vault.
**Exploitation:** A vault operator (or anyone able to trigger an outbound to a gas-heavy/reverting recipient) causes the ETH to bounce back to the vault while the emitted TransferOut tells THORChain the outbound succeeded; the network credits the outbound and updates vault accounting, so the same funds remain in the vault while users are debited — double-spend/loss of funds.
**Insight:** When a contract emits an event describing an external transfer, audit every failure/refund branch to confirm the event's fields reflect the actual recipient — off-chain parsers that trust events will mis-account bounced funds.

## Proof of concept (copied exactly from the original report)

**Test showing bounced ETH emits wrong TransferOut event**

```
it("Should bounce back ethers but emits wrong event", async function () {
        // Contract Address which doesn't accept ethers
        let navichAddr = navich.address;

        let startBalVault = getBN(await web3.eth.getBalance(ASGARD1));
        let startBalNavich = getBN(await web3.eth.getBalance(navichAddr));

        let tx = await ROUTER1.transferOut(navichAddr, ETH, _400, "ygg+:123", {
            from: ASGARD1,
            value: _400,
        });
        
        let endBalVault = getBN(await web3.eth.getBalance(ASGARD1));
        let endBalNavich = getBN(await web3.eth.getBalance(navichAddr));
          
        // Navich Contract Balance remains same & Vault balance is unchanged as it got the refund (only gas fee cut)
        expect(BN2Str(startBalNavich)).to.equal(BN2Str(endBalNavich));
        expect(BN2Str(endBalVault)).to.not.equal(BN2Str(startBalVault) - _400);
          
        // 4 Events Logs as expected
        expect(tx.logs[0].event).to.equal("TransferOut");
        expect(tx.logs[0].args.asset).to.equal(ETH);
        expect(tx.logs[0].args.memo).to.equal("ygg+:123");
        expect(tx.logs[0].args.vault).to.equal(ASGARD1);
        expect(BN2Str(tx.logs[0].args.amount)).to.equal(_400);
          
        //🔺 Event Log of `to` address is Navich Contract instaed of the Vault (actual funds receiver) 
        expect(tx.logs[0].args.to).to.equal(navichAddr);
    });
```

**Navich contract that rejects ETH to force bounce**

```
contract Navich {
    receive() external payable {
        require(msg.value == 0, "BRUH");
    }
}
```

