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
~$15.9M Lost: Trusted Volumes & More | BlockSec Weekly
Security Insights

~$15.9M Lost: Trusted Volumes & More | BlockSec Weekly

This BlockSec bi-weekly security report covers 11 notable attack incidents identified between April 27 and May 10, 2026, across Sui, Ethereum, BNB Chain, Base, Blast, and Berachain, with total estimated losses of approximately $15.9M. Three incidents are analyzed in detail: the highlighted $1.14M Aftermath Finance exploit on Sui, where a signed/unsigned semantic mismatch in the builder-fee validation allowed an attacker to inject a negative fee that was converted into positive collateral during settlement; the $5.87M Trusted Volumes RFQ authorization mismatch on Ethereum; and the $5.7M Wasabi Protocol infrastructure-to-contract-control compromise across multiple EVM chains.

Newsletter - April 2026
Security Insights

Newsletter - April 2026

In April 2026, the DeFi ecosystem experienced three major security incidents. KelpDAO lost ~$290M due to an insecure 1-of-1 DVN bridge configuration exploited via RPC infrastructure compromise, Drift Protocol suffered ~$285M from a multisig governance takeover leveraging Solana's durable nonce mechanism, and Rhea Finance incurred ~$18.4M following a business logic flaw in its margin-trading module that allowed circular swap path manipulatio

~$7.04M Lost: GiddyDefi, Volo Vault & More | BlockSec Weekly
Security Insights

~$7.04M Lost: GiddyDefi, Volo Vault & More | BlockSec Weekly

This BlockSec weekly security report covers eight attack incidents detected between April 20 and April 26, 2026, across Ethereum, Avalanche, Sui, Base, HyperLiquid, and MegaETH, with total estimated losses of approximately $7.04M. The highlighted incident is the $1.3M GiddyDefi exploit, where the attacker did not break any cryptography or use a flash loan but simply replayed an existing on-chain EIP-712 signature with the unsigned `aggregator` and `fromToken` fields swapped out for a malicious contract, demonstrating how partial signature coverage turns any historical signature into a generic permit. Other incidents include a $3.5M Volo Vault operator key compromise on Sui, a $1.5M Purrlend privileged-role takeover, a $413K SingularityFinance oracle misconfiguration, a $142.7K Scallop cross-pool index injection, a $72.35K Kipseli Router decimal mismatch, a $50.7K REVLoans (Juicebox) accounting pollution, and a $64K Custom Rebalancer arbitrary-call exploit.

Best Security Auditor for Web3

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

BlockSec Audit