Back to Blog

LI.FI 攻击:跨链桥漏洞?不,它是由于未经验证的外部调用!

Code Auditing
March 21, 2022

根据LI.FI项目的报告和Daniel Von Fange的推文,我们注意到LI.FI于2022年3月20日遭受攻击。由于目前还没有对该漏洞的详细技术分析,我们将在下文进一步分析此次攻击。我们发现此次攻击的根本原因是未经验证的外部调用

攻击交易

我们从攻击交易开始,来阐述攻击过程。下面的截图展示了我们交易可视化系统的结果。

如上图所示,整个攻击过程相当简单,**没有部署恶意的智能合约,也没有涉及闪电贷。**攻击者执行的唯一操作是调用CBridgeFacet合约swapAndStartBridgeTokensViaCBridge(0x01c0a31a)函数,该函数随后将各种代币(例如USDC、MATIC、RPL、GNO、USDT、MVI、AUDIO、AAVE、JRT和DAI)从不同的支出者转移到攻击者控制的EOA

代码分析

接着,我们深入研究了受害者逻辑合约的代码。

的代码
的代码
的代码
的代码

根据上述代码,swapAndStartBridgeTokensViaCBridge是源链上跨链交易的入口。

LIFI项目声称他们可以为用户找到最佳路线,称为Smart Routing,这是在链下发生的。具体来说,前端网站计算最佳路线,并将参数(包括交换合约和路由路径)编码到swapAndStartBridgeTokensViaCBridge函数的参数中。

显然,LIFI项目没有考虑到该函数可以被区块链上的任何账户调用,因为该函数对参数(例如白名单和滑点)不做任何检查。最严重的是,CBridgeFacet合约要求用户批准代币,这使用户的资金面临风险。

利润

因此,攻击者通过调用swapAnStartBridgeTokensViaCBridge函数,窃取了LI.FI用户已批准代币给CBridgeFacet合约的资金,该函数随后调用了不同代币的transferFrom函数。损失统计如下表所示。总损失约为59.6万美元,基本与LI.FI项目公布的统计数据一致。

代币 金额 价格
GNO 0.94 310.22
USDC 202,012.28 0.999655
MATIC 3,144.89 1.46
AUDIO 1,202.37 1.10
AAVE 8.99 149.99
RPL 44.86 31.2
MVI 22.95 131.82
USDT 368,745.29 1
DAI 8,421.49 0.999847
JRT 136,805.06 0.03789613

教训

LI.FI是一个跨链桥聚合器,受害者合约是跨链交易的入口。这次的漏洞并非由复杂的跨链逻辑引起,这与其他跨链桥的安全事件类似。相反,这次攻击的根本原因是未经验证的外部调用,这是Solidity中排名前十的常见问题。

随着DeFi项目变得越来越复杂,项目开发者在编写正确的业务代码之外,还需要更加注重编写安全的代码。我们强烈建议项目不要在区块链上部署未经审计的合约。

关于BlockSec

BlockSec是一家开创性的区块链安全公司,于2021年由一群全球知名的安全专家创立。公司致力于增强新兴Web3世界的安全性和可用性,以促进其大规模采用。为此,BlockSec提供智能合约和EVM链安全审计服务,用于安全开发和主动阻止威胁的Phalcon平台,用于资金追踪和调查的MetaSleuth平台,以及供Web3开发者在加密世界高效冲浪的MetaDock扩展。

迄今为止,公司已为MetaMask、Uniswap Foundation、Compound、Forta和PancakeSwap等300多家知名客户提供服务,并已获得Matrix Partners、Vitalbridge Capital和Fenbushi Capital等知名投资者的两轮融资,总额达数千万美元。

官方网站:https://blocksec.com/

官方推特账号:https://twitter.com/BlockSecTeam

Sign up for the latest updates
Weekly Web3 Security Incident Roundup | Apr 6 – Apr 12, 2026
Security Insights

Weekly Web3 Security Incident Roundup | Apr 6 – Apr 12, 2026

This BlockSec weekly security report covers four DeFi attack incidents detected between April 6 and April 12, 2026, across Linea, BNB Chain, Arbitrum, Optimism, Avalanche, and Base, with total estimated losses of approximately $928.6K. Notable incidents include a $517K approval-related exploit where a user mistakenly approved a permissionless SquidMulticall contract enabling arbitrary external calls, a $193K business logic flaw in the HB token's reward-settlement logic that allowed direct AMM reserve manipulation, a $165.6K exploit in Denaria's perpetual DEX caused by a rounding asymmetry compounded with an unsafe cast, and a $53K access control issue in XBITVault caused by an initialization-dependent check that failed open. The report provides detailed vulnerability analysis and attack transaction breakdowns for each incident.

Weekly Web3 Security Incident Roundup | Mar 30 – Apr 5, 2026
Security Insights

Weekly Web3 Security Incident Roundup | Mar 30 – Apr 5, 2026

This BlockSec weekly security report covers nine DeFi attack incidents detected between March 30 and April 5, 2026, across Solana, BNB Chain, Arbitrum, and Polygon, with total estimated losses of approximately $287M. The week was dominated by the $285.3M Drift Protocol exploit on Solana, where attackers combined multisig signer social engineering with Solana's durable nonce mechanism to bypass a zero-timelock 2-of-5 Security Council, alongside notable incidents including a $950K flash loan TWAP manipulation against the LML staking protocol, a $359K Silo Finance vault inflation via an external `wstUSR` market donation exploiting a depegged-asset oracle and `totalAssets()` accounting flaw, and an EIP-7702 delegated-code access control failure. The report provides detailed vulnerability analysis and attack transaction breakdowns for each incident, covering flawed business logic, access control, price manipulation, phishing, and misconfiguration attack types.

Tracing $1.6B in TRON USDT: Inside the VerilyHK Ponzi Infrastructure
Case Studies

Tracing $1.6B in TRON USDT: Inside the VerilyHK Ponzi Infrastructure

An on-chain investigation into VerilyHK, a fraudulent platform that moved $1.6B in TRON USDT through a multi-layered fund-routing infrastructure of rotating wallets, paired payout channels, and exchange exit funnels, with traced connections to the FinCEN-sanctioned Huione Group.

Best Security Auditor for Web3

Validate design, code, and business logic before launch. Aligned with the highest industry security standards.

BlockSec Audit