安全最大化:如何应对DeFi中的MEV攻击

Odaily星球日报Pubblicato 2024-07-18Pubblicato ultima volta 2024-07-18

Introduzione

各类防护手法也是为了维护去中心化交易的排序过程,确保智能合约以公平的方式处理交易,但最根本的解决方法一定是要在矿工和验证者角度来作出调整。

本文 Hash(SHA 1):b366289db9b21c3e9b6668c274e4a179be57a463

编号:链源 Security Knowledge No.008 

安全最大化:如何应对DeFi中的MEV攻击

在过去几年中,区块链经济经历了指数级的增长,尤其是 2022 年 DeFi 生态系统的锁定价值达到峰值 3000 亿美元。Web3发展到现在也已经出现了形形色色的攻击方法和逻辑安全漏洞,从 2017 年开始,最大可提取值(MEV)就常年占据 ETH 链损失金额的攻击方法前列。链源安全团队对 MEV 的基本原理和防护手法做了相关的分析和梳理,希望能够帮助读者提高保护自身资产安全的能力。

MEV 基本原理

安全最大化:如何应对DeFi中的MEV攻击

MEV,全称 Maximum Extractable Value(最大可提取价值),在以太坊的 POW 时代又被称为 Miner Extractable Value(矿工可提取价值),在大量的区块链转为 POS 之后更名为最大可提取价值,因为区块生产者不再是唯一决定交易排序的角色(目前有这两种权限的角色是矿工和验证者,之前只有矿工)。

MEV 是指验证者或排序器等参与者,通过在他们生产的区块内,对交易进行选择性操作(包含交易、排序交易、重排序交易)所获得的利润的度量。

·验证者:负责验证交易和生产区块的参与者;

·排序器:负责决定交易顺序的参与者;

·包含交易:选择哪些交易会被包含在区块中;

·排除交易:选择哪些交易不会被包含在区块中;

·重排序交易:决定交易在区块中的顺序;

当前使用 MEV 的黑客主要针对的是那些获得了空投快照资格、质押代币即将解除锁定的钱包地址,黑客发起这类攻击的前提是需要拿到钱包私钥,然后开启动态 Gas 监控,等待用户的代币或者 Gas 费到账后在同一区块或者相邻区块内发送一笔提取的交易,也就是抢跑交易,这类作为监控的机器人我们称之为 Sweeper 机器人。    

安全最大化:如何应对DeFi中的MEV攻击

防护手法(以 ETH 为例)

首先这类防护有两种思路,由于是要和黑客竞争抢跑的速度,所以说第一种就是提高 Gas price 和交易排序的 Nonce。

因为以太坊的交易手续费=Gas (数量) * Gas Price (单价),每个以太坊区块的 Gas Limit 容量是固定的,那么谁的 Gas Price 更高,谁的交易就优先被打包进区块确认,另外就是以太坊中的 nonce 代表着交易次数,这个概念要结合以太坊本身是基于账户的,所以每一个不同的账户维护着它们各自的 nonce,而以太坊每个账户的每笔交易都会有一个唯一的 nonce,这既可以防止重放攻击(同一个交易被多次处理),又可以让 EVM 虚拟机来明确交易的顺序(比如说某笔交易的 nonce 是 5 ,那么在这笔交易被处理之前,账户中 nonce 为 4 的交易必须已被处理)

第二种思路就是连接确认速度更快,交易混淆度更高的节点    

安全最大化:如何应对DeFi中的MEV攻击

而更换连接节点的话在这里首先推荐的是 TAICHI 网络节点,这个网络是基于 ETH、Solana 等区块链的隐私安全解决方案,它通过引入一系列中继节点来实现交易的混淆和隐私保护,这些节点负责接收用户的交易请求,并将之与其他交易混合,以隐藏交易的来源和目的。

·中继节点:这些节点是 TAICHI 网络的核心,它们负责接收、混合和转发交易;

·交易混合:通过将多个交易混合在一起,中继节点能够有效地隐藏单个交易的来源和目的;

·隐私保护:这种方法能够有效地防止链上数据分析和跟踪,保护用户的隐私;

Sweeper 的工作方式就是监控公共内存池中的交易记录来实现抢先交易,但是 TAICHI 节点允许我们将签名的交易直接提交给矿工,而无需通过公共内存池进行广播,这意味着 Sweeper 很大概率是监控不到的,也就有了抢跑 Sweeper 的可能性(公共内存池指的是那些已经广播但尚未被打包进区块的交易的集合)。    

安全最大化:如何应对DeFi中的MEV攻击

第二个推荐的节点就是 FlashProtect,FlashProtect 是 FlashBots 组织提供的以太坊系统中 MEV 问题的解决方案,它的工作原理是将用户的交易打包后通过 Flashbots 直接发送给矿工,而不是通过公共内存池,来防止恶意矿工和机器人在公共内存池中发现和利用这些交易来使用 MEV 提取资金,它的缺点是交易速度很慢,因为使用的是 Flashbots 内存池,其中的验证者比公共内存池少得多。

安全最大化:如何应对DeFi中的MEV攻击

结语

总的来说各类防护手法也是为了维护去中心化交易的排序过程,确保智能合约以公平的方式处理交易,但最根本的解决方法一定是要在矿工和验证者角度来作出调整。

链源科技是一家专注于区块链安全的公司。我们的核心工作包括区块链安全研究、链上数据分析,以及资产和合约漏洞救援,已成功为个人和机构追回多起被盗数字资产。同时,我们致力于为行业机构提供项目安全分析报告、链上溯源和技术咨询/支撑服务。    

感谢各位的阅读,我们会持续专注和分享区块链安全内容。  

Letture associate

A Record $70 Billion Inflow in 5 Days! Investors Are No Longer Choosy, Buying Gold and Bitcoin Together

Investors are moving beyond "either/or" choices and are simultaneously pouring money into both gold and bitcoin ETFs. Over the past five trading sessions, ETFs tracking these assets attracted a record $7 billion in combined inflows, pushing some of the largest gold and bitcoin funds to the top of the U.S. weekly ETF inflow rankings. This surge was triggered by U.S. Treasury Secretary's announcement to at least double long-term bond buybacks, which initially pressured Treasury yields and the dollar, boosting prices for both assets. Gold has risen about 13% this month, while bitcoin reclaimed the $80,000 level. The synchronized rally signals the return of the "monetary debasement trade." Amid growing concerns over fiscal sustainability and easing financial conditions, investors are seeking scarce assets perceived as outside direct government control. Gold benefits from its traditional safe-haven role, while bitcoin's fixed supply of 21 million coins positions it as a potential hedge. The SPDR Gold ETF (GLD) attracted nearly $3.4 billion, and the iShares Bitcoin Trust (IBIT) saw $1.5 billion in inflows, both ranking in the weekly top ten. Analysts note the momentum behind the flows is as significant as the volume, indicating investors are aggressively adjusting previously underweight positions. While the narrative of hedging against fiscal stress and currency debasement is gaining traction, some analysts question its sustainability, suggesting equities might be a more reliable hedge in the long run.

华尔街日报5 min fa

A Record $70 Billion Inflow in 5 Days! Investors Are No Longer Choosy, Buying Gold and Bitcoin Together

华尔街日报5 min fa

Yangtze Memory: Is It the Second ChangXin?

The largest IPO in the history of the STAR Market is approaching. Yangtze Memory Technologies (YMTC) has filed for a listing on the Shanghai Stock Exchange's STAR Market, aiming to raise 33 billion yuan. This surpasses the previous record set by competitor ChangXin Memory Technologies (CXMT), which raised 29.5 billion yuan and saw its market capitalization surge on its debut. Despite both being leading Chinese memory chipmakers founded in 2016 and operating under the IDM model, the two companies are fundamentally different. CXMT focuses on DRAM, the memory used for temporary data processing, while YMTC specializes in NAND Flash, used for long-term data storage. Industry reports indicate the global DRAM market is significantly larger and more concentrated among three major players, where CXMT ranks as the fourth-largest supplier. The NAND Flash market is more fragmented, with YMTC ranking third globally by shipment volume in Q2 2026, though fifth by revenue due to a stronger focus on consumer-grade products. Experts are divided on whether YMTC can replicate CXMT's explosive market debut. Some analysts believe it is highly unlikely, citing a cooler market environment and YMTC's perceived lower strategic scarcity within the AI supply chain compared to DRAM/HBM-focused companies. They warn that aggressive IPO pricing could lead to downward pressure post-listing. Industry forecasts suggest the DRAM market may remain tight, while the NAND Flash market could face price corrections due to new capacity and weaker demand. Other experts argue that while short-term market sentiment differs, the long-term investment value of both companies is comparable, hinging on future performance and potential breakthroughs in areas like HBM. They believe YMTC's IPO is unlikely to face significant cooling given still-elevated market interest in the semiconductor sector.

marsbit25 min fa

Yangtze Memory: Is It the Second ChangXin?

marsbit25 min fa

Tether Completes Full Audit by KPMG U.S., 150 Tons of Gold and 100,000 BTC Reserves Verified

Tether Announces Completion of Full Financial Audit by KPMG US, Confirming Gold and BTC Reserves Tether CEO Paolo Ardoino announced that the company has completed its first-ever full financial audit by the "Big Four" accounting firm KPMG US. The audit covers the financial statements of Tether International, S.A. de C.V. as of December 31, 2025. Ardoino stated that Tether's delay in obtaining a full audit was primarily due to the previous US administration's hostile stance towards the digital asset industry. With a more favorable regulatory environment, the company engaged KPMG US for the rigorous review. Ardoino emphasized the audit confirmed the strength of Tether's reserves, including over $6 billion in excess equity. He also revealed the company holds substantial physical assets: approximately 150 tons of gold and over 100,000 Bitcoin (BTC). The audit process reportedly involved physically verifying each gold bar. Addressing past criticism and ongoing skepticism, Ardoino pointed to Tether's ability to handle large-scale redemptions, citing the processing of around $7 billion within 48 hours during market stress in 2022. He stated the company plans to undergo annual full financial audits alongside its ongoing quarterly attestation reports. Regarding a potential private equity round, Ardoino clarified that Tether, as a highly profitable company, does not require external capital but acknowledges significant market interest in its shares. The company remains private and mission-focused, aiming to serve users outside the traditional financial system. Looking ahead, Ardoino expressed Tether's interest in potentially funding initiatives like the "Bitcoin Red Team," which uses AI to audit Bitcoin's code and wallet security for vulnerabilities.

marsbit44 min fa

Tether Completes Full Audit by KPMG U.S., 150 Tons of Gold and 100,000 BTC Reserves Verified

marsbit44 min fa

Wall Street's Imagination Can't Keep Up with Nvidia's 'Speed'

NVIDIA once again delivered stellar earnings, with revenue, operating profit, and EPS all hitting record highs for Q2 FY2027 (ended July 26, 2026). Revenue reached $96.221 billion, a 106% YoY increase, while net profit surged 126% to $59.688 billion. The core driver remained the Data Center segment, which grew 117% YoY to $89.023 billion, fueled by ongoing global AI infrastructure investments. The company segmented its Data Center revenue into Hyperscale (large cloud providers) and ACIE (AI cloud, enterprise, industrial, and sovereign AI) categories, with the latter showing faster growth. Notably, shipments of Hopper architecture products to mainland China accounted for less than 1% of Data Center revenue this quarter, and future guidance excludes contributions from China's Data Center compute market. CEO Jensen Huang stated that AI has reached a "tipping point," directly generating productivity and revenue. Financially, NVIDIA maintained robust profitability with a gross margin of 75%. The company also returned approximately $26 billion to shareholders via buybacks and dividends. Looking ahead, product transitions are key. The Blackwell Ultra platform is now in large-scale deployment, while the next-generation Vera Rubin platform, including NVIDIA's first CPU designed for AI agents, has entered full production. The company is also expanding its software ecosystem with tools like the DSX platform for building AI factories. However, NVIDIA's role is evolving beyond chip supplier. It is increasingly involved in financing and facilitating massive AI infrastructure projects, exemplified by its credit support for the SB Energy project in Ohio intended for OpenAI. The company aims to mobilize over $500 billion in third-party capital for such builds, though this raises questions about future capital intensity. For Q3 FY2027, NVIDIA forecasts revenue of approximately $108 billion, signaling continued growth but at a potentially moderated pace. While still dominant, the competitive landscape is intensifying with rivals like AMD and in-house chips from major cloud customers. Key challenges include maintaining growth through the Blackwell-to-Rubin transition, sustaining the pace of AI infrastructure investment, and defending market share as inference workloads grow and competition increases.

marsbit44 min fa

Wall Street's Imagination Can't Keep Up with Nvidia's 'Speed'

marsbit44 min fa

MiniMax Starts Earning Money by Relying on Others

MiniMax, a Chinese AI company known initially for its consumer-facing products like Conch AI, has undergone a significant business shift according to its first post-IPO semi-annual report. While overall revenue grew to $117 million (surpassing its full-year 2025 projection), the revenue structure flipped dramatically. Revenue from its open platform and enterprise AI services surged 703.1% to $73.93 million, now constituting 63.4% of total income. In contrast, revenue from its own AI-native products, though doubling to $42.64 million, dropped from 69.7% to 36.6% of the total. This indicates MiniMax is transitioning from a product-centric to a platform-centric model, embedding its AI capabilities into other companies' workflows and developer applications rather than solely relying on its own apps. The company is now monetizing its core model technology as a service. However, profitability remains a challenge. Despite revenue growth of 283.1%, R&D expenses were $297 million—2.55 times revenue—leading to an adjusted net loss of $293 million. A positive sign is improving gross margin, which rose from 12.1% to 17.9%, suggesting initial progress toward scaling efficiently. Geographically, MiniMax demonstrates a "developed in China, monetized globally" model, with 60.8% of its revenue coming from outside mainland China. The report highlights that MiniMax has successfully moved past proving demand and model capability. The critical next phase is demonstrating that its growing enterprise and developer customer base can generate sufficient, sustainable profit to offset the high inherent costs of AI model training and inference.

marsbit55 min fa

MiniMax Starts Earning Money by Relying on Others

marsbit55 min fa

Trading

Spot
活动图片