Back to Blog

CVE-2021–39137 漏洞的野蛮利用简析

Code Auditing
August 28, 2021

CVE-2021-39137 是一个几天前报告并已修复的漏洞。然而,并非所有以太坊节点都已应用该补丁。我们观察到此漏洞已被恶意交易利用。

攻击交易

https://tx.blocksecteam.com/tx/0x1cb6fb36633d270edefc04d048145b4298e67b8aa82a9e5ec4aa1435dd770ce4

此交易有一个对地址 0x4 的 STATICCALL。这是一个预编译的智能合约 dataCopy。参数如下:

inOffset = 0, inSize = 32, retOffset = 7, retSize = 32。

0x4 智能合约

图 1

由于 STATICCALL 的目标是 0x4 预编译合约,它将执行图 1 中的 RunPrecompiledContract 函数。

图 2

图 3

根据图 2/3,0x4 智能合约只是返回 in 指针的引用。

图 4

图 5

图 4 是 STATICCALL 操作码的代码。在第 751 行,args 指向 EVM 内存中的 [inOffset ~ inOffset + inSize ],即 Mem[0:32]。

根据图 5 和对 0x04 代码逻辑(图 2/3)的分析,返回值 (ret) 是指向与 args 相同的内存的引用。也就是说,它也指向 Mem[0:32]。

漏洞

在有漏洞的代码(版本 1.10.7)中,第 762 行将 ret 的内容复制到 Mem[retOffset : retOffset + retOffset],即 Mem[0:32] 复制到 Mem [7:7+32]。此操作意外地改变了 ret 的内容。这意味着 0x4 预编译合约的返回值已被修改。

在修复版本(1.10.8)中,它复制了 ret(第 766 行)。这可以修复漏洞,因为第 767 行的复制不会修改 ret 的内容。

CVE-2021-39137 漏洞由于节点未能及时更新补丁而被恶意交易利用。此缺陷涉及以太坊虚拟机内存操作中的一个缺陷,但已在 1.10.8 版本中修复。为确保系统安全,建议所有以太坊节点立即更新到最新版本。

致谢

本次攻击由 BlockSec 的 Siwei Wu, Yufeng Hu, Lei Wu, Yajin Zhou 分析。

Sign up for the latest updates
Building a Secure Stablecoin Payment Network: BlockSec Partners with Morph
Partnership

Building a Secure Stablecoin Payment Network: BlockSec Partners with Morph

BlockSec has partnered with Morph as an official audit partner for the $150M Morph Payment Accelerator. By offering exclusive discounts on smart contract audits and penetration testing, BlockSec provides institutional-grade security to payment builders, ensuring a safe and resilient foundation for the future of global stablecoin payments.

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.

Venus Thena (THE) Incident: What Broke and What Was Missed

Venus Thena (THE) Incident: What Broke and What Was Missed

On March 15, 2026, an attacker bypassed the THE (Thena) supply cap on Venus Protocol (BNB Chain) through a donation attack, inflating a collateral position to 3.67x the intended limit and borrowing ~$14.9M in assets. Both sides lost money on-chain: Venus was left with ~$2.15M in bad debt after 254 liquidation bots competed across 8,048 transactions, while the attacker retained only ~$5.2M against a $9.92M investment. This deep dive examines what broke across three lines of defense (exposure limits, collateral valuation, and liquidation) and the monitoring gaps that left months of on-chain warning signals unacted upon.

Best Security Auditor for Web3

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

BlockSec Audit