Back to Blog

市場リスクを超えて:SushiSwapのKashiPairMediumRiskV1コントラクトにおけるロジックバグの特定

Code Auditing
December 15, 2022

2022年11月8日、Sushiの公式KashiPairMediumRiskV1コントラクト(またはそれをフォークしたコントラクト)の上に構築された一部のプールから、資産が流出した攻撃を検出しました。調査の結果、根本原因はトークン価格の誤計算を引き起こすロジックバグであることが判明しました。

直ちにSushiのセキュリティチームに連絡したところ、彼らは我々の発見を確認しました。幸いなことに、彼らは脆弱なプールを攻撃から保護するための対策を講じていました。さらに、不正利用によって資金を失った人々への補償手続きも提供されました。そのため、脆弱性と攻撃に関する詳細を公開しても安全であると判断しました。本レポートでは、詳細な分析を提供します。

脆弱性分析

KashiPairMediumRiskV1コントラクトのソースコードを分析した結果、このバグは borrow 関数にあり、solvent モディファイアで借入シェアを検証する際に、古い exchangeRate を使用していると結論付けました。具体的には、_isSolvent 関数内の現在の exchangeRate の値に基づいて検証が行われます。

一方、liquidate 関数では、最初に updateExchangeRate 関数が呼び出されます。したがって、検証と計算は更新された値に基づいて行われます。

明らかに、このバグは(巨額の)価格差につながる可能性があり、悪用される可能性があります。

攻撃分析

2件の攻撃が観測されました。

  1. 0xcf8f242ea83100b6d43e659f7f53a698d304fc6ac2ca6fe79e3e07ee05fefe58: 被害者はKashiPairMediumRiskV1コントラクトを使用しており、損失は約9,466 USDCでした。
  2. 0x3d163bfbec5686d428a6d43e45e2626a220cc4fcfac7620c620b82c1f2537c78: 被害者はCauldronMediumRiskV1(KashiPairMediumRiskV1のフォーク)を使用する戦略コントラクトであり、損失は約110,911 MIMでした。

注:最初の攻撃トランザクションは、元の攻撃トランザクションである0x7a845d8d2af7919f5b9e22dd5571305cb5347d17986a8402715c1463d515fc18をフロントランするボットによって実行されました。元の攻撃者のアドレスは0xb7ea0f0f8c6df7a61bf024db21bbe85ac5688005です。

ここでは、次のステップで構成される最初の攻撃トランザクションを例として取り上げます。

  1. Balancerから40,900 BADGERと121,904 USDCのフラッシュローンを借り入れます。
  2. 40,900 BADGERと113,599 USDCをBentoBoxに預け入れます。
  3. kmBADGER/USDC-LINKのaddCollateral関数を呼び出し、40,900,000,000,000,000,000,000 SHARESのBADGERを預け入れます。
  4. kmBADGER/USDC-LINKのaddAsset関数を呼び出し、112,529,000,000 SHARESのUSDCを預け入れます。
  5. borrow関数を呼び出し、120,755,095,093 SHARESのUSDCを借ります。
  6. UpdateExchangeRate関数を呼び出します。
  7. liquidate関数を呼び出し、自身を清算します。
  8. BentoBoxから40,899 BADGERと123,006 USDCを引き出します。
  9. フラッシュローンを返済し、約9466 USDCの利益を得ます。

注:ステップ6は必須ではありません。なぜなら、borrow関数はUpdateExchangeRate関数を呼び出すためです。

主要なステップは次のとおりです。

borrow 関数で使用される exchangeRate の値と liquidate 関数で使用される値が乖離していることは、容易に理解できます。

  • borrow 関数内: 250,997,938,545,109,237,740,214,705,193
  • liquidate 関数内: 328,266,883,541,864,569,505,752,156,794

影響

EthereumとBSCの両方で、このバグの影響を受ける可能性のあるプールが数十個存在します。この問題を軽減するための暫定的な方法は、UpdateExchangeRate 関数を時折(または定期的に)呼び出すことで、乖離を減らすか排除することです。この方法はすでに多くの影響を受けたプロジェクトで採用されており、対応するトランザクションは実際に確認できます。

まとめ

DeFiプロジェクトを安全にすることは容易ではありません。コード監査に加えて、コミュニティはプロジェクトの状況を積極的に監視し、攻撃が発生する前にブロックするべきだと考えています。

BlockSecについて

BlockSecは、世界的に著名なセキュリティ専門家グループによって2021年に設立された、先駆的なブロックチェーンセキュリティ企業です。同社は、新興のWeb3世界におけるセキュリティとユーザビリティの向上に尽力しており、その普及を促進しています。この目的のために、BlockSecはスマートコントラクトおよびEVMチェーンのセキュリティ監査サービス、セキュリティ開発および脅威のプロアクティブなブロックのためのPhalconプラットフォーム、資金追跡および調査のためのMetaSleuthプラットフォーム、そしてWeb3開発者が暗号世界を効率的にサーフィンするためのMetaDock拡張機能を提供しています。

現在までに、同社はMetaMask、Uniswap Foundation、Compound、Forta、PancakeSwapなど300社以上の著名なクライアントにサービスを提供し、Matrix Partners、Vitalbridge Capital、Fenbushi Capitalなどの有力な投資家から2回の資金調達で数千万米ドルを受け取っています。

公式ウェブサイト: https://blocksec.com/

公式Twitterアカウント: https://twitter.com/BlockSecTeam

Sign up for the latest updates
Tether Freezes $6.76M USDT Linked to Iran's IRGC & Houthi Forces: Why On-Chain Compliance is Now a Geopolitical Battlefield
Security Insights

Tether Freezes $6.76M USDT Linked to Iran's IRGC & Houthi Forces: Why On-Chain Compliance is Now a Geopolitical Battlefield

Looking ahead, targeted freezing events like this $6.76M USDT action will only become more common. On-chain data analysis is improving. Stablecoin issuers are also working closely with regulators. As a result, hidden illicit financial networks will be exposed.

Weekly Web3 Security Incident Roundup | Mar 2 – Mar 8, 2026
Security Insights

Weekly Web3 Security Incident Roundup | Mar 2 – Mar 8, 2026

During the week of March 2 to March 8, 2026, seven blockchain security incidents were reported with total losses of ~$3.25M. The incidents occurred across Base, BNB Chain, and Ethereum, exposing critical vulnerabilities in smart contract business logic, token deflationary mechanics, and asset price manipulation. The primary causes included a double-minting logic flaw during full token deposits that allowed an attacker to exponentially inflate their balances through repeated burn-and-mint cycles, a price manipulation vulnerability in an AMM-based lending market where artificially inflated vault shares created divergent price anchors to incorrectly force healthy positions into liquidation, and a flawed access control implementation relying on trivially spoofed contract interfaces that enabled attackers to bypass authorization to batch-mint and dump arbitrary tokens.

Weekly Web3 Security Incident Roundup | Feb 23 – Mar 1, 2026
Security Insights

Weekly Web3 Security Incident Roundup | Feb 23 – Mar 1, 2026

During the week of February 23 to March 1, 2026, seven blockchain security incidents were reported with total losses of ~$13M. The incidents affected multiple protocols, exposing critical weaknesses in oracle design/configuration, cryptographic verification, and core business logic. The primary drivers included oracle manipulation/misconfiguration that led to the largest loss at YieldBloxDAO (~$10M), a crypto-proof verification flaw that enabled the FOOMCASH (~$2.26M) exploit, and additional token design and logic errors impacting Ploutos, LAXO, STO, HedgePay, and an unknown contract, underscoring the need for rigorous audits and continuous monitoring across all protocol layers.

Best Security Auditor for Web3

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

BlockSec Audit