慢雾:Stars Arena 被黑简析

web3caffPublished on 2023-10-27Last updated on 2023-10-27

Abstract

本文将简析攻击者是如何利用 Stars Arena 的重入漏洞获利。

本文将简析攻击者是如何利用 Stars Arena 的重入漏洞获利。
作者:慢雾安全团队,慢雾科技
背景
据慢雾 MistEye 系统安全预警,2023 年 10 月 7 日,Avalanche 链上社交协议 Stars Arena 遭攻击,损失约 290 万美元。慢雾安全团队简析该攻击事件并将结果分享如下。
相关信息
攻击者地址:
https://snowtrace.io/address/0xa2ebf3fcd757e9be1e58b643b6b5077d11b4ad7a
攻击合约:
https://snowtrace.io/address/0x7f283edc5ec7163de234e6a97fdfb16ff2d2c7ac
https://snowtrace.io/address/dd9afc0e3c43951659c8ebe7aef9ee40879863ea
攻击交易:
https://snowtrace.io/tx/0x4f37ffecdad598f53b8d5a2d9df98e3c00fbda4328585eb9947a412b5fe17ac5
攻击核心
攻击者利用重入漏洞,篡改自己存款份额所对应的价格。随后在卖出时,又因该恶意操纵的价格计算依赖,导致类似的价格操控。通过精确计算重入时更新的份额价格,攻击者窃取了合约中的资金。
交易分析
我们可以发现攻击交易中存在一笔重入调用,我们通过反编译代码逐步分析调用方式。

攻击者先创建攻击合约(0x7f283 和 0xdd9af),通过攻击合约调用 Stars Arena: Shares 合约的 0xe9ccf3a3 方法,然后存入 1 枚 AVAX 代币。

根据反编译后的代码一步步跟踪,攻击者首先用的 0xe9ccf3a3 方法是一个类似于存款的函数,其中会调用 0x326c 和 0x2058 方法。0x326c 方法仅作为参数返回的调用,而 0x2058 方法类似于一个处理某种代币购买或交换的函数,该方法通过 0xe9ccf3a3 所传入的 AVAX 代币数额及地址来进行下一步操作及份额和费用的计算。

跟进 0x2058 方法第 92 行的调用逻辑,可以发现 0x1a9b 方法为一个计算函数,计算出的结果是一个类似于价格的值,其返回值为新计算出的 v24 / 0xde0b6b3a7640000 或者是 _initialPrice。
之后的 109 行,110 行及 116 行的 0x307c 和 0x30ef 方法中就存在 low-level call 的调用,而 0x30ef 的 call 还是对 varg1 也就是传入的 0xdd9af 攻击合约地址的外部调用。函数没有防重入锁的约束,并且在执行完外部调用后,此方法才会向下执行之后的 if 判断来更新 field0.length 及 field0 参数。毫无疑问,重入就是在此处发生的。

我们再来看攻击者在重入调用中构造的数据。

重入外部调用的是 0x5632b2e4 方法,并传入攻击者所构造的的 4 个参数,这些参数通过进制转化 153005ce00 为 91000000000。
正如上面讲到的,对 0x5632b2e4 方法的外部调用是执行在 if (varg0 == _getMyShares[address(varg1)][msg.sender]) 判断之前。这时 field0.lengt 值为 0, 并未更新。攻击者正好通过这个方式绕过 0x5632b2e4 方法中的判断,将 msg.sender 也就是攻击合约 0xdd9af 的以下 4 个参数状态都修改为了外部调用是时构造的数据。

通过以上操作之后,攻击者调用了 sellShares 来卖出自己的份额,获得了 266,102.97278 枚 AVAX。

深入 sellShares 函数,函数起先就调用了 0x1a9b 方法,而在之前的 0x2058 方法中就曾存在调用,是处理某种代币购买或交换的函数。我们可以发现,在 0x1a9b 方法中的 0x2329 方法会更新 owner_9f[varg0],而这个参数在重入时就已经被修改为攻击者所构造的 91000000000。

回到 0x1a9b 方法中,根据之前恶意构造的值重新计算(计算数额见注释)。

经过以上计算,新计算出的份额所对应的价格发生了改变,计算出的结果为 274,333.061476814e18。再经过一系列的费用收取过后,攻击者在没有修改份额的情况下使用恶意构造操纵的价格,卖出份额,成功获利。
总结
本次攻击的核心在于重入攻击所造成的价格计算依赖更新,进而导致了类似恶意价格操控。慢雾安全团队建议项目方应尽可能在经过多家安全公司审计后,再进行合约的部署发布;同时在编码时应尽可能满足 Checks-Effects-Interactions 编码规范,添加防重入锁。
免责声明:作为区块链信息平台,本站所发布文章仅代表作者及嘉宾个人观点,与 Web3Caff 立场无关。文章内的信息仅供参考,均不构成任何投资建议及要约,并请您遵守所在国家或地区的相关法律法规。

Related Reads

UBS: The Crowdedness of A-Share Tech Stocks Is Far From Reaching Historical Peaks

UBS: A-share tech stocks still far from peak crowding levels A-shares' technology sector has seen a strong rebound, with trading activity hitting record highs, raising concerns about market crowding. However, UBS Securities argues that a key indicator of institutional positioning suggests the current crowding level remains well below historical peaks. While the large-cap tech sector's share of total A-share trading volume and market capitalization have reached historical highs, the overweight ratio of domestic mutual funds in this sector stood at 9.9% in Q1 2026. This is down from 11.6% in Q3 2025 and significantly lower than the historical peak of 14.1% in Q4 2015. It also pales in comparison to the historical peak overweight of 18.7% for the consumer sector. UBS notes that typical cycles from a low to a peak in fund overweighting last about three years, and the current outperformance of the tech/growth style has lasted less than two years since the policy pivot in September 2024. UBS expects A-share earnings recovery to accelerate, providing fundamental support. It forecasts 2026 A-share profit growth to rise to 11% from 3.9% in 2025. Non-financial A-share profits grew 11.8% YoY in Q1 2026, with gross and net profit margins at their highest since 2023. Persistent fund inflows, the expansion of thematic ETFs, and a recovery in private fund issuance are supporting market liquidity. In tactical allocation, UBS favors growth and cyclical styles under its "slow bull" base case, with overweight ratings on six sectors: Electronics (benefiting from semiconductor inventory recovery and AI innovation), Communications (driven by AI computing demand), Machinery (aided by domestic capex recovery), Non-ferrous Metals (due to rising copper/aluminum prices), Chemicals (supported by anti-involution policies), and Electrical Equipment (driven by policy support and AI data center power demand).

marsbit1h ago

UBS: The Crowdedness of A-Share Tech Stocks Is Far From Reaching Historical Peaks

marsbit1h ago

Trading

Spot
Futures

Hot Articles

How to Buy ZRX

Welcome to HTX.com! We've made purchasing ZRX(0X) (ZRX) simple and convenient. Follow our step-by-step guide to embark on your crypto journey.Step 1: Create Your HTX AccountUse your email or phone number to sign up for a free account on HTX. Experience a hassle-free registration journey and unlock all features.Get My AccountStep 2: Go to Buy Crypto and Choose Your Payment MethodCredit/Debit Card: Use your Visa or Mastercard to buy ZRX(0X) (ZRX) instantly.Balance: Use funds from your HTX account balance to trade seamlessly.Third Parties: We've added popular payment methods such as Google Pay and Apple Pay to enhance convenience.P2P: Trade directly with other users on HTX.Over-the-Counter (OTC): We offer tailor-made services and competitive exchange rates for traders.Step 3: Store Your ZRX(0X) (ZRX)After purchasing your ZRX(0X) (ZRX), store it in your HTX account. Alternatively, you can send it elsewhere via blockchain transfer or use it to trade other cryptocurrencies.Step 4: Trade ZRX(0X) (ZRX)Easily trade ZRX(0X) (ZRX) on HTX's spot market. Simply access your account, select your trading pair, execute your trades, and monitor in real-time. We offer a user-friendly experience for both beginners and seasoned traders.

2.1k Total ViewsPublished 2024.03.29Updated 2026.06.02

How to Buy ZRX

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 ZRX (ZRX) are presented below.

活动图片