零时科技 || Spectra攻击事件分析

币界网Published on 2024-07-26Last updated on 2024-07-26

币界网报道:

AZvLVBueS8dPHk3YIbziS3gpLnKyfry9IYBrqrSW.jpeg

背景介绍

2024年7月23日,我们监控到一笔Ethereum链上攻击交易:https://etherscan.io/tx/0x491cf8b2a5753fdbf3096b42e0a16bc109b957dc112d6537b1ed306e483d0744

被攻击的项目为Spectra Protocol,Spectra协议是无需许可的,意味着其服务完全开放供公众使用。任何人都可以随意创建新的市场、交换收益衍生品或成为流动性提供者。此次攻击中,攻击者共获利188, 013asdCRV,折合73, 325USD。 

攻击及事件分析

首先,攻击者查询了asd CRV Token中,地址 0x279a7dbfae376427ffac52fcb0883147d42165ff对Spectra Protocol的授权额度与该地址的asd CRV余额。

图片

接着,攻击者调用execute函数开始针对Spectra Protocol进行攻击,execute函数代码如下:

图片

最终,输入数据会调用_dispatch,该函数的代码如下:

图片

由上述代码我们可以看出,该代码根据_commandType来决定执行哪些操作,在此次攻击中,_commandType为0x12 ,所以command=0x12&0x3f=0x12,对应的值为KYBER_SWAP

图片

所以,攻击者调用代码段如下。我们可以看到,该代码的kyberRoutertargetData均可以被控制,意味着攻击者可以利用Spectra Protocol合约调用任意合约并传入任意参数。

图片

我们将攻击者的inputs数据解析出来如下:

图片

我们可以发现,kyberRouter已经被操纵为地址:

0x43e54c2e7b3e294de3a155785f52ab49d87b9922

tokenIn已经被操纵为地址:

0xeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee

tokenOut被操纵为地址:

0xba8ce86147ded54c0879c9a954f9754a472704aa

我们可以看到Constants.ETH为:

0xEeeeeEeeeEeEeeEeEeEeeEEEeeeeEeeeeeeeEEeE

图片

所以,代码进入到如下流程

图片

其中,targetData经过解析如下:

图片

由于,transferFrom的signature为0x23b872dd;所以,transferFrom对应的参数from为:

0x279a7dbfae376427ffac52fcb0883147d42165ff

to为:

0xba8ce86147ded54c0879c9a954f9754a472704aa

value为:

188,013,365,080,870,249,823,427

又因为,kyberRouter被控制为:

0x43e54c2e7b3e294de3a155785f52ab49d87b9922,即asdCRVToken。

所以,攻击者相当于操纵了Spectra Protocol从0x279a7dbfae376427ffac52fcb0883147d42165ff转了188,013,365,080,870,249,823,427asdCRV到地址0xba8ce86147ded54c0879c9a954f9754a472704aa(此地址为攻击者控制的地址)。

至此,攻击者完成攻击。 

总结

本次漏洞的成因是被攻击合约对攻击者传入参数校验不严格,导致攻击者可以通过构造特殊的inputData来使受害者合约调用任意合约并传入任意参数。最终,攻击者利用特殊的参数,使得受害者合约通过transferFrom将授权给其合约的代币转入到攻击者控制的地址。建议项目方在设计代码运行逻辑时要多方验证,合约上线前审计时尽量选择多个审计公司交叉审计。 

Trending Cryptos

Related Reads

Never expected that the first tangible application of AI x Crypto is in security auditing

Unexpectedly, the initial major application of AI in the Crypto sphere has turned out to be security auditing. In 2026, DeFi has faced significant security challenges, with 121 hacking incidents resulting in approximately $942 million in losses. While AI was expected to first impact areas like quantitative trading, its initial breakthrough has instead transformed security auditing by drastically lowering the cost and skill barrier for finding smart contract vulnerabilities. The traditional audit model is facing obsolescence. Advanced AI models, such as Claude Mythos, enable attackers to scan thousands of contracts and identify vulnerability patterns at scale, compressing the time from discovery to execution to mere minutes. This renders the month-long validity of traditional audit reports ineffective. Notably, attacks now frequently target well-audited, established protocols by exploiting business logic flaws, operational security weaknesses, and even years-old historical contracts, demonstrating that old audit reports offer zero protection. This pressure is forcing a fundamental shift in the industry. In the short term, a wave of defensive re-auditing is occurring, driven by projects seeking to meet new AI-era security standards and regulatory requirements. In the long run, audit firms' business models are diverging. The one-time report delivery model is declining in value, as evidenced by platforms like Code4rena shutting down. Leading firms are now pivoting towards AI-powered defense, integrating continuous monitoring, real-time on-chain risk detection, and embedding security directly into the development phase, as seen with tools like OpenZeppelin's Skills system. Ultimately, the era of "audit once, secure forever" is over. Security must become a continuous, embedded infrastructure investment for projects. For audit companies, survival depends on proactively transforming from traditional service providers into platforms offering AI-native, ongoing security solutions.

链捕手7m ago

Never expected that the first tangible application of AI x Crypto is in security auditing

链捕手7m ago

Who's Paying for the $64 Billion Paper Feast?

"The Illusion of Wealth: Who Bears the Burden of the $64 Billion Paper Bonanza?" Bitcoin recently broke below the critical $60,000 support level, triggering significant selling by major holders. While the price drop itself is concerning, a deeper issue lies with publicly traded companies that have bet their entire balance sheets on Bitcoin, creating a precarious financial link between their stock prices and crypto valuations. Leading the pack is Strategy (formerly MicroStrategy), holding 847,000 BTC at an average cost of ~$75,600, now facing over 20% unrealized losses. Its stock trades at a deep discount to its Bitcoin holdings. Other companies like Japan's Metaplanet (nearly 40% unrealized loss) and Solmate (which fully pivoted to Solana and saw its stock collapse 98%) illustrate the risks of this model without underlying business operations. A key misconception is that these firms face immediate, forced liquidation. Their debt structures provide a buffer. However, the core "financial flywheel" is stalling. Strategy's CEO has even hinted at potentially selling Bitcoin to cover obligations—a reversal of his long-standing "never sell" doctrine. New accounting rules (ASU 2023-08) exacerbate the problem, requiring quarterly mark-to-market adjustments. Bull markets create paper profits, attracting capital. In bear markets, they generate massive paper losses, potentially triggering index exclusions and forced selling by passive funds. The true crisis point is not the current price, but a looming debt reckoning. If Bitcoin fails to recover above key cost bases within 12-24 months, convertible note redemption windows opening in Fall 2027 could force companies to sell massive Bitcoin holdings for cash, potentially triggering a severe liquidity crisis. The model hasn't eliminated risk; it has merely transformed instant, price-triggered liquidation into a slow-burning, time-triggered debt crisis.

marsbit17m ago

Who's Paying for the $64 Billion Paper Feast?

marsbit17m ago

Base Halts for Two Hours: A Single Invalid Block Reveals the Centralized Reality of L2s

Base, an Ethereum Layer-2 Rollup, experienced a two-hour network outage starting around 00:03 UTC on June 26. The halt was caused by a consensus issue that led to an invalid block being sequenced, which prevented the generation of new blocks after block 47806542. The team identified the problem, restored block sequencing by 01:51 UTC, and confirmed full recovery of ecosystem infrastructure synchronization shortly after. This incident highlights the operational reality for many L2s: while they leverage Ethereum for security and data availability, their day-to-day usability heavily depends on their sequencer and internal systems. Base employs a high-availability sequencer system with one active leader, but this setup did not prevent the outage when a consensus-level problem arose. This follows a previous 33-minute outage in August 2025 related to a faulty sequencer handover process. The downtime occurred near the scheduled activation window for the "Beryl" network upgrade, which has since been postponed. Beryl introduces the native B20 token standard, among other improvements. The incident has sparked renewed discussion about Base potentially launching its own network token in the future, shifting the conversation from mere speculation to questions about how a token might relate to sequencer decentralization, governance, and accountability in such failure scenarios.

Foresight News37m ago

Base Halts for Two Hours: A Single Invalid Block Reveals the Centralized Reality of L2s

Foresight News37m ago

Trading

Spot

Hot Articles

Discussions

Welcome to the HTX Community. Here, you can stay informed about the latest platform developments and gain access to professional market insights. Users' opinions on the price of ETH (ETH) are presented below.

活动图片