Jet Protocol 任意提款漏洞

慢雾科技Publicado em 2022-04-02Última atualização em 2022-04-02

Resumo

目前在 Solana 上发生过多起黑客攻击事件均与账号校验问题有关,慢雾安全团队提醒广大 Solana 开发者,注意对账号体系进行严密的审查。

据 Jet Protocol 官方博客披露,他们近期修复了一个赏金漏洞,这个漏洞会导致恶意用户可以提取任意用户的存款资金,慢雾安全团队对此漏洞进行了简要分析,并将分析结果分享如下。

账号

(来源:https://www.jetprotocol.io/posts/jet-bug-disclosure)
相关信息
Jet Protocol 是运行在 Solana 上的一个借贷市场,用户可将账号里的代币(如:USDC、SOL)存入金库,赚取年化收益,同时也可以按一定的比例借出另一种代币。在这个过程中合约会给用户一个 note 凭证,作为用户未来的提款凭证,用我们熟悉的字眼来说就是 LP,而本次漏洞发生的原因也和这个 LP 的设计有关。
我们知道和以太坊合约相比,Solana 合约没有状态的概念,取而代之的是账号机制,合约数据都存储在相关联的账号中,这种机制极大提升了 Solana 的区块链性能,但也给合约编写带来了一些困难,最大的困难就是需要对输入的账号进行全面的验证。Jet Protocol 在开发时使用了 Anchor 框架进行开发,Anchor 是由 Solana 上的知名项目 Serum 团队开发的,可以精简很多账号验证及跨合约调用逻辑。
Anchor 是如何工作的呢?我们可以从 Jet Protocol 的一段代码说起:
programs/jet/src/instructions/init_deposit_account.rs

账号

这里的 deposit_account 账号就是用于存储 LP 代币数据的账号,用户在首次使用时,需要调用合约生成该账号,并支付一定的存储费用。
而这里的 #[account] 宏定义限定了这个账号的生成规则:
规则 1:#[account(init, payer = <target_account>, space = <num_bytes>)]
这个约束中,init 是指通过跨合约调用系统合约创建账号并初始化,payer=depositor 意思是 depositor 为新账号支付存储空间费用。
规则 2:#[account(seeds = <seeds>, bump)]
这个约束中将检查给定帐户是否是当前执行程序派生的 PDA,PDA (Program Derived Address) 账号是一个没有私钥、由程序派生的账号,seed 和 bump 是生成种子,如果 bump 未提供,则 Anchor 框架默认使用 canonical bump,可以理解成自动赋予一个确定性的值。
使用 PDA,程序可以以编程方式对某些地址进行签名,而无需私钥。同时,PDA 确保没有外部用户也可以为同一地址生成有效签名。这些地址是跨程序调用的基础,它允许 Solana 应用程序相互组合。这里用的是 "deposits" 字符 + reserve 账号公钥 + depositor 账号公钥作为 seeds,bump 则是在用户调用时传入。
规则 3:#[account(token::mint = <target_account>, token::authority = <target_account>)]
这是一个 SPL 约束,用于更简便地验证 SPL 账号。这里指定 deposit_account 账号是一个 token 账号,它的 mint 权限是 deposit_note_mint 账号,authority 权限是 market_authority。
Account 的宏定义还有很多,这里略表不提,详细可以考虑文档:
https://docs.rs/anchor-lang/latest/anchor_lang/derive.Accounts.html
有了这些前置知识,我们就可以直接来看漏洞代码:
programs/jet/src/instructions/withdraw_tokens.rs

账号

正常情况下,用户调用函数 withdraw_tokens 提币时,会传入自己的 LP 账号,然后合约会销毁他的 LP 并返还相应数量的代币。但这里我们可以看到 deposit_note_account 账号是没有进行任何约束的,用户可以随意传入其他用户的 LP 账号。难道使用别人的 LP 账号不需要他们的签名授权吗?
通过前面分析宏定义代码,我们已经知道了 market_authority 账号拥有 LP 代币的操作权限,确实不需要用户自己的签名。那么 market_authority 又是一个怎么样的账号呢?我们可以看这里:

  • programs/jet/src/instructions/init_market.rs
账号

这个 market_authority 也是一个 PDA 账号。也就是说合约通过自身的调用就可以销毁用户的 LP 代币。那么对于恶意用户来说,要发起攻击就很简单了,只要简单地把 deposit_note_account 账号设置为想要窃取的目标账号,withdraw_account 账号设置为自己的收款账号,就可以销毁他的 LP,并把他的存款本金提现到自己的账号上。
最后我们看一下官方的修复方法:

账号

补丁中并未直接去约束 deposit_note_account 账号,而是去除了 burn 操作的 PDA 签名,并将 authority 权限改成了 depositor,这样的话用户将无法直接调用这里的函数进行提现,而是要通过另一个函数 withdraw() 去间接调用,而在 withdraw() 函数中账号宏定义已经进行了严密的校验,恶意用户如果传入的是他人的 LP 账号,将无法通过宏规则的验证,将无法通过宏规则的验证,因为 depositor 需要满足 signer 签名校验,无法伪造成他人的账号。

programs/jet/src/instructions/withdraw.rs

账号

总结
本次漏洞的发现过程比较有戏剧性,漏洞的发现人 @charlieyouai 在他的个人推特上分享了漏洞发现的心路历程,当时他发现 burn 的权限是 market_authority,用户无法进行签名,认为这是一个 bug,会导致调用失败且用户无法提款,于是给官方提交了一个赏金漏洞,然后就去吃饭睡觉打豆豆了。
而后官方开发者意识到了问题的严重性,严格地说,他们知道这段代码没有无法提现的漏洞,而是人人都可以提现啊,老铁,一个能良好运行的 bug 你知道意味着什么吗?!所幸的是没有攻击事件发生。
目前在 Solana 上发生过多起黑客攻击事件均与账号校验问题有关,慢雾安全团队提醒广大 Solana 开发者,注意对账号体系进行严密的审查。

Leituras Relacionadas

The Permanent Underclass: No One Can Answer That 17-Year-Old Child

The article "The Permanent Underclass: No One Has an Answer for That 17-Year-Old" explores the concept of a "permanent underclass" emerging in a future where AI can perform most cognitive and physical labor. This theory, gaining traction in tech circles, suggests that as AI reduces the need for human workers, wages lose importance, and wealth increasingly flows to those who own AI models, compute, and data. The core issue is not temporary poverty but the potential breakdown of the traditional ladder of upward mobility—through labor, bargaining, and asset accumulation—making "underclass" a permanent status. The piece highlights a poignant question posed by researcher Jasmine Sun to AI lab personnel: What advice would you give a typical 17-year-old facing this future? Most had no answer, acknowledging the frightening transition ahead. However, while struggling to advise others, many in the AI field are securing their own positions, shifting from research or policy into labs to gain equity and stand on the "capital" side. This creates a vicious cycle: the more people believe labor's bargaining power is vanishing, the fewer work to rebuild it, accelerating its decline. Common personal survival strategies—learning AI skills, acquiring AI company equity, or pivoting to hands-on, in-person work—are analyzed. The author argues these are largely stopgaps, accessible mainly to the privileged, and may collectively undermine labor's overall position. The fundamental question shifts from "how not to fall behind" to "why must one's survival depend on being needed by capital?" The article concludes that the real solution is not individual adaptation but building a new societal "negotiating table"—new laws, forms of collective bargaining, or redistribution mechanisms (like taxes or public funds) to ensure the wealth AI creates is shared, especially with those displaced. It contrasts tentative institutional responses in China with a potential regulatory vacuum in the US, warning that without such frameworks being established before public frustration boils over, social unrest could follow. The 17-year-old’s dilemma underscores a systemic failure: the architects of this future are buying personal insurance but offering no collective answers.

marsbitHá 7m

The Permanent Underclass: No One Can Answer That 17-Year-Old Child

marsbitHá 7m

465% Growth in One Day: How a Memory Shortage Made CXMT China's Most Valuable Company

Chinese memory chip maker CXMT (ChangXin Memory Technologies) saw its shares surge 465.82% on its debut on the Shanghai STAR Market on July 27, 2026, closing at 49 yuan. Its market capitalization reached over 3.2 trillion yuan (~$473-488B), making it mainland China's most valuable listed company. This explosive debut coincided with staggering industry-wide profit growth. China's major integrated circuit manufacturers saw profits soar 2579.5% year-on-year in H1 2026. Specific companies like Shenzhen Longsys Electronics and GigaDevice Semiconductor reported profit growth exceeding 62,000% and 1000%, respectively. The primary driver is the AI boom, which has triggered massive global data center construction. Major memory giants like Samsung, SK Hynix, and Micron shifted capacity to high-margin AI accelerator memory (HBM), creating a severe shortage of standard DRAM used in servers, PCs, and smartphones. Contract DRAM prices spiked 90-95% QoQ in Q1 2026 and another 50-60% in Q2. CXMT, as China's largest domestic DRAM producer, capitalized on this deficit. It ramped up standard DRAM supply, secured long-term contracts with clients like ByteDance and Tencent, and expanded capacity. It forecasts H1 2026 revenue of 110-120B yuan and net profit of 50-57B yuan. A low comparative base from 2025's industry downturn and domestic policy support further fueled growth. However, analysts note a significant constraint: U.S. export controls on advanced lithography and manufacturing equipment limit CXMT's access to tools needed for cutting-edge HBM production. Its future trajectory will depend not just on global DRAM demand but also on China's ability to develop domestic semiconductor manufacturing equipment.

cryptonews.ruHá 7m

465% Growth in One Day: How a Memory Shortage Made CXMT China's Most Valuable Company

cryptonews.ruHá 7m

SkyCapital Expands Cooperation with Crypto Services Amid Regulatory Changes

SkyCapital, a financial technology company, has announced an expansion of its partnership program for crypto services in response to new, stricter regulations coming into force in Russia in September 2026. The company will offer its infrastructure to other market participants to help them transition from anonymous P2P transfers to a more transparent, legally compliant business model. According to SkyCapital's managing director, Dmitry Galkin, the move addresses a growing industry demand. He explained that after the new law takes effect, services lacking proper KYC/AML checks, anti-fraud protection, and SBP (Russia's Fast Payments System) acquiring will only be able to operate under a transitional period. Ultimately, they will face a clear choice: adapt with compliant infrastructure or shut down. The partnership model allows other crypto services to maintain their own brand and customer interface while utilizing SkyCapital's backend infrastructure. This includes SBP-acquiring, transaction execution, KYC/AML verification, anti-fraud systems, and regulatory reporting. This approach enables faster, more cost-effective compliance for partners without needing to build such systems from scratch. Galkin warned that non-compliant operators risk not just payment blocks and business limitations, but also potential criminal and administrative prosecution. SkyCapital believes the crypto market is entering a phase where competition is increasingly supplemented by partnerships focused on shared, reliable infrastructure to mitigate operational, regulatory, and reputational risks. This strategic shift signifies SkyCapital's broader role in the market, moving beyond its own platform to provide technological and compliance solutions for the wider industry. It reflects a broader trend in the Russian crypto sector away from fragmented, informal models towards collaboration around secure and formalized solutions.

cryptonews.ruHá 16m

SkyCapital Expands Cooperation with Crypto Services Amid Regulatory Changes

cryptonews.ruHá 16m

South Korean Giants LG CNS and POSCO International Implement Real-Time Trade Transaction Data on Injective Blockchain

South Korean conglomerates POSCO International and LG CNS have launched a pilot project to tokenize real trade accounts receivable on the Injective blockchain, using actual commercial data from POSCO's overseas subsidiaries. POSCO International, a major trading firm with over $22 billion in revenue, and LG CNS, a leading IT services provider, are testing this as an advanced real-world asset (RWA) initiative in Korea. The pilot issues POSCO's receivables as permissioned tokens on Injective. Authorized parties can hold and transfer these assets, with settlements executed on-chain. This moves away from the current fragmented tracking by subsidiaries, banks, and counterparties—which slows reconciliation and delays cash access—to a single shared ledger. Compliance rules are embedded with the tokens, enabling uniform checks across jurisdictions. Injective was chosen for its native real-world asset module, which enforces regulatory compliance at the protocol level. Its fast transaction finality (under one second per block) and built-in order book designed to prevent front-running were cited as essential for tokenizing real monetary claims. The companies aim to build a unified infrastructure for inter-subsidiary trade, enabling faster settlements than the current multi-day cycle and border-agnostic compliance. POSCO plans to refine the pilot structure in the second half of the year for real business application. This project is part of a global acceleration in enterprise tokenization, with Korea being a particularly active market.

cryptonews.ruHá 18m

South Korean Giants LG CNS and POSCO International Implement Real-Time Trade Transaction Data on Injective Blockchain

cryptonews.ruHá 18m

Trading

Spot
活动图片