Back to Blog

Loopring (LRC) 协议事件

Code Auditing
December 3, 2020
6 min read

Hash(ti)(mod2248)=[b0,b1,,b247]T,其中 bi{0,1}\text{Hash}(t_i) \pmod{2^{248}} = [b_0, b_1, \dots, b_{247}]^T, 其中\ b_i \in \{0, 1\}

2020年11月,Loopring的LRC协议费用金库(Protocol Fee Vault)中出现了一个关键漏洞,攻击者利用了访问控制的薄弱环节,并通过闪电贷攻击操纵了代币价格。此事件凸显了强大的访问控制和持续的DeFi安全监控对于防止代价高昂的攻击的重要性。

Loopring (LRC) 协议事件简介

2020年末,包括Pickle Finance和88mph在内的多个基于以太坊的DeFi平台经历了安全事件。为了检测此类漏洞,BlockSec开发了ThunderForecast系统,该系统识别出涉及异常大的交易汇率差异以及同一外部拥有账户(EOA)持续获得以太币的疑似交易。

通过我们的EthScope系统,我们分析了这些交易,并发现了一个针对Loopring金库协议(特别是LRC协议费用金库 LRCPFV)中漏洞的攻击。本博客文章将详细介绍此次攻击、其影响以及为DeFi安全社区带来的经验教训。


LRC协议费用金库概述

Loopring是以太坊上的一个开源去中心化交易所(DEX)协议。其原生代币LRC(ERC-20)在该生态系统中使用。Loopring的金库协议,称为LRC协议费用金库(LRCPFV),存储协议费用并允许将交易费用兑换成LRC代币。

LRCPFV中的漏洞函数是sellTokenForLRC,它允许在没有适当访问控制的情况下将代币兑换成LRC,使得任何人都可以调用它。

function sellTokenForLRC(
    address token,
    uint amount
)
    external
    nonReentrant
{
    require(amount > 0, "ZERO_AMOUNT");
    require(token != lrcAddress, "PROHIBITED");

    address recipient = tokenSellerAddress == address(0) ? owner : tokenSellerAddress;

    if (token == address(0)) {
        recipient.sendETHAndVerify(amount, gasleft());
    } else {
        token.safeTransferAndVerify(recipient, amount);
    }

    require(
        tokenSellerAddress == address(0) ||
        ITokenSeller(tokenSellerAddress).sellToken(token, lrcAddress),
        "SELL_FAILURE"
    );

    emit TokenSold(token, amount);
}

由于此函数缺乏访问控制,攻击者可以反复调用它来操纵代币价格并从套利机会中获利。


攻击详情

我们分析了一个代表性的攻击交易:0x00b2c...。攻击涉及六个关键步骤:

  1. 闪电贷: 从闪电贷提供商(0xEB7e...)借入3,773.88 ETH。
  2. 初始兑换: 在Uniswap V1-LRC上将3,773.88 ETH兑换成5,014.68 LRC,汇率为1 ETH = 1.32878 LRC。
  3. 费用金库兑换: 通过调用有漏洞的sellTokenForLRC函数,将LRCPFV中存储的0.231 ETH费用兑换成0.000219 LRC。此未经授权的调用操纵了Uniswap上的LRC价格,使其相对于ETH的价值急剧增加(1 ETH = 0.00094 LRC)。
  4. 盈利兑换: 在Uniswap V1-LRC上将5,014.68 LRC兑换回3,774.09 ETH,由于操纵的价格,额外获得了0.215 ETH。
  5. 贷款偿还: 偿还3,773.88 ETH的闪电贷。
  6. 利润转移: 将0.215 ETH的利润发送到攻击者的EOA。

此漏洞利用了闪电贷攻击,结合价格操纵和金库合约中缺乏访问控制。


攻击的影响和规模

分析的交易发生在2020年10月13日。根据CoinGecko的数据,当时LRC的价格约为0.0005175 ETH。

我们的调查发现:

  • 恶意合约: 攻击者部署了3个(0xa896...0x414a...0xd91d...)。
  • 攻击量: 自LRCPFV部署的区块9,644,449以来,攻击者的EOA(0x81e8...)发起了90笔交易。
  • 最高利润: 一笔交易(0x33eab...)产生了9.89 ETH的利润。
  • 总利润: 约80.97 ETH(截至2020年10月1日,约合48,849美元)。

根本原因是sellTokenForLRC函数缺少访问控制,使得重复利用成为可能。


开始使用Phalcon Security

检测所有威胁,警报重要事件,并阻止攻击。

立即免费试用

经验教训与结局

随着以太坊DeFi生态系统的发展,访问控制漏洞等安全挑战变得越来越关键。虽然引人注目的攻击常常吸引眼球,但不太显眼的漏洞也会造成重大的经济损失,正如此次事件所示。

Loopring因这次漏洞损失了约80.97 ETH,这凸显了进行严格的智能合约审计和持续安全监控的必要性。

对于DeFi协议而言,实施严格的访问控制,利用BlockSec的智能合约审计Phalcon Security等工具,以及主动的风险管理,对于保护数字资产至关重要。


探索MetaSleuth调查

追踪资金流并为调查建立证据

立即免费试用

事件时间线

  • 2020/11/30: ThunderForecast检测到可疑交易。
  • 2020/12/01: 使用EthScope完成详细分析。
  • 2020/12/02: 向Loopring团队报告漏洞。
  • 2020/12/03: 确认漏洞;实施修复。
  • 2020/12/03: 公开披露事件详情。
  • 2021/01/03: 为该漏洞分配CVE-2020-35962。

参考和进一步阅读

Sign up for the latest updates
The Decentralization Dilemma: Cascading Risk and Emergency Power in the KelpDAO Crisis
Security Insights

The Decentralization Dilemma: Cascading Risk and Emergency Power in the KelpDAO Crisis

This BlockSec deep-dive analyzes the KelpDAO $290M rsETH cross-chain bridge exploit (April 18, 2026), attributed to the Lazarus Group, tracing a causal chain across three layers: how a single-point DVN dependency enabled the attack, how DeFi composability cascaded the damage through Aave V3 lending markets to freeze WETH liquidity exceeding $6.7B across Ethereum, Arbitrum, Base, Mantle, and Linea, and how the crisis forced decentralized governance to exercise centralized emergency powers. The article examines three parameters that shaped the cascade's severity (LTV, pool depth, and cross-chain deployment count) and provides an exclusive technical breakdown of Arbitrum Security Council's forced state transition, an atomic contract upgrade that moved 30,766 ETH without the holder's signature.

Weekly Web3 Security Incident Roundup | Apr 13 – Apr 19, 2026
Security Insights

Weekly Web3 Security Incident Roundup | Apr 13 – Apr 19, 2026

This BlockSec weekly security report covers four attack incidents detected between April 13 and April 19, 2026, across multiple chains such as Ethereum, Unichain, Arbitrum, and NEAR, with total estimated losses of approximately $310M. The highlighted incident is the $290M KelpDAO rsETH bridge exploit, where an attacker poisoned the RPC infrastructure of the sole LayerZero DVN to fabricate a cross-chain message, triggering a cascading WETH freeze across five chains and an Arbitrum Security Council forced state transition that raises questions about the actual trust boundaries of decentralized systems. Other incidents include a $242K MMR proof forgery on Hyperbridge, a $1.5M signed integer abuse on Dango, and an $18.4M circular swap path exploit on Rhea Finance's Burrowland protocol.

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.

Best Security Auditor for Web3

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

BlockSec Audit