Loading...

Loading
WalletGuard Audit: EVMBench: 2024-06-thorchain | Score: 6.0/10

medium(9)

low(6)
Code Quality Observations(2)
Gas Optimizations(2)

Decentralization

2 centralization points identified

*
Missing Two-Step Ownership Transfer in THORChain_Aggregator

Loss of owner key results in permanent inability to call rescueFunds, locking any ETH held in the aggregator. This is a property of the ownership model the buyer should know about.

rescueFunds()
*
THORChain_Router transferOut and transferOutV5 are publicly callable by any address

The permissionless vault operation is an acknowledged THORChain design choice; the ETH routing path enables event spoofing from arbitrary callers but does not drain held user funds without vault key compromise.

transferOut()

Attack Chain Analysis

Full ETH Drain via Unrestricted Router Target and Balance Sweepcritical

An attacker exploits two cooperating flaws in swapIn. First, the balance sweep bug causes safeAmount to equal address(this).balance rather than just the current swap's output, inflating the ETH forwarded. Second, the tcRouter parameter has no whitelist, so the attacker supplies a malicious contract implementing a depositWithExpiry interface. The aggregator calls depositWithExpiry on the malicious contract with the full contract balance, effectively transferring all accumulated ETH to the attacker. Neither flaw alone is as severe: the balance sweep without a malicious router only inflates a legitimate deposit, while the unrestricted router without the balance sweep only redirects the current swap's proceeds. Together they enable complete ETH drainage in a single transaction.

swapIn uses entire contract ETH balance instead of swap proceeds onlyUnrestricted tcRouter parameter in swapIn allows arbitrary external call with ETH
ERC-20 Fund Loss via Aggregator Failure with No Fallback Recoveryhigh

The transferOutAndCallV5 function in THORChain_Router transfers ERC-20 tokens to an aggregator target and then calls swapOutV5. If the aggregator fails or reverts, the router does not recover the tokens and has no fallback transfer to the recipient. An attacker controlling or influencing the aggregator can deliberately cause swapOutV5 to fail, leaving ERC-20 tokens stranded in the aggregator. If the aggregator also lacks a rescue mechanism, user funds are permanently locked. The unrestricted target address in transferOutAndCall means a vault operator could direct this flow at a malicious or non-functional aggregator.

transferOutAndCallV5 ERC20 Path Does Not Check or Handle dexAgg Failure — Funds Left in AggregatorPermissionless transferOut and transferOutAndCall in AvaxRouter Allow Any Caller to Drain Vault Allowances

Agent Coverage

AgentStatusFindingsSeverityConfidenceDurationCoverage
reentrancysuccess7
2M1L
81%1.3mCross-function reentrancy in AvaxRouter and THORChain_Router (deposit, transferOut, transferAllowance, returnVaultAssets), ERC-20 callback reentrancy via malicious transferFrom (EvilToken pattern), CEI pattern compliance in all router deposit and transfer functions, nonReentrant modifier placement and coverage on all public/external state-modifying functions, Balance accounting in swapIn (pre-existing ETH/AVAX balance vulnerability), tx.origin usage in ETH_RUNE.transferTo(), safeApprove usage in AvaxAggregator, transferOutAndCallV5 ERC-20 stranding risk, EvilCallback reentrancy attempt via receive() hook, batchTransferOutV5 and batchTransferOutAndCallV5 nonReentrant guard coverage, depositWithExpiry expiration check ordering, _transferOutAndCallV5 failure recovery paths
access controlsuccess10
1H2M2L
82%1.7mtx.origin authorization patterns in ETH_RUNE.transferTo(), Access control on bridge router functions (transferOut, transferOutAndCall, deposit), Reentrancy guards across all router and aggregator contracts, ETH balance sweep vulnerability in swapIn functions, Signature/authentication patterns (none present - not applicable), Initialization safety (no upgradeable proxies - not applicable), Ownership patterns in THORChain_Aggregator, safeApprove usage and potential DoS via non-zero allowance, Deposit expiry bypass via direct deposit() call, Arbitrary target calls in transferOutAndCall functions, EvilCallback and EvilToken test contracts for reentrancy analysis, Cross-chain replay attacks (THORChain uses memo-based validation off-chain), selfdestruct usage (none present), delegatecall usage (none present)
economicsuccess10
2M
81%1.6mFlash loan / balance manipulation in swapIn (address(this).balance usage), Reentrancy across all router and aggregator functions, Access control on vault management functions (transferOut, transferAllowance, returnVaultAssets), Oracle manipulation - no price feeds present, N/A, ERC-20 approval patterns (safeApprove with wrong amounts, dangling approvals), tx.origin usage in ETH_RUNE transferTo, Batch function ETH distribution correctness (batchTransferOutAndCallV5), Fee-on-transfer token handling in safeTransferFrom, Governance attack surface - no governance present, N/A, MEV/sandwich exposure on swapOut functions, Cross-contract composability with external DEX routers, THORChain_Router deposit/withdrawExpiry nonReentrant coverage, EvilCallback/EvilToken test contract analysis, USDT and ETH_RUNE ERC-20 standard compliance
logic validationsuccess9
1H1M
88%1.3mAvaxAggregator swapIn and swapOut ETH/AVAX balance handling, THORChain_Aggregator swapIn balance handling and approval logic, THORChain_Router deposit, transferOut, transferAllowance, returnVaultAssets access control, AvaxRouter deposit, transferOut, transferAllowance access control, Reentrancy guard implementation across all router contracts, Integer arithmetic in Solidity 0.8.x contracts (overflow protection built-in), ETH_RUNE tx.origin usage in transferTo, EvilCallback and EvilToken reentrancy test contracts, Batch function DoS via unbounded loops, Fee-on-transfer token handling in aggregators, Vault allowance underflow protection (Solidity 0.8+ reverts), transferOutAndCall and transferOutAndCallV5 fallback behavior, safeTransferFrom balance-delta pattern correctness
code qualitysuccess11
79%1.6mReentrancy guards across all router and aggregator contracts, Access control on vault/allowance management functions, ETH/token balance accounting in swapIn/swapOut flows, tx.origin usage in ETH_RUNE transferTo, Fee-on-transfer token handling in safeTransferFrom and approve flows, Arbitrary external call targets (tcRouter, tcVault) in aggregators, ERC-20 compliance of Token, ETH_RUNE, EvilToken, StealToken, TetherToken, Integer overflow/underflow in Solidity 0.7.6 contracts (SafeMath usage), Vault allowance accounting correctness, Cross-function reentrancy via EvilCallback and EvilToken, depositWithExpiry expiration check, returnVaultAssets ETH forwarding, transferOutAndCall fallback behavior, batchTransferOutV5 unbounded loop DoS potential, Storage variable optimization opportunities
compiler bugssuccess3
1H1M
88%40.8sAvaxAggregator.swapIn and swapOut - ETH balance handling and parameter validation, AvaxRouter deposit, transferOut, transferOutAndCall, returnVaultAssets - reentrancy, allowance accounting, THORChain_Router (both chain/ and ethereum/ versions) - all transfer functions, batch operations, reentrancy guards, THORChain_Aggregator and THORChain_Failing_Aggregator - swapIn, swapOut, swapOutV5, rescueFunds, ETH_RUNE token - transferTo tx.origin pattern, mint access control, burn functions, EvilToken and EvilCallback - understanding of existing attack vectors already modeled, USDT (TetherToken) - fee-on-transfer behavior impact on router safeTransferFrom, Compiler bug checks - pragmas are 0.8.9, 0.8.22, 0.7.6, 0.4.17; no affected ABIEncoderV2 storage array patterns found, Reentrancy across all router functions - nonReentrant guards in place and correctly structured, Access control on rescueFunds and admin functions, Integer overflow/underflow - 0.8.x contracts use built-in checks; 0.7.6 and 0.4.x use SafeMath
assembly safetysuccess9
1M3L
81%1.5mFull codepoint scan for non-ASCII characters, RTLO (U+202E), zero-width joiners, Cyrillic homoglyphs — none found, Inline assembly blocks — none present in any contract, AvaxAggregator and THORChain_Aggregator swapIn/swapOut logic, AvaxRouter and THORChain_Router deposit, transferOut, transferAllowance, returnVaultAssets, transferOutAndCall, transferOutAndCallV5, batchTransferOutV5, batchTransferOutAndCallV5, Reentrancy guard implementation and cross-function reentrancy vectors, ETH/AVAX balance accounting in aggregator swap flows, ETH_RUNE tx.origin usage in transferTo, ERC20 allowance patterns (safeApprove without reset), Access control on vault management functions, EvilToken and EvilCallback reentrancy test contracts, msg.value reuse in batch functions, THORChain_Failing_Aggregator swapOutV5 always-revert design, USDT/TetherToken fee-on-transfer compatibility with router safeTransferFrom, SushiRouterSmol and WETH helper contracts, StealERC20Token transfer-based token theft pattern, Integer overflow/underflow (all critical contracts use 0.8.x with built-in checks except ETH_RUNE at 0.7.6 with SafeMath)
l2 specificsuccess12
86%1.5mReentrancy guards across all router and aggregator contracts, Cross-function reentrancy (deposit, transferOut, transferAllowance sharing _status), ETH/AVAX balance sweeping in swapIn functions, tx.origin usage in ETH_RUNE.transferTo, ERC20 approval patterns (safeApprove without zero-reset), Vault allowance accounting in _adjustAllowances and _vaultAllowance, transferOutAndCallV5 ERC20 failure path - missing fallback for stuck tokens, transferOutAndCall ETH failure path - fallback to recipient then vault, batchTransferOut* iteration with external calls, safeTransferFrom balance-delta pattern for fee-on-transfer tokens, EvilERC20Token and EvilCallback test contracts for reentrancy attack vectors, StealToken transfer side-effect pattern, depositWithExpiry expiration check, returnVaultAssets ETH forwarding, THORChain_Aggregator.rescueFunds owner access control, No L2-specific predeploys or cross-domain messengers found (chain-agnostic Ethereum/Avalanche contracts)

Scope and Methodology

Target0x878d8d03dd5efb9251dc2f520f96fceade756687
ChainEthereum
Complexitycomplex
Standards DetectedERC20
Analysis ModelClaude Sonnet 4.6
Specialist Agents9
Agent Types
reentrancyaccess controleconomiclogic validationcode qualitycompiler bugsassembly safetyl2 specific
Scope TemplateGeneral Smart Contract (auto-selected)
MethodologyAutomated multi-agent analysis. Each specialist agent independently reviews the contract source code for vulnerabilities in its domain. Findings are deduplicated, scored, and synthesized into this report.
Findings are gated by demonstrated exploit feasibility against the analyzed contract. Observations that describe accepted blockchain behavior, consensus-layer issues, or infeasible preconditions are excluded from scored findings. See scope policy.

Severity Classification

CriticalDirect loss of funds or complete protocol compromise. Exploitable with high likelihood. Requires immediate remediation.
HighSignificant risk to funds or protocol integrity. Conditionally exploitable or requires specific circumstances. Should be fixed before deployment.
MediumLimited or conditional impact. May require unlikely conditions to exploit. Should be addressed but not blocking.
LowMinor impact. Best practice deviations, minor inefficiencies. Fix when convenient.
InformationalNo direct security impact. Code quality observations, gas optimizations, style recommendations.

Limitations

This automated audit has inherent limitations. The following areas are not covered.

Disclaimer

This report is an automated point-in-time assessment and does not guarantee protection against all possible attacks. It does not cover off-chain components, economic modeling, or business logic correctness unless explicitly noted. Changes to the contract after the audit commit are not reviewed. This is not financial or legal advice. WalletGuard, powered by Gestalt Labs, provides this analysis as-is with no warranty of completeness.

Embed Badge
WalletGuard Audit Badge
Markdown
[![WalletGuard Audit](https://walletguard.ai/api/badge/4f6e1d28-7e42-4f71-9b65-43415ca0a58d)](https://walletguard.ai/audit/4f6e1d28-7e42-4f71-9b65-43415ca0a58d)
HTML
<a href="https://walletguard.ai/audit/4f6e1d28-7e42-4f71-9b65-43415ca0a58d">
  <img src="https://walletguard.ai/api/badge/4f6e1d28-7e42-4f71-9b65-43415ca0a58d" alt="WalletGuard Audit Badge" />
</a>
WalletGuardSecured by WalletGuard
How We AuditView all reports for this contractUID: 0x3e2cf2b1...d15af7This report was produced by generic vulnerability pattern matching.
Modelsonnet
Duration3.8m
CostN/A
Tokens- in / - out
Source verified via Etherscan