损失超过 4000 万美元,GMX 攻击原理分析

链捕手Pubblicato 2025-07-10Pubblicato ultima volta 2025-07-10

作者:BlockSec

GMX 遭遇黑客攻击,损失超过 4000 万美元。攻击者利用了一个可重入漏洞,并在合约启用杠杆功能的情况下开空头头寸,实施了攻击。

问题的根源在于 executeDecreaseOrder 函数被错误使用。该函数的第一个参数本应是外部账户(EOA),但攻击者传入了一个智能合约地址。这使得攻击者可以在赎回过程中重新进入系统,操纵内部状态,最终赎回的资产远超过其实际持有的 GLP 价值

GLP正常赎回机制

GMX 中,GLP 是流动性提供者代币,代表对金库资产(如 USDC、ETH、WBTC)的份额。当用户调用 unstakeAndRedeemGlp 时,系统使用以下公式计算应返还的资产数量:

redeem_amount = (user_GLP / total_GLP_supply) * AUM

其中 AUM(管理资产总额)的计算方式为:

AUM = 所有 token 池的总价值 + 全局空头未实现亏损 - 全局空头未实现盈利 - 已预留金额 - 预设扣减(aumDeduction)

该机制保证了 GLP 持有者按比例获得金库的实际资产份额。

杠杆开启后的问题

enableLeverage 开启后,用户可以开设杠杆仓位(多头或空头)。攻击者在赎回 GLP 前,开设了大额的 WBTC 空头头寸。

由于空头一开仓便增加了全局空头规模,价格尚未变动的情况下系统默认该空头是亏损的,而这部分未实现亏损会被计为金库的“资产”,导致 AUM 人为上升。尽管金库并未实际获得额外价值,但赎回计算会基于这个虚高的 AUM,从而使攻击者获得了远超其应得的资产。

攻击流程

攻击交易

https://app.blocksec.com/explorer/tx/arbitrum/0x03182d3f0956a91c4e4c8f225bbc7975f9434fab042228c7acdc5ec9a32626ef?line=93

 

图片
图片

写在结尾

此次攻击暴露了 GMX 在杠杆机制与可重入保护设计上的严重缺陷。核心问题在于资产赎回逻辑对 AUM 的信任过高,未对其组成部分(如未实现亏损)进行足够审慎的安全校验。同时,关键函数对调用者身份的假设(EOA vs 合约)也缺乏强制性验证。该事件再次提醒开发者,在涉及资金敏感操作时,必须确保系统状态不可被操纵,尤其是在引入复杂金融逻辑(如杠杆、衍生品)时,更需严防重入与状态污染带来的系统性风险。

 

Letture associate

Warsh's Debut: Will the FED Chair Who Knows Crypto Best Bring Surprises or Shocks to the Market?

Kevin Warsh, the new Federal Reserve Chairman, prepares for his inaugural press conference amidst a challenging macroeconomic landscape: resurgent inflation, a bond market sell-off, and political pressure from President Trump for rate cuts. Uniquely, Warsh holds indirect investments in over 20 crypto and Web3 entities (e.g., Solana, dYdX), making him the first Fed Chair with disclosed crypto exposure. His stance may combine a hawkish, inflation-focused monetary policy with a crypto-friendly regulatory philosophy that shifts from Powell’s “same risk, same rule” approach toward a framework acknowledging blockchain’s productivity value. Warsh’s leadership could impact crypto markets across three dimensions: a paradigm shift in regulation (potentially accelerating pro-innovation legislation and stable币 rules), a re-pricing of risk premiums based on clearer communication and his view of AI as a structural disinflationary force, and a long-term reallocation of global institutional capital driven by increased legitimacy. Two potential scenarios for the press conference are outlined. A “positive surprise” would involve a dovish-leaning tone on rates coupled with signals of regulatory openness, potentially boosting crypto asset valuations. Conversely, a “negative shock” would see a more hawkish-than-expected stance on inflation and rates, triggering a broad risk-asset selloff that crypto markets would not escape. While ethics rules required Warsh to divest his crypto holdings upon confirmation, his deep understanding of the technology may fundamentally lower policy uncertainty and build a more receptive long-term foundation for digital assets’ integration into the mainstream financial system.

marsbit1 h fa

Warsh's Debut: Will the FED Chair Who Knows Crypto Best Bring Surprises or Shocks to the Market?

marsbit1 h fa

Trading

Spot
Futures

Articoli Popolari

Come comprare GMX

Benvenuto in HTX.com! Abbiamo reso l'acquisto di GMX (GMX) semplice e conveniente. Segui la nostra guida passo passo per intraprendere il tuo viaggio nel mondo delle criptovalute.Step 1: Crea il tuo Account HTXUsa la tua email o numero di telefono per registrarti il tuo account gratuito su HTX. Vivi un'esperienza facile e sblocca tutte le funzionalità,Crea il mio accountStep 2: Vai in Acquista crypto e seleziona il tuo metodo di pagamentoCarta di credito/debito: utilizza la tua Visa o Mastercard per acquistare immediatamente GMXGMX.Bilancio: Usa i fondi dal bilancio del tuo account HTX per fare trading senza problemi.Terze parti: abbiamo aggiunto metodi di pagamento molto utilizzati come Google Pay e Apple Pay per maggiore comodità.P2P: Fai trading direttamente con altri utenti HTX.Over-the-Counter (OTC): Offriamo servizi su misura e tassi di cambio competitivi per i trader.Step 3: Conserva GMX (GMX)Dopo aver acquistato GMX (GMX), conserva nel tuo account HTX. In alternativa, puoi inviare tramite trasferimento blockchain o scambiare per altre criptovalute.Step 4: Scambia GMX (GMX)Scambia facilmente GMX (GMX) nel mercato spot di HTX. Accedi al tuo account, seleziona la tua coppia di trading, esegui le tue operazioni e monitora in tempo reale. Offriamo un'esperienza user-friendly sia per chi ha appena iniziato che per i trader più esperti.

107 Totale visualizzazioniPubblicato il 2024.12.10Aggiornato il 2026.06.02

Come comprare GMX

Discussioni

Benvenuto nella Community HTX. Qui puoi rimanere informato sugli ultimi sviluppi della piattaforma e accedere ad approfondimenti esperti sul mercato. Le opinioni degli utenti sul prezzo di GMX GMX sono presentate come di seguito.

活动图片