Back to Blog

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

Code Auditing
December 15, 2022
4 min read

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 です。

ここでは、最初の攻撃トランザクション the first attack transaction を例として取り上げ、以下の手順で構成されています。

  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,000sharesの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の普及を促進するために、新興の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
The Decentralization Dilemma: Cascading Risk and Emergency Power in the KelpDAO Crisis
Security Insights

The Decentralization Dilemma: Cascading Risk and Emergency Power in the KelpDAO Crisis

This BlockSec deep-dive analyzes the KelpDAO $290M rsETH cross-chain bridge exploit (April 18, 2026), attributed to the Lazarus Group, tracing a causal chain across three layers: how a single-point DVN dependency enabled the attack, how DeFi composability cascaded the damage through Aave V3 lending markets to freeze WETH liquidity exceeding $6.7B across Ethereum, Arbitrum, Base, Mantle, and Linea, and how the crisis forced decentralized governance to exercise centralized emergency powers. The article examines three parameters that shaped the cascade's severity (LTV, pool depth, and cross-chain deployment count) and provides an exclusive technical breakdown of Arbitrum Security Council's forced state transition, an atomic contract upgrade that moved 30,766 ETH without the holder's signature.

Weekly Web3 Security Incident Roundup | Apr 13 – Apr 19, 2026
Security Insights

Weekly Web3 Security Incident Roundup | Apr 13 – Apr 19, 2026

This BlockSec weekly security report covers four attack incidents detected between April 13 and April 19, 2026, across multiple chains such as Ethereum, Unichain, Arbitrum, and NEAR, with total estimated losses of approximately $310M. The highlighted incident is the $290M KelpDAO rsETH bridge exploit, where an attacker poisoned the RPC infrastructure of the sole LayerZero DVN to fabricate a cross-chain message, triggering a cascading WETH freeze across five chains and an Arbitrum Security Council forced state transition that raises questions about the actual trust boundaries of decentralized systems. Other incidents include a $242K MMR proof forgery on Hyperbridge, a $1.5M signed integer abuse on Dango, and an $18.4M circular swap path exploit on Rhea Finance's Burrowland protocol.

Weekly Web3 Security Incident Roundup | Apr 6 – Apr 12, 2026
Security Insights

Weekly Web3 Security Incident Roundup | Apr 6 – Apr 12, 2026

This BlockSec weekly security report covers four DeFi attack incidents detected between April 6 and April 12, 2026, across Linea, BNB Chain, Arbitrum, Optimism, Avalanche, and Base, with total estimated losses of approximately $928.6K. Notable incidents include a $517K approval-related exploit where a user mistakenly approved a permissionless SquidMulticall contract enabling arbitrary external calls, a $193K business logic flaw in the HB token's reward-settlement logic that allowed direct AMM reserve manipulation, a $165.6K exploit in Denaria's perpetual DEX caused by a rounding asymmetry compounded with an unsafe cast, and a $53K access control issue in XBITVault caused by an initialization-dependent check that failed open. The report provides detailed vulnerability analysis and attack transaction breakdowns for each incident.

Best Security Auditor for Web3

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

BlockSec Audit