Back to Blog

Loopring(LRC)协议事件

Code Auditing
December 3, 2020

2020年11月,以太坊上的许多DeFi平台都遭遇了安全事件,例如Pickle Finance88mph

为了检测DeFi中发生的安全事件,我们开发了ThunderForecast系统。在分析近期交易时,它会发现一类极其可疑的交易。首先,存在一对交易,它们的交易汇率差异超过千倍。其次,调用者(EOA)在每次交易结束时总能获得少量以太坊。我们使用我们研究团队开发的EthScope系统来分析这些交易,并发现这是一个利用Loopring的Vault协议漏洞进行的套利攻击。

LRC协议费用Vault

Loopring是以太坊区块链上一个开源的去中心化交易所(DEX)协议。相应的,LRC是Loopring的代币(ERC-20)。此外,Loopring有一个特定的Vault协议(LRC Protocol Fee Vault)来存储协议费用。在下面的分析中,我们将使用缩写LRCPFV。

    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);
    }

sellTokenForLRC是LRCPFV中的一个函数。该函数允许用户将池中的费用兑换成LRC代币。然而,其开发者在sellTokenForLRC中没有设计任何访问控制,因此任何人都可以调用此函数。最终,攻击者利用此漏洞,获得了发起一系列相同逻辑攻击的机会。攻击的细节将在下面进行分析。

细节

现在,我们将通过一个攻击交易0x00b2c...来揭示更多攻击细节。

共涉及六个步骤:

  • 步骤1:从0xEB7e...进行闪电贷,借入 3773.88 ETH。

  • 步骤2:在Uniswap V1-LRC上将 3773.88 ETH兑换成 5014.68 LRC。此交易的汇率为:1 ETH = 1.32878 LRC。

  • 步骤3:通过调用sellTokenForLRC,在Uniswap V1-LRC池中将LRCFV存储的 0.231 ETH费用兑换成 0.000219 LRC(如前所述,攻击者不应调用sellTokenForLRC)。然而,根据Uniswap V1-LRC使用的价格计算算法,LRC兑ETH的价格在Uniswap V1-LRC上急剧上升。此交易的汇率为:1 ETH = 0.00094 LRC。

  • 步骤4:在Uniswap V1-LRC上将 5014.68 LRC兑换成 3774.09 ETH。基于步骤3,只有少量LRC在Uniswap V1-LRC上被兑换。此操作使得LRC兑ETH在Uniswap V1-LRC上的价值增加。因此,与步骤1相比,攻击者通过在Uniswap V1-LRC上兑换 5014.68 LRC获得了 3773.88 ETH,并额外获利 0.215 ETH。

  • 步骤5:归还 3773.88 ETH闪电贷。

  • 步骤6:将 0.215 ETH发送到攻击者的地址(EOA)。

盈亏

上述分析的交易于2020年10月13日发起。为了计算攻击者和受害者之间大致但可追溯的盈亏,我们使用coingecko获取LRC的价格,即 0.0005175 ETH。另一方面,LRCPFV。

攻击者操纵了步骤4中的价格,通过两次交易获利 0.215 ETH。

攻击规模

基于攻击的特征,我们检测到3个已部署的恶意合约(0xa896...0x414a...0xd91d...)以及自LRCPFV部署以来的90笔由攻击者0x81e8...发起的交易(在第9644449个区块,LRCPFV已部署。(在交易0x33eab...中获得的最大利润甚至达到9.89 ETH。)最终,攻击者通过套利获得了总计80.97 ETH,相当于2020年10月1日的价格为48,849.2美元。

尾声

随着以太坊DeFi生态系统的发展,各种安全问题逐渐显现。然而,社区可能更容易被造成巨大经济损失的攻击所吸引,而不是一些不显眼的攻击。事实上,此次攻击背后的根本原因,即访问控制,也通过发起90笔交易给Loopring造成了相当大的损失(80.97 ETH)。

时间线

  • 2020/11/30:发现可疑交易。
  • 2020/12/01:完成分析。
  • 2020/12/02:向loopring报告。
  • 2020/12/03:漏洞确认,修复上线。
  • 2020/12/03:公布细节。
  • 2021/01/03:分配CVE-2020–35962。
Sign up for the latest updates
Drift Protocol Incident: Multisig Governance Compromise via Durable Nonce Exploitation
Security Insights

Drift Protocol Incident: Multisig Governance Compromise via Durable Nonce Exploitation

On April 1, 2026 (UTC), Drift Protocol on Solana suffered a $285.3M loss after an attacker exploited Solana's durable nonce mechanism to delay the execution of phished multisig approvals, ultimately transferring administrative control of the protocol's 2-of-5 Squads governance with zero timelock. With full admin privileges, the attacker created a malicious collateral market (CVT), inflated its oracle price, relaxed withdrawal protections, and drained USDC, JLP, SOL, cbBTC, and other assets through 31 rapid withdrawals in approximately 12 minutes. This incident highlights how durable nonce-based delayed execution can decouple signer intent from on-chain execution, bypassing the temporal assumptions that multisig security implicitly relies on.

Weekly Web3 Security Incident Roundup | Mar 23 – Mar 29, 2026
Security Insights

Weekly Web3 Security Incident Roundup | Mar 23 – Mar 29, 2026

This BlockSec weekly security report covers eight DeFi attack incidents detected between March 23 and March 29, 2026, across Ethereum and BNB Chain, with total estimated losses of approximately $1.53M. Incidents include a $679K flawed burn mechanism exploit on the BCE token, a $512K spot-price manipulation attack on Cyrus Finance's PancakeSwap V3 liquidity withdrawal, a $133.5K flash-loan-driven referral reward manipulation on a TUR staking contract, and multiple integer overflow, reentrancy, and accounting error vulnerabilities in DeFi protocols. The report provides detailed vulnerability analysis and attack transaction breakdowns for each incident.

Newsletter -  March 2026
Security Insights

Newsletter - March 2026

In March 2026, the DeFi ecosystem experienced three major security incidents. Resolv Protocol lost ~$80M due to compromised privileged infrastructure keys, BitcoinReserveOffering suffered ~$2.7M from a double-minting logic flaw, and Venus Protocol incurred ~$2.15M following a donation attack combined with market manipulation.

Best Security Auditor for Web3

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

BlockSec Audit