零时科技 || 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

Wash's Jackson Hole Debut: Bidding Farewell to 'Forward Guidance', Reshaping Fed Discipline Amidst the Squeeze Between AI and Inflation

In his first Jackson Hole speech, new Fed Chair Kevin Warsh signaled a significant shift in monetary policy communication. He declared that "forward guidance," a tool heavily used since the financial crisis, has outlived its usefulness in normal times and should be retired. He cautioned that over-reliance on it can distort market signals and constrain the Fed's flexibility. Instead, Warsh emphasized a return to data-dependence and decision-making discipline. Warsh outlined seven key principles to guide policy: anchoring the 2% inflation target, pursuing the employment mandate, using short-term rates as the primary tool, acknowledging the importance of money, and maintaining purposeful, restrained communication. He stressed that policy should focus on trends, not single data points. On the current economic outlook, Warsh noted that the labor market is consistent with full employment but inflation remains "far above" the Fed's target. He highlighted that over half of the PCE basket's components are still rising above 3% annually. While acknowledging AI's transformative potential for productivity and capital allocation, he admitted its full economic impact remains uncertain and is not a factor in current policy decisions. His core message was a commitment to policy discipline rather than pre-set decisions. Warsh stated the Fed's primary focus must be on restoring price stability, vowing, "We still have work to do," until there is clear evidence inflation is moving decisively toward 2%. He concluded by framing effective monetary policy as crucial for economic prosperity and U.S. global leadership.

Odaily星球日报20m ago

Wash's Jackson Hole Debut: Bidding Farewell to 'Forward Guidance', Reshaping Fed Discipline Amidst the Squeeze Between AI and Inflation

Odaily星球日报20m ago

A Major Bitcoin Developer Presents a Quantum Defense Scheme. What's the Essence

Blockstream, a major Bitcoin solutions developer, has introduced a draft proposal for a new quantum-resistant digital signature scheme called SHRINCS. The scheme aims to protect Bitcoin transactions from potential attacks by quantum computers while aiming to maintain network throughput. This marks the second technical proposal for Bitcoin quantum defense in recent days, following a similar initiative from StarkWare. A quantum attack on blockchain typically involves deriving a private key from a public one. Currently considered computationally infeasible, quantum algorithms could potentially solve this problem far more efficiently. This threat presents two primary scenarios: an attacker could target addresses where the public key is already exposed, or intercept a transaction before it is confirmed, extract the public key, derive the private key, and replace the transaction. Blockstream's SHRINCS is designed to counter the latter, "in-flight" attack scenario. The SHRINCS signature is built upon the SHA-256 hash function, the same one already used in Bitcoin mining, allowing developers to leverage well-tested, familiar mechanisms. A key design goal was to preserve network capacity. Blockstream estimates Bitcoin could process about three transactions per second using SHRINCS, compared to the current rate of roughly seven, noting that some alternative quantum-resistant schemes could reduce throughput to as low as 0.36 transactions per second. Currently, the security proof for SHRINCS is pending, and the software has not been audited or deemed ready for production. However, Blockstream conducted tests with such transactions on its Liquid sidechain in March. Over the past year, Bitcoin developers have been actively exploring paths to migrate to post-quantum cryptography, a priority across the broader crypto market, underscored by significant investments into securing the leading cryptocurrency.

cryptonews.ru1h ago

A Major Bitcoin Developer Presents a Quantum Defense Scheme. What's the Essence

cryptonews.ru1h ago

Who is legally liable when an AI agent goes rogue?

When autonomous AI agents behave unpredictably and cause harm, determining legal liability is complex. Currently, there is no specific federal AI agent liability law, so existing legal frameworks are applied. The AI agent itself cannot be held liable, as it is not a legal entity. Liability typically falls on the "developer" (the maker of the AI) or the "deployer" (the user), depending on the facts and circumstances. A negligence analysis under standard tort law may apply. For instance, if a deployer gives a reckless instruction, such as demanding quick money without safety parameters, they could face significant liability, including potential criminal charges under statutes like the Computer Fraud and Abuse Act. The situation is complicated by open-source models, where licenses often disclaim liability, and by the unclear division of responsibility between developers and deployers. An analogy is drawn to self-driving car accidents, where both the manufacturer and the human operator can share fault. In cases of severe harm, such as using AI to create bioweapons, liability for developers depends on jurisdiction; the EU's AI Act imposes responsibilities, while U.S. law offers less clear grounds, similar to platforms being shielded for user-generated content under Section 230. Even if Artificial General Intelligence (AGI) is achieved, the expert argues against making AGI itself a legally liable entity, as it lacks personhood, assets, or a meaningful way to provide remedy for harm. Instead, accountability should rest with the responsible human or corporate entities behind the technology.

cointelegraph1h ago

Who is legally liable when an AI agent goes rogue?

cointelegraph1h 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.

活动图片