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
Building a Secure Stablecoin Payment Network: BlockSec Partners with Morph
Partnership

Building a Secure Stablecoin Payment Network: BlockSec Partners with Morph

BlockSec has partnered with Morph as an official audit partner for the $150M Morph Payment Accelerator. By offering exclusive discounts on smart contract audits and penetration testing, BlockSec provides institutional-grade security to payment builders, ensuring a safe and resilient foundation for the future of global stablecoin payments.

Weekly Web3 Security Incident Roundup | Mar 9 – Mar 15, 2026
Security Insights

Weekly Web3 Security Incident Roundup | Mar 9 – Mar 15, 2026

This BlockSec weekly security report covers eight DeFi attack incidents detected between March 9 and March 15, 2026, across Ethereum and BNB Chain, with total estimated losses of approximately $1.66M. Incidents include a $1.01M AAVE incorrect liquidation caused by oracle misconfiguration, a $242K exploit on the deflationary token MT due to flawed trading restrictions, a $149K exploit on the burn-to-earn protocol DBXen from `_msgSender()` and `msg.sender` inconsistency, and a $131K attack on AM Token exploiting a flawed delayed-burn mechanism. The report provides detailed vulnerability analysis and attack transaction breakdowns for each incident.

Venus Thena (THE) Incident: What Broke and What Was Missed

Venus Thena (THE) Incident: What Broke and What Was Missed

On March 15, 2026, an attacker bypassed the THE (Thena) supply cap on Venus Protocol (BNB Chain) through a donation attack, inflating a collateral position to 3.67x the intended limit and borrowing ~$14.9M in assets. Both sides lost money on-chain: Venus was left with ~$2.15M in bad debt after 254 liquidation bots competed across 8,048 transactions, while the attacker retained only ~$5.2M against a $9.92M investment. This deep dive examines what broke across three lines of defense (exposure limits, collateral valuation, and liquidation) and the monitoring gaps that left months of on-chain warning signals unacted upon.

Best Security Auditor for Web3

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

BlockSec Audit