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
FATF’s New Stablecoin Report Signals a Shift to Secondary-Market Compliance
Knowledge

FATF’s New Stablecoin Report Signals a Shift to Secondary-Market Compliance

BlockSec interprets FATF’s March 2026 report on stablecoins and unhosted wallets, explains why supervision is shifting toward secondary-market P2P activity, breaks down the report’s main recommendations and red flags, and shows how on-chain monitoring, screening, and cross-chain tracing can help issuers and VASPs respond with stronger, more effective compliance controls.

Weekly Web3 Security Incident Roundup | Mar 16 – Mar 22, 2026
Security Insights

Weekly Web3 Security Incident Roundup | Mar 16 – Mar 22, 2026

This BlockSec weekly security report covers seven DeFi attack incidents detected between March 16 and March 22, 2026, across Ethereum, BNB Chain, Polygon, and Polygon zkEVM, with total estimated losses of approximately $82.7M. The most significant event was the Resolv stablecoin protocol's infrastructure-key compromise, which led to over $80M in unauthorized USR minting and cross-protocol contagion across lending markets. Other incidents include a $2.15M donation attack combined with market manipulation on Venus Protocol, a $257K empty-market exploit on dTRINITY (Aave V3 fork), access control vulnerabilities in Fun.xyz and ShiMama, a weak-randomness exploit in BlindBox, and a redemption accounting flaw in Keom.

Weekly Web3 Security Incident Roundup | Mar 9 – Mar 15, 2026
Security Insights

Weekly Web3 Security Incident Roundup | Mar 9 – Mar 15, 2026

This BlockSec weekly security report covers eight DeFi attack incidents detected between March 9 and March 15, 2026, across Ethereum and BNB Chain, with total estimated losses of approximately $1.66M. Incidents include a $1.01M AAVE incorrect liquidation caused by oracle misconfiguration, a $242K exploit on the deflationary token MT due to flawed trading restrictions, a $149K exploit on the burn-to-earn protocol DBXen from `_msgSender()` and `msg.sender` inconsistency, and a $131K attack on AM Token exploiting a flawed delayed-burn mechanism. The report provides detailed vulnerability analysis and attack transaction breakdowns for each incident.

Best Security Auditor for Web3

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

BlockSec Audit