Oracle Flashloan Analysisのロゴ

Oracle Flashloan Analysis

組織
quillai-network
oracle-flashloan-analysis

DeFiスマートコントラクトにおける価格オラクルの操作やフラッシュローン攻撃の手口を検出します。オラクルの信頼モデル(Chainlink、TWAP、スポット価格、カスタム)を分類し、古い価格データのリスク、循環的な価格依存関係、フラッシュローンによるアトミック性の悪用パターンを特定します。価格データに依存するDeFiプロトコル、オラクル連携、レンディングプロトコル、DEX、デリバティブ、または単一トランザクション内のフラッシュローンで状態を操作される可能性があるコントラクトの監査に使用します。

Add to TypingMind

概要

公開者quillai-network
リポジトリquillshield_skills
スキル名oracle-flashloan-analysis
スター
131
フォーク
28
同梱ファイル
2
ライセンスMIT
リンク
  • Markdown形式の指示

    モデルが必要に応じて読み込むSKILL.mdファイルです。関連するリクエストがあったときだけトークンを消費します。

  • どのLLMでも利用可能

    AIスキルはプロバイダー固有のコードではなく、通常のMarkdownなので、GPT、Claude、Gemini、Grok、ローカルモデルで利用できます。

  • 2個の同梱ファイル

    モデルが作業中に読み取れるスクリプト、テンプレート、参考資料です。ファイルは読み取り専用で、実行されることはありません。

  • オープンソース

    quillai-networkがGitHubで公開しています。インストールする前にソースを確認してください。

インストール

AIスキル「Oracle Flashloan Analysis」をTypingMindにインストールすれば、どのLLMでも利用できます。SKILL.mdを読み取れる別のAIエージェントに追加することもできます。

1

TypingMindにインストール

TypingMindはGitHubフォルダから直接スキルをインストールします。SKILL.mdを読み取り、リソースファイルをまとめてローカルに保存します。

  1. アプリを開き、「プラグイン」→「スキル」に移動します。
  2. 「GitHubからインストール」を選択します。
  3. 以下のスキルフォルダのURLを貼り付けて確定します。
    https://github.com/quillai-network/quillshield_skills/tree/main/plugins/oracle-flashloan-analysis/skills/oracle-flashloan-analysis
  4. スキルを利用したいチャットごとに、そのスキルを有効にしてください。
「プラグイン」→「スキル」→「スキルを追加」→「GitHubのURLから」を選択し、フォルダのURLを貼り付けて「続行」を押します。
2

別のAIエージェントにインストール

Agent Skills形式を読み取れるAIエージェントなら、このスキルを利用できます。フォルダをそのAIエージェントのスキルディレクトリにコピーしてください。

Claude Code — .claude/skills
git clone --depth 1 https://github.com/quillai-network/quillshield_skills.git /tmp/quillshield_skills
mkdir -p .claude/skills
cp -r /tmp/quillshield_skills/plugins/oracle-flashloan-analysis/skills/oracle-flashloan-analysis .claude/skills/oracle-flashloan-analysis
コピー後、新しいスキルを読み込むためにClaude Codeを再起動してください。

TypingMindで使用

TypingMindのチャットでOracle Flashloan Analysisを有効にするだけで、あとはモデルが対応します。名前と説明がシステムプロンプトに含まれ、関連するリクエストがあると、モデルが指示の全文を自動で読み込みます。手動で呼び出す必要はなく、実際に使用されるまでトークンを消費しません。

関連するリクエストがあるとすぐに、モデルが自動的にOracle Flashloan Analysisを読み込みます。

どのAIモデルでも利用可能

AIスキルはプロバイダー固有のコードではなく、通常のMarkdownで書かれた指示です。そのため、Oracle Flashloan Analysisは作成時に想定されたモデルに縛られません。TypingMindに一度インストールすれば、ご自身のAPIキーを使って、GPT-5、Claude、Gemini、Grok、DeepSeek、Mistral、Llama、またはご自身で実行するローカルモデルで利用できます。

  • 必要なときだけ読み込み

    システムプロンプトには名前と説明だけが含まれます。関連するリクエストが初めてあったときに指示を取得するため、スキルを使わない間は指示の読み込みにトークンを消費しません。

  • チャットの途中でモデルを切り替え

    スキルはコードではなく指示なので、モデルを切り替えてもそのまま使えます。次のモデルも同じSKILL.mdを読み込みます。

スキルの指示

モデルが読み込むSKILL.mdの内容です。スキルはモデルが従う指示なので、インストールする前に確認してください。

Oracle & Flash Loan Analysis

Detect vulnerabilities where external price data can be manipulated or flash loans can exploit protocol logic within a single transaction. These two attack vectors are often combined and represent the most common DeFi attack pattern.

When to Use

  • Auditing any DeFi protocol that reads external price data (lending, DEX, derivatives, yield aggregators)
  • Reviewing Chainlink, Uniswap TWAP, Band Protocol, or custom oracle integrations
  • Analyzing protocols that interact with or are accessible via flash loans
  • Threat modeling for MEV, sandwich attacks, and price manipulation
  • When a protocol uses balanceOf(), pool reserves, or spot prices for critical calculations

When NOT to Use

  • Contracts with no price dependencies or external data feeds
  • Pure access control analysis (use semantic-guard-analysis)
  • State-to-state invariant checking (use state-invariant-detection)

Core Concept: The Oracle Trust Hierarchy

Not all price sources are equally secure. Oracle vulnerabilities stem from the gap between assumed trust and actual manipulation resistance.

Trust Level (highest to lowest):
┌─────────────────────────────────────────────┐
│ Level 5: Multi-oracle consensus + circuit    │
│          breakers + TWAP + staleness checks  │
├─────────────────────────────────────────────┤
│ Level 4: Chainlink with full validation      │
│          (staleness, sequencer, min answers)  │
├─────────────────────────────────────────────┤
│ Level 3: Uniswap V3 TWAP (long window)      │
│          Multi-block manipulation cost        │
├─────────────────────────────────────────────┤
│ Level 2: Uniswap V2 TWAP (short window)     │
│          or Chainlink WITHOUT staleness check │
├─────────────────────────────────────────────┤
│ Level 1: Spot price from single pool         │ ← Manipulable via flash loan
│          or balanceOf() for pricing           │
└─────────────────────────────────────────────┘

The Four-Phase Detection Architecture

Phase 1: Oracle Source Identification

Locate every point where the contract reads external price/value data.

Search for these patterns:

PatternOracle TypeRisk Level
latestRoundData()ChainlinkMedium (depends on validation)
latestAnswer()Chainlink (deprecated)HIGH (no round validation)
observe() / consult()Uniswap TWAPMedium (depends on window)
getReserves()AMM spot priceCRITICAL (flash-loan manipulable)
balanceOf(address(this))Self-balanceCRITICAL (donation attack)
slot0() / sqrtPriceX96Uniswap V3 spotCRITICAL (single-block manipulable)
Custom getPrice()UnknownRequires investigation

Build an Oracle Dependency Map:

Contract: LendingPool
├── borrowLimit() → uses getCollateralPrice()
│   └── getCollateralPrice() → calls chainlinkOracle.latestRoundData()
├── liquidate() → uses getDebtPrice()
│   └── getDebtPrice() → calls uniswapPool.slot0() ← SPOT PRICE!
└── calculateInterest() → uses getUtilizationRate()
    └── getUtilizationRate() → reads internal state (safe)

Phase 2: Oracle Validation Verification

For each oracle source, verify that proper safety checks are in place.

Chainlink Validation Checklist:

solidity
// COMPLETE Chainlink integration
(uint80 roundId, int256 price, , uint256 updatedAt, uint80 answeredInRound) =
    priceFeed.latestRoundData();

require(price > 0, "Invalid price");                    // Check 1: Non-negative
require(updatedAt > 0, "Round not complete");            // Check 2: Round complete
require(answeredInRound >= roundId, "Stale price");      // Check 3: Not stale
require(block.timestamp - updatedAt < HEARTBEAT,         // Check 4: Fresh
        "Price too old");

// L2-specific
require(!sequencerFeed.isDown(), "Sequencer down");      // Check 5: L2 sequencer
require(block.timestamp - sequencerUptime > GRACE,       // Check 6: Grace period
        "Grace period");

Missing Check Severity:

Missing CheckSeverityImpact
price > 0HIGHZero/negative price → infinite borrowing or free liquidations
updatedAt > 0MEDIUMIncomplete round data used
answeredInRound >= roundIdHIGHStale price from previous round
Heartbeat/freshnessHIGHHours-old price during volatile markets
L2 sequencer checkHIGHStale price during L2 outage → unfair liquidations
Price deviation boundsMEDIUMExtreme outlier not filtered

TWAP Validation:

Window length analysis:
  - < 10 minutes: HIGH RISK — manipulable with moderate capital
  - 10-30 minutes: MEDIUM RISK — expensive but feasible multi-block manipulation
  - 30+ minutes: LOWER RISK — requires sustained pool manipulation
  - Check: Is the TWAP window configurable? Can governance reduce it?

Phase 3: Flash Loan Attack Surface Analysis

Identify operations that can be exploited via flash loan atomicity.

Flash Loan Attack Model:

Single Transaction:
  1. Borrow N tokens via flash loan (Aave, dYdX, Balancer)
  2. Manipulate price source (swap in pool, donate to contract)
  3. Exploit protocol at manipulated price (borrow, liquidate, swap)
  4. Reverse manipulation (swap back)
  5. Repay flash loan + fee
  6. Profit = exploited_value - flash_loan_fee - gas

Detection Algorithm:

For each function F that reads price/value data:
  1. Identify the price source S
  2. Can S be manipulated within a single transaction?
     - Spot price from AMM → YES (swap in same tx)
     - balanceOf(address(this)) → YES (donate tokens)
     - Chainlink feed → NO (off-chain updates)
     - TWAP → DEPENDS (short window = risky)
  3. What does F do with the price?
     - Determines borrowing limit → CRITICAL
     - Triggers liquidation → CRITICAL
     - Sets exchange rate → HIGH
     - Informational only → LOW
  4. Is the manipulation profitable?
     - value_extracted - (flash_loan_fee + slippage + gas) > 0 → EXPLOIT VIABLE

Common Flash Loan Attack Patterns:

PatternTargetMethod
Oracle manipulationLending protocolFlash swap in pool → inflate collateral price → over-borrow
Governance attackDAO/votingFlash borrow governance tokens → vote → execute → return
Liquidation manipulationLending protocolFlash swap to crash price → liquidate at discount
Share price inflationVault/ERC4626Flash loan → donate to vault → inflate share price → front-run deposit
Arbitrage amplificationAMM/DEXFlash loan amplifies existing price discrepancy

Phase 4: Circular Dependency Detection

Find cases where a protocol's pricing depends on its own state, creating exploitable feedback loops.

Circular Dependency Pattern:

Protocol A uses Token X price → from Pool P
Pool P contains Token X + Token Y
Protocol A issues Token X (or affects its supply)

→ CIRCULAR: Protocol A's actions change Token X supply
            → changes Pool P reserves
            → changes Token X price
            → changes Protocol A's valuations

Detection:

For each price oracle call in the contract:
  1. What token/asset is being priced?
  2. Does THIS contract mint, burn, or distribute that token?
  3. Does THIS contract add/remove liquidity from the pricing pool?
  4. Does any action in THIS contract affect the reserves of the pricing pool?

  If YES to any → CIRCULAR DEPENDENCY
  Severity: CRITICAL if the circular path can be exploited atomically

Workflow

Task Progress:
- [ ] Step 1: Identify all oracle/price data sources in the contract
- [ ] Step 2: Classify each source by trust level (Chainlink, TWAP, spot, custom)
- [ ] Step 3: Verify validation checks for each oracle source
- [ ] Step 4: Map flash loan attack surfaces (which operations use manipulable prices?)
- [ ] Step 5: Detect circular price dependencies
- [ ] Step 6: Estimate manipulation cost vs profit (feasibility analysis)
- [ ] Step 7: Score findings and generate report

Output Format

markdown
## Oracle & Flash Loan Analysis Report

### Finding: [Title]

**Function:** `functionName()` at `Contract.sol:L42`
**Category:** [Oracle Manipulation | Stale Price | Flash Loan | Circular Dependency]
**Severity:** [CRITICAL | HIGH | MEDIUM]

**Oracle Source:** `[oracle contract/function]`
**Trust Level:** [1-5 from hierarchy]

**Vulnerability:**
[Description of how the price source can be manipulated or is insufficiently validated]

**Attack Scenario:**
1. Attacker obtains flash loan of [X tokens] from [source]
2. Swaps [amount] in [pool] to manipulate price of [token]
3. Calls `functionName()` which reads manipulated price
4. Extracts [value] from protocol at wrong price
5. Reverses manipulation and repays flash loan
6. Net profit: [amount]

**Missing Validations:**
- [ ] Price > 0 check
- [ ] Staleness check (heartbeat)
- [ ] Round completeness check
- [ ] L2 sequencer check
- [ ] Price deviation bounds

**Recommendation:**
[Specific fix — add TWAP, add Chainlink validation, implement circuit breaker]

Quick Detection Checklist

  • Does any function use getReserves(), slot0(), or balanceOf() for pricing? (Flash-loan manipulable)
  • Does Chainlink integration check for price > 0, staleness, and round completeness?
  • Is the TWAP window long enough to resist multi-block manipulation (> 30 min)?
  • Does the protocol's own token appear in its pricing oracle's pool? (Circular dependency)
  • Can any critical operation (borrow, liquidate, swap) be called in the same transaction as a flash loan?
  • Are there price deviation circuit breakers for extreme moves?
  • On L2: Is the sequencer uptime checked before using price data?

For oracle type details, see {baseDir}/references/oracle-types.md. For flash loan attack patterns, see {baseDir}/references/flash-loan-vectors.md.

Rationalizations to Reject

  • "We use Chainlink, so it's safe" → Only if ALL validation checks are implemented; partial integration is common
  • "Flash loans can't affect our protocol" → Any protocol using manipulable price sources is affected
  • "The TWAP window is 10 minutes" → Multi-block manipulation is feasible for well-funded attackers
  • "Our oracle is a trusted admin feed" → Admin key compromise → arbitrary price → instant drain
  • "The pool is too large to manipulate" → Flash loans provide unlimited capital for single-transaction manipulation
  • "We check if price is non-zero" → Non-zero is necessary but not sufficient; stale/manipulated non-zero prices are dangerous

同梱ファイル

スキルが読み込まれている間、モデルは必要に応じてこれらを読み取ります。読み取り可能なファイルとして提供され、実行されることはありません。

よくある質問

AIスキル「Oracle Flashloan Analysis」では何ができますか?

DeFiスマートコントラクトにおける価格オラクルの操作やフラッシュローン攻撃の手口を検出します。オラクルの信頼モデル(Chainlink、TWAP、スポット価格、カスタム)を分類し、古い価格データのリスク、循環的な価格依存関係、フラッシュローンによるアトミック性の悪用パターンを特定します。価格データに依存するDeFiプロトコル、オラクル連携、レンディングプロトコル、DEX、デリバティブ、または単一トランザクション内のフラッシュローンで状態を操作される可能性があるコントラクトの監査に使用します。

TypingMindでOracle Flashloan Analysisを使うメリットは何ですか?

一度インストールすれば、どのモデルでも使えるからです。Oracle Flashloan Analysisはプロバイダー固有のコードではなく、通常のMarkdownで記述されているため、同じスキルをGPT-5、Claude、Gemini、Grok、ローカルモデルで利用できます。チャットの途中でモデルを切り替えても、そのまま使い続けられます。TypingMindは自分のAPIキーで動作するため、シート単位のサブスクリプションではなく、プロバイダーに直接料金を支払います。スキルとチャットは自分のストレージに保持されます。

TypingMindにOracle Flashloan Analysisをインストールするにはどうすればよいですか?

TypingMindで「プラグイン」→「スキル」→「GitHubからインストール」を開き、https://github.com/quillai-network/quillshield_skills/tree/main/plugins/oracle-flashloan-analysis/skills/oracle-flashloan-analysisを貼り付けてください。TypingMindがSKILL.mdを読み込み、関連ファイルをまとめて、チャットごとに有効にできるスキルとしてインストールします。

Oracle Flashloan Analysisを使えるAIモデルはどれですか?

TypingMindに接続したどのモデルでも利用できます。AIスキルはプロバイダー固有のコードではなく、通常のMarkdownで書かれた指示です。そのため、GPT、Claude、Gemini、Grok、ローカルモデルのいずれも、リクエストの内容がこのスキルの用途に合ったときに、このスキルを読み込めます。

Oracle Flashloan Analysisで使えるAIモデルの数に制限はありますか?

数に制限はありません。スキルに対応したモデルであれば、GPT、Claude、Gemini、Grok、DeepSeek、Mistral、Llamaなど、どのモデルでもOracle Flashloan Analysisを利用できます。すべてTypingMind上で、自分のAPIキーを使って利用できます。

AIスキル「Oracle Flashloan Analysis」は無料ですか?

はい。quillai-networkがMITライセンスのもとでGitHubに公開しています。ご利用のAIプロバイダーに支払うのは、使用したトークンの料金だけです。

AIスキルとは何ですか?

AIスキルは、特定のタスクの実行方法をAIモデルに教える、再利用可能な指示のセットです。オープンなAgent Skills形式に従い、名前と説明を含むSKILL.mdファイルに加え、モデルが必要とするスクリプト、テンプレート、参照ファイルで構成されます。モデルはリクエストがスキルに合致したときだけ指示を読み込むため、インストール済みのスキルも、使うまでは費用がかかりません。

AIスキルは、プラグインやMCPサーバーとどう違いますか?

プラグインやMCPサーバーは、モデルが呼び出せる新しいツールを提供します。ツールとは、どこかで実行され、結果を返すコードです。一方、AIスキルは、タスクへの取り組み方、従うべき手順、望ましい出力の例といった知識や進め方をモデルに伝えます。スキルは通常のMarkdownで記述されているため、サーバー、APIキー、実行環境は不要で、どのモデルでも利用できます。

すべて見る

今すぐ自分専用のAIワークスペースを作成

ニュースレターに登録すると、新機能や今後のプレゼント企画のお知らせが届きます👇