Back to Blog

ミラープロトコルがどのように悪用されたか

Code Auditing
May 31, 2022

Mirror Protocolが@FatManによって不正利用されたと報告されました。このブログには、その詳細なレポートがあります。この記事では、攻撃トランザクションを用いて、これがどのように発生したのかを詳しく説明します。

免責事項: この記事は、公開されているトランザクションと、Mirror ProtocolおよびTerraエコシステムに関する私たちの理解に基づいています。不正確な点がありましたら、お知らせください。このブログに関するコメントは歓迎します。

1 攻撃

1.1 準備

このトランザクションは、攻撃の準備に使用されます。

ステップ1: このトランザクションで、攻撃者はまず100,000 USTCをロックコントラクトに送信しました。これはポジションを開くために必須ではありませんが、攻撃にとっては極めて重要です。

ステップ2: その後、攻撃者は10 USTCを担保として預け入れ、collateral_ratioを2.5に指定してポジションを開きました。

short_paramsが指定されているため、ミントコントラクトはミントされたmAssets(つまりmETH)を販売し、得られたUSTCをポジションのロック額に追加します。

ステップ2.1: トランザクションをステップごとに見ていきましょう。まず、open_position関数が呼び出され、IDが43186のショートポジションが開かれます。

ステップ2.2: オプションのshort_paramsが追加されているため、コントラクトはまず0.001208 mETH(現在のETH価格に基づく)をミントし、次にmETH-UST Pairでスワップして販売します。

ステップ2.3: 0.001208 mETHは4.06582 USTCにスワップされ、スワップされたUSTCは、関連手数料(税金など)が差し引かれた後、ロックコントラクトに送信されます。これは、開かれたポジションは一定期間後にしかアンロックできないためです。

ステップ2.4: 次にlock_position_funds_hookが呼び出されます。この関数では、current_balanceをクエリし、current_balancelocked_fundsを比較してposition_locked_amountが計算されます。

しかし、ステップ1で見たように、100,000 USTCが直接ロックコントラクトに転送されているため、locked_amount4 USTCではなく、約100,004 USTCになります。

ステップ2.5: 最後に、increase_short_tokenが呼び出され、sLPトークンが記録されます。

これで、攻撃者は直接ロックコントラクトに100,000 USTCを送信し、担保として10 USTCを預け入れてポジションを開きました。ポジションのロック額は約100,004 USTCで、一定期間後にアンロックできます。攻撃者は、1,000から100,000 USTCを送信して、このようなポジションを多数開きました。

1.2. 攻撃

Mirror Protocolは、ポジションIDの重複をチェックしません。この場合、攻撃者はロックされた金額を繰り返しアンロックするために、多くの重複したポジションIDを入力できます。

このトランザクションは、攻撃トランザクションです。例えば、ポジションID43186では、攻撃者は437回重複させました。

元のコントラクトコードは重複をチェックしないため、(この単一の関数呼び出しで)約43.7M437 * 0.1M)USTCがアンロックされました。

なお、他のポジションも同様のメカニズムでアンロックされています。

2. バグ修正

この脆弱性は、このコミットで修正されました。

具体的には、unlockable_positionsはアンロックされるポジションIDを含むベクトルです。元のコードでは、unlockable_positionsに重複IDがあるかのチェックはありませんでした。パッチが適用されたコードでは、ポジションIDの重複チェックが追加されています。

3. 結論

@FatManや他のコミュニティメンバーが指摘したように、このバグは数ヶ月前から存在し、実際に悪用されていました。すでに悪用された脆弱性を黙ってパッチすることは、良いセキュリティプラクティスではないと考えています。さらに、注目度の高いDeFiプロジェクトは、アプリケーションのステータスを積極的に監視し、異常が発生した際にアラートを発するゲートキーパーを配置すべきだと考えています。

Sign up for the latest updates
Tracing $1.6B in TRON USDT: Inside the VerilyHK Ponzi Infrastructure
Case Studies

Tracing $1.6B in TRON USDT: Inside the VerilyHK Ponzi Infrastructure

An on-chain investigation into VerilyHK, a fraudulent platform that moved $1.6B in TRON USDT through a multi-layered fund-routing infrastructure of rotating wallets, paired payout channels, and exchange exit funnels, with traced connections to the FinCEN-sanctioned Huione Group.

Weekly Web3 Security Incident Roundup | Mar 30 – Apr 5, 2026
Security Insights

Weekly Web3 Security Incident Roundup | Mar 30 – Apr 5, 2026

This BlockSec weekly security report covers nine DeFi attack incidents detected between March 30 and April 5, 2026, across Solana, BNB Chain, Arbitrum, and Polygon, with total estimated losses of approximately $287M. The week was dominated by the $285.3M Drift Protocol exploit on Solana, where attackers combined multisig signer social engineering with Solana's durable nonce mechanism to bypass a zero-timelock 2-of-5 Security Council, alongside notable incidents including a $950K flash loan TWAP manipulation against the LML staking protocol, a $359K Silo Finance vault inflation via an external `wstUSR` market donation exploiting a depegged-asset oracle and `totalAssets()` accounting flaw, and an EIP-7702 delegated-code access control failure. The report provides detailed vulnerability analysis and attack transaction breakdowns for each incident, covering flawed business logic, access control, price manipulation, phishing, and misconfiguration attack types.

Drift Protocol Incident: Multisig Governance Compromise via Durable Nonce Exploitation
Security Insights

Drift Protocol Incident: Multisig Governance Compromise via Durable Nonce Exploitation

On April 1, 2026 (UTC), Drift Protocol on Solana suffered a $285.3M loss after an attacker exploited Solana's durable nonce mechanism to delay the execution of phished multisig approvals, ultimately transferring administrative control of the protocol's 2-of-5 Squads governance with zero timelock. With full admin privileges, the attacker created a malicious collateral market (CVT), inflated its oracle price, relaxed withdrawal protections, and drained USDC, JLP, SOL, cbBTC, and other assets through 31 rapid withdrawals in approximately 12 minutes. This incident highlights how durable nonce-based delayed execution can decouple signer intent from on-chain execution, bypassing the temporal assumptions that multisig security implicitly relies on.

Best Security Auditor for Web3

Validate design, code, and business logic before launch. Aligned with the highest industry security standards.

BlockSec Audit