NBA的16进制合约漏洞是怎么被科学家薅秃噜皮的?

今天有更懂这个世界一点了吗Published on 2022-04-22Last updated on 2022-04-22

Abstract

用户绕开官网,直接通过matemask用别人已经产生的16进制Input Data与合约直接交互。

今早一觉睡起来看群里大家都在讨论昨晚NBA带给科学家的狂欢,据说有人直接free mint了100个,按照现在0.4ETH的地板价也有一百万人民币了,原由是合约又出现了漏洞,所以来看看到底是怎么回事。
NBA于昨日发售了他们的NFT系列The Association NFT,将240个球员各制作了75个NFT,总共供应18000个,白名单持有者可以free mint 1 个,这句话重点圈起来,之前的讲过的Gh0stlyGh0sts的那篇文章也是free mint,只需要缴纳gas费就可以mint到坐等升值,在肉眼可见的获利空间下如果能再发现点合约漏洞,比如绕过白名单或者绕过mint 1个的限制,那不得把羊毛薅秃噜皮了,所以每当出现这种NFT项目都会有大量科学家盯着找漏洞,NBA这次整了个王炸,白名单限制和mint 1个限制都被攻破了。

漏洞

这次漏洞对于辛辛苦苦干白名单的用户也是很大的打击,没有白名单的能mint也就算了,还可以无限mint,导致把有白名单的用户名额都抢了,甚至很多用户当初都是在场外花费几千美金购买的白名单。并且在mint时涌进去一大堆科学家导致gas费飙升,白名单用户也受了无妄之灾被迫缴纳更多gas(毕竟白名单的目的之一就是避免 gas war),所以也有大量的用户在维权哭诉,白名单用户在DC哀嚎一片。

漏洞

这的问题主要是两个情况导致的:
1.用户绕开官网,直接通过matemask用别人已经产生的16进制Input Data与合约直接交互。
2.合约对于mint的白名单校验存在漏洞。 
我们先来讲第一个,先考大家一个知识,与智能合约进行交互mint的方式都有哪几种?
首先大家肯定会说,不是在网站上点一个“mint”按钮去调用智能合约来mint吗?
这是最常规的也是所有项目方都希望我们进行的一种操作,大家应该都有蹲在屏幕前狂戳mint按钮抢公售的经历。
另外有经验的同学会说,还可以直接打开区块链浏览器如etherscan,找到项目方的合约地址,在read contract和write contract里对合约进行操作,很多同学都是通过这种方式抢公售的,因为你在官网里点击mint,前端要再触发请求去合约进行操作,合约再完成执行,而你直接在etherscan里操作合约会跳过第一步,速度更快,对于这个方式不了解的可以看我之前的文章怎么通过看懂etherscan了解NFT项目情况?
但是这种方式遇到两种情况是行不通的,一种是项目方根本没有开源它的合约,或者是项目方在合约接口里必须要求你传入一些如签名等参数,而这种参数只能通过项目方的中心化服务器来生成,所以强制你必须要通过项目方的官网进行操作。
其实还有第三种,直接通过matemask钱包来和合约进行操作。
大家也许会对这一种很陌生,其实你已经在不知不觉中大量的使用了这种操作,转账的过程其实就是你用钱包直接交互合约的过程。
当我给某个地址转钱时,首先点击发送。

漏洞

然后输入收款地址,并输入你要转账的金额。

漏洞

这个过程大家已经非常熟悉了,这其实就是你与合约交互的过程,因为转账这种动作是我把钱转给某个地址,该地址只需要收钱就好,不需要让我输入更多额外的信息,这时候你会问,mint可不一样呀,至少我需要输入mint几个,还可能包括白名单校验等,这些参数怎么输入呢?
我们打开小狐狸钱包等设置,进入高级,然后下拉会看到有一个开关叫“显示十六进制数据”,把它打开。

漏洞

这个开关是干嘛的呢?需要先为你讲清楚什么是十六进制数据。
你与任何一个合约交互都会为其输入一定的数据,合约接收到这部分数据进行处理,这个数据定义了你要和合约的哪个接口函数交互,要给这个接口函数传入什么参数等等,这些数据都会以16进制的形式进行压缩。
你打开etherscan,随意找到你曾经的一个交易记录点击进入详情,然后一直下拉,你会在最下面看到 input data,右边有一长串字符,这就是你当时与这个合约的函数交互时输入的数据转成16进制后的样子。

漏洞

关键是这一长串无规律的数字也压根都不懂呀,先不急,这里面是有规律的,虽然这次NBA的漏洞也不要求你读懂16进制就可以直接用,但是本着求真的态度,我们还是要能理解这里面的含义。
首先我们可以看到开头的0x后面有几位字符,再往后全是0。

漏洞

这几位字符就代表着你调用的这个合约函数的编码,每个函数会有一个自己的编码。
我们打开一个合约的交易记录,你会看到调用的方法中有的是如mint、transfer这种可以理解的文字,有的是0x开头的编码,因为mint、transfer这种操作函数是非常标准的,所以etherscan自动帮你把它们的编码翻译成了文字,但是有的函数是项目方自己开发的,所以只显示其原始编码。

漏洞

我们在测试网试一下使用这种方式和合约直接进行交互的流程,我找到了之前部署的一套合约,然后点击进入已经完成的mint交易详情中。

漏洞

然后拉到最下面复制当时的input data。

漏洞

将合约地址填写进入后,并粘贴我刚才复制的input data,点击下一步。

漏洞

然后到了缴纳gas费的步骤。

漏洞

我们可以点击数据看一下,果然这里功能类型是Mint,没错就是mint函数,说明我们成功的用之前的16进制input data调用到了合约。

漏洞

然后点击确认缴纳gas费,到etherscan上看一下,成功了!

漏洞

漏洞

好了到这里我们已经很清楚的知道用已经存在的交易的16进制数据可以原模原样的执行一次合约函数。
我们刚才讲到这次问题出现的原因第二点是合约校验白名单出现了漏洞。这个漏洞给了科学家用16进制手段薅到到机会。
接下来我们看合约mint到底有什么问题,看过我之前的文章的读者应该都清楚,在mint时一般都会经过几层校验,主要包括是否开启mint校验、数量校验、白名单校验等,如下图NBA的mint合约所示,它有三层校验:
batchNumber是用来校验第几批mint,这个不是我们今天要讲的重点可以先略过。
重点是第二层的白名单校验和第三层的mint数量校验。

漏洞

重点来了,第二层校验用到了一个叫 verify 的函数,传入了一个 info 参数,这是用来校验当前用户是否在白名单,问题就是出在了这里。
在解释白名单校验的问题之前,我们有必要先了解一下常见的2种白名单校验方式,在NFT行业初期,那时候很多项目的白名单都是一个个的录入的,然后在mint时校验一下当前用户的地址是否能够匹配到白名单,每录入一个都要缴纳一次gas费,成本投入极高,我周围就有人仅录入白名单就花费了数万美金。
逐渐的有人意识到这种方法又贵又笨,于是采取了一种技术难度较高但更节省gas费的方式如梅克尔树这种加密签名验证,它的原理就是将白名单不要存储在链上合约中,而是放在链下由项目方自己保管,当用户在官网mint时根据用户的钱包地址用算法生成一个签名,NBA这次使用的就是加密签名方式的校验。
具体的加密原理和代码实现方式讲起来就太复杂了先略过,感兴趣的可以自己去学习椭圆加密算法、梅克尔树这些内容。我们先了解原理即可,我们现在只需要知道这个验证的方法是需要输入一个钱包地址,校验该地址是否存在于白名单,如果存在则返回一个签名。
这时候你可能会隐约觉得有问题,既然校验的方式是输入地址返回结果,那我如果用刚才说的16进制交互的方法,我把白名单用户已经执行的交易16进制数据输入进去,不就可以完成“白名单mint”了吗,这就相当于是指纹识别开门,你把有权限人的手指头剁下来放在识别机上也一样可以进门(有点残忍)。
这里有个问题是如果项目方又多加了一层校验比如mint者地址和校验白名单地址必须是一样的,即你解锁的手指头和进门的人必须得是一体的,这个漏洞也就堵住了,可偏偏NBA还就没有堵住。
我们再回顾一下代码,先用msg.sender获取了当前执行合约的用户地址,在最终执行mint时传入的是这个地址。

漏洞

而在mint前校验的是传入一个叫info的参数,这个info的参数里面包含的地址是官网获取到操作官网用户的地址后传进来的。

漏洞

明白问题所在了吗?有白名单的张三在官网点了mint,官网把张三的地址传入了info后给到合约校验通过,然后合约再执行mint时再获取一遍当前正在执行的张三地址,把NFT转给他,但是!但是没有去判断此张三是否为彼张三呀!他没有去校验这两个地址是否为同一个。
所以我完全可以先找到张三的交易记录,然后把他的16进制复制粘贴到钱包里执行交易,这时候在校验白名单时用的是张三的地址,所以会校验通过,但是mint时用的是我的地址,因为是我正在和合约进行交互。
破案了!精不精彩!我把张三的手指头砍下来进到了金库!
我们看一下规规矩矩用白名单mint的用户他们的16进制长什么样,可以看到这个地址他mint了1个NFT成功了。

漏洞

然后我们看一下16进制,有两个关键点,数字1代表着他mint了1个,下面的地址就是他自己的地址,对上了。

漏洞

我们再看一个昨天传遍科学家圈的一次撸了69个的巨能撸干了点啥,以下为他的地址和mint的100个NFT。

漏洞

我们来看一下他的16进制都是什么,先看到45,这是什么意思呢?这不是代表着数量吗?可不是1也不是64呀,因为64的16进制就是45,所以这位巨能撸把1改成了45从而撸撸64个。

漏洞

你会疑惑不是说有限制每人只能1个吗?这里就又是个漏洞,我们看到代码确实有限制,mint时你的持有量不能超过1,但是我mint的时候是0呀,我mint一万个这个限制也管不住我....不知道这个合约工程师在想啥。

漏洞

接下来我们回到16进制数据,看那个合约地址,你会发现和巨能撸的对不上,说明巨能撸是把他的手指头砍下来解锁了,我们来看看是哪个倒霉蛋。
进入他的地址看到这小子也挺有钱账上躺着30个以太,被撸了也不算亏。

漏洞


然后看到他的交易记录确实在昨晚mint了一个NBA,看来巨能撸就是拿着他的16进制开锁的。

漏洞

这应该是我写过最精彩的一篇文章,犹如破案一般层层抽丝剥茧为大家讲清楚了科学家是怎么把羊毛薅干净的,也是我写过最累的一篇,耗时整整5个小时,写作不易,如果对你有用麻烦大家多转发扩散哈。
我之前的文章中多次强调,web3的世界因为其开源性使得作恶空间很多,当然科学家的行为是否是作恶有待商榷,但是作为项目方一定是有责任保障自己用户利益的,需要对技术有敬畏之心,代码review一定要严谨。

Related Reads

To Hike or Not Tonight: Economists Unanimous on 'No', Markets Price in a 30% Chance

Federal funds futures are repricing ahead of the July FOMC decision, as traders pay a higher premium for the risk of a surprise rate hike or more hawkish signals. This contrasts with economists, where a Reuters survey of 104 analysts unanimously expects rates to remain unchanged at 3.50%-3.75%, with 78 foreseeing no change through year-end. Yet, futures markets have priced in about a 30% probability of a 25-basis-point hike. The core debate, especially under new Fed Chair Kevin Warsh, centers on how the Fed will respond to the oil price shock from Middle East tensions. The market is not necessarily predicting a hike tonight but is hedging against two tail risks: an immediate rate increase, or a hold combined with communication that seriously opens the door for a September hike. This hedging activity has driven up open interest in Fed funds futures. Analysts are divided on how to weight the oil price surge in the Fed's reaction function. Hawkish voices (e.g., BofA) worry that completely dismissing the price pressure could challenge the Fed's inflation credibility in Warsh's first major test. Dovish views (e.g., Citi) argue the shock is primarily supply-driven and that overreacting with rate hikes could unnecessarily hurt growth, unless clear signs of secondary inflation emerge. Warsh's new tenure amplifies policy path uncertainty, as markets lack a stable baseline for his communication style. This environment forces traders to price in a wider range of outcomes, explaining the divergence between unanimous economist forecasts and market hedging. The key focus will be on Warsh's post-meeting commentary. If he downplays the oil shock and stresses anchored long-term expectations, hawkish pricing may recede. If he emphasizes the risk of broader price spillovers and prioritizes returning to 2% inflation, the market will interpret this as reopening the door for a September hike. This would sustain support for the USD, keep pressure on JPY (testing intervention thresholds), and challenge risk assets like stocks and crypto through higher discount rates and weaker sentiment. The baseline remains no action in July, but the communication will determine how far this repricing extends.

marsbit4m ago

To Hike or Not Tonight: Economists Unanimous on 'No', Markets Price in a 30% Chance

marsbit4m ago

The Semiconductor Industry's Most Obscure Chokepoint Material: It Has Multiplied in Price Unnoticed, and China Just Banned Its Export

"Helium: The Silent Choke Point in Semiconductors" Helium, despite being the universe's second most abundant element, is critically scarce on Earth. It cannot be synthesized artificially and escapes Earth's gravity once released, making it a non-renewable resource. Yet, it is indispensable for advanced semiconductor manufacturing, requiring ultra-high purity (99.9999%) for processes like wafer etching, leak detection, and thermal management in lithography tools, with no viable substitutes. This low-profile resource, whose price has doubled unnoticed, suddenly gained attention when China imposed an export ban on July 10th. The ban is a response to a severe global shortage triggered months earlier. In March, missile attacks damaged the world's largest helium production hub in Qatar's Ras Laffan, halting a third of global supply with repairs expected to take 3-5 years. Concurrently, Russia tightened export controls, and the US sold off its federal helium reserve. Approximately 200 specialized transport containers, each worth ~$1 million, were stranded with perishable cargo. Global spot prices skyrocketed, and chipmakers like TSMC warned of potential impacts. China, which imports over 84% of its helium (primarily from Qatar and Russia), faces a severe squeeze. Despite being helium-poor, China has developed domestic extraction technology over five years, processing byproduct gases from LNG plants to produce ultra-pure helium. Domestic output, while still only covering less than 20% of demand, enabled the recent export ban aimed at securing domestic supply for its own expanding chip industry. The industry now faces "Helium Shortage 5.0." With key global sources constrained for years, this invisible gas—once wasted on party balloons—has become a critical, geopolitically charged bottleneck for chips, healthcare (MRI machines), and beyond, forcing the world to finally treat it as the finite strategic resource it is.

marsbit44m ago

The Semiconductor Industry's Most Obscure Chokepoint Material: It Has Multiplied in Price Unnoticed, and China Just Banned Its Export

marsbit44m ago

Early Investor of Unitree Bets on a Brain-Computer Interface Company

"Wabo Technologies, a brain-computer interface (BCI) startup, has secured new funding from Vertex Ventures (under Temasek), Hongtai Fund, Chengdu Future Industry Fund, and Huifengda Capital. Vertex Ventures is known for its early bet on Unitree Robotics. Inspired by the sci-fi film "Avatar," founder Zhang Xingzhi has pursued human-machine interaction for over a decade. He established Wabo in late 2025, coinciding with China's push for BCI as a future industry. Unlike companies focused solely on medical hardware, Wabo positions itself as a model company. Its core mission is to develop a "Human Neural Intent Model" that decodes EEG, EMG, and behavioral signals to understand a user's goals, confirmations, corrections, and stop intentions before physical action, translating them into standardized control signals for machines, robots, or smart devices. The young, full-stack team, backed by academic collaborators from Tianjin University and Fudan University, quickly attracted investors. The company had previously raised a seed round from Ceyuan Capital. Investors were impressed by Wabo's systematic capabilities in data collection, signal processing, and engineering, seeing potential beyond a single hardware product toward a reusable layer of human intent interpretation. Applications span medical rehabilitation, smart homes, embodied AI, and even space exploration, with Wabo partnering with Tianjin University on pioneering "space BCI" research. Wabo plans a dual-headquarters strategy, with Shanghai focusing on high-end R&D and model development, and Chengdu handling hardware, product development, and supply chain. The BCI sector in China is heating up, with over 30 financing deals in early 2026. Zhang believes future competition will center on who can build a sustainable data-model-scenario loop. He predicts industry consolidation within three years, with only companies that master this闭环 surviving. The vision from "Avatar" is inching closer to reality."

marsbit58m ago

Early Investor of Unitree Bets on a Brain-Computer Interface Company

marsbit58m ago

ChangXin Technology: A Cyclical Stock Standing Atop the Cycle Peak

Changxin Technology: A Cyclical Stock at the Peak On July 27, 2026, Changxin Technology topped the A-share market with a market capitalization of 3.28 trillion yuan, surging 465% on its first trading day. The company, which lost 16.3 billion yuan in 2023, reported an estimated net profit of 50-57 billion yuan for the first half of 2026. Its dramatic reversal mirrors the volatile DRAM (Dynamic Random Access Memory) cycle. The DRAM industry is inherently cyclical, with booms and busts every 3-4 years. This is due to product standardization and a significant time lag in supply adjustment. When prices rise, manufacturers expand capacity, but new production takes 2-3 years to come online, often leading to oversupply and price crashes when demand cools. Changxin's performance perfectly tracks this cycle. It recorded deep losses in 2023-2024 during the industry downturn, turned its first annual profit in 2025, and saw profits skyrocket in Q1 2026. This surge is primarily price-driven. The AI boom has led major players like Samsung and SK Hynix to shift 70-80% of new capacity to high-margin HBM (High Bandwidth Memory), creating a severe shortage and price explosion in general-purpose DRAM markets where Changxin competes. However, a massive global capacity expansion is underway. The top three manufacturers have announced nearly $70 billion in capital expenditure for 2026. Changxin itself plans to expand from three to seven 12-inch wafer fabs. This investment will translate into significant new supply in 2-3 years. While DRAM prices are expected to remain high through 2026-2027, price growth is already slowing, and a potential downturn is forecast for around 2028 as new capacity ramps up. A key challenge for Changxin is catching up in the critical HBM segment. While it has delivered HBM3 samples, leaders are already mass-producing more advanced HBM3E. Success in HBM is crucial for gaining true cyclical resilience. In conclusion, Changxin is a commendable company that has broken foreign monopolies in DRAM. Its long-term growth narrative—driven by import substitution and AI—is valid. Yet, its current valuation of 5-6x forward P/E, typical for a cyclical stock at its peak, suggests much future growth is already priced in. AI may extend the current cycle but cannot eliminate the industry's inherent volatility. For investors, the critical question is preparedness for the inevitable downturn when the cycle turns.

marsbit1h ago

ChangXin Technology: A Cyclical Stock Standing Atop the Cycle Peak

marsbit1h ago

Trading

Spot
活动图片