mcpField
T
testing-for-business-logic-vulnerabilities

testing-for-business-logic-vulnerabilities

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

testing-for-business-logic-vulnerabilities について

許可を得たペネトレーションテスト向けの、ビジネスロジック脆弱性テストスキルです。ワークフローを整理し、ルールの回避や状態操作、競合状態、権限の問題を調べる手順と報告形式を示します。

主な機能

  1. 01重要なワークフローと制約の整理
  2. 02価格・数量・合計額の操作テスト
  3. 03複数ステップの回避テスト
  4. 04同時リクエストの競合状態評価
  5. 05ロール・権限・報酬の悪用テスト
  6. 06再現手順と所見の報告形式

活用シーン

  1. 01ECの決済とクーポンルールの確認
  2. 02登録や承認ワークフローのテスト
  3. 03送金や報酬システムの競合確認

インストール

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

$npx skills add https://github.com/mukul975/anthropic-cybersecurity-skills --skill testing-for-business-logic-vulnerabilities

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

同梱ファイル

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

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

詳細

ビジネスロジックの脆弱性のテスト

使用するタイミング

  • 自動スキャナーで技術的な脆弱性がほとんど見つからなかった場合に、許可を得たペネトレーションテストで使用します
  • 価格、カート、決済フローの改ざんについて、EC プラットフォームを評価するときに使用します
  • 複数ステップのワークフロー(登録、チェックアウト、承認プロセス)に、回避の機会がないかテストするときに使用します
  • バウチャー、クーポン、紹介、リワードシステムなど、レート制限のある機能を評価するときに使用します
  • 金融アプリケーション、投票システム、または重要なビジネスルールを持つアプリケーションのセキュリティ評価で使用します

前提条件

  • 許可:ビジネスロジックのテストを対象に含む、書面によるペネトレーションテスト契約
  • Burp Suite Professional:複数ステップのリクエストフローを傍受して変更するために使用します
  • アプリケーションの理解:アプリケーションで意図されているビジネスワークフローについて、十分な知識が必要です
  • 複数のテストアカウント:異なる権限レベルや状態のアカウント
  • ブラウザーの DevTools:クライアント側の検証ロジックを調べるために使用します
  • ドキュメント:想定される動作を説明するビジネス要件またはユーザーストーリー

ワークフロー

ステップ 1:ビジネスワークフローとルールを把握する

重要なビジネスプロセスと、その想定される制約をすべて記録します。

# Critical business flows to map:
# 1. Registration/Onboarding flow
#    - Email verification requirements
#    - Account approval process
#    - Role assignment logic

# 2. E-commerce/Purchase flow
#    - Product selection → Cart → Checkout → Payment → Confirmation
#    - Price calculation logic
#    - Discount/coupon application
#    - Quantity limits
#    - Shipping cost calculation

# 3. Authentication/Authorization flow
#    - Login → MFA → Dashboard
#    - Password reset → Token → New password
#    - Role escalation/approval

# 4. Financial transactions
#    - Balance check → Transfer → Confirmation
#    - Withdrawal limits
#    - Currency conversion

# Document expected constraints:
# - Minimum order amounts
# - Maximum quantity per item
# - Coupon usage limits (one per user)
# - Referral reward caps
# - Withdrawal daily limits
# - Account verification requirements before certain actions
ステップ 2:価格と数量の改ざんをテストする

リクエスト内の価格、数量、合計値を傍受して変更します。

# Test negative quantity
curl -s -X POST \
  -H "Authorization: Bearer $TOKEN" \
  -H "Content-Type: application/json" \
  -d '{"product_id": 1, "quantity": -1, "price": 99.99}' \
  "https://target.example.com/api/cart/add"

# Test zero price
curl -s -X POST \
  -H "Authorization: Bearer $TOKEN" \
  -H "Content-Type: application/json" \
  -d '{"product_id": 1, "quantity": 1, "price": 0}' \
  "https://target.example.com/api/cart/add"

# Test extremely large quantity
curl -s -X POST \
  -H "Authorization: Bearer $TOKEN" \
  -H "Content-Type: application/json" \
  -d '{"product_id": 1, "quantity": 999999999}' \
  "https://target.example.com/api/cart/add"

# Test decimal/float manipulation
curl -s -X POST \
  -H "Authorization: Bearer $TOKEN" \
  -H "Content-Type: application/json" \
  -d '{"product_id": 1, "quantity": 0.001, "price": 0.01}' \
  "https://target.example.com/api/cart/add"

# Test integer overflow
curl -s -X POST \
  -H "Authorization: Bearer $TOKEN" \
  -H "Content-Type: application/json" \
  -d '{"product_id": 1, "quantity": 2147483647}' \
  "https://target.example.com/api/cart/add"

# Modify total amount directly in checkout request
# Intercept in Burp and change total from 299.99 to 0.01
curl -s -X POST \
  -H "Authorization: Bearer $TOKEN" \
  -H "Content-Type: application/json" \
  -d '{"cart_id": "abc123", "total": 0.01, "payment_method": "card"}' \
  "https://target.example.com/api/checkout"
ステップ 3:ワークフローのステップ回避をテストする

複数ステップのプロセスで、必須のステップをスキップできるか試します。

# Skip email verification
# Instead of: Register → Verify email → Access dashboard
# Try: Register → Access dashboard directly
curl -s -H "Authorization: Bearer $UNVERIFIED_TOKEN" \
  "https://target.example.com/api/dashboard"

# Skip payment step
# Instead of: Cart → Shipping → Payment → Confirmation
# Try: Cart → Confirmation (skip payment)
curl -s -X POST \
  -H "Authorization: Bearer $TOKEN" \
  -H "Content-Type: application/json" \
  -d '{"cart_id": "abc123", "shipping_address": "123 Main St"}' \
  "https://target.example.com/api/orders/confirm"

# Skip MFA step
# Instead of: Login → MFA → Dashboard
# Try: Login → Dashboard (skip MFA)
# After successful password auth, directly access protected resources

# Skip approval process
# Instead of: Submit request → Manager approval → Access granted
# Try: Submit request → Access granted (skip approval)

# Repeat a step that should be one-time
# Apply same coupon code multiple times
for i in $(seq 1 5); do
  curl -s -X POST \
    -H "Authorization: Bearer $TOKEN" \
    -H "Content-Type: application/json" \
    -d '{"coupon_code": "DISCOUNT50"}' \
    "https://target.example.com/api/cart/apply-coupon"
  echo "Attempt $i"
done
ステップ 4:ビジネスロジックの競合状態をテストする

同時リクエストの処理におけるタイミングの隙を悪用します。

# Race condition on coupon application
# Send multiple identical requests simultaneously
for i in $(seq 1 10); do
  curl -s -X POST \
    -H "Authorization: Bearer $TOKEN" \
    -H "Content-Type: application/json" \
    -d '{"coupon_code": "ONETIME50"}' \
    "https://target.example.com/api/cart/apply-coupon" &
done
wait

# Race condition on balance transfer
# If user has $100, try to transfer $100 to two accounts simultaneously
curl -s -X POST \
  -H "Authorization: Bearer $TOKEN" \
  -H "Content-Type: application/json" \
  -d '{"to": "user_b", "amount": 100}' \
  "https://target.example.com/api/transfer" &

curl -s -X POST \
  -H "Authorization: Bearer $TOKEN" \
  -H "Content-Type: application/json" \
  -d '{"to": "user_c", "amount": 100}' \
  "https://target.example.com/api/transfer" &
wait

# Race condition on reward claiming
# Using Burp Turbo Intruder for precise timing:
# 1. Send request to Turbo Intruder
# 2. Use race condition script template
# 3. Send 20+ requests simultaneously
# 4. Check if reward was claimed multiple times
ステップ 5:紹介・リワードシステムの悪用をテストする

プロモーション機能やリワードの仕組みを悪用する方法を探します。

# Self-referral: refer your own email
curl -s -X POST \
  -H "Authorization: Bearer $TOKEN" \
  -H "Content-Type: application/json" \
  -d '{"referral_email": "[email protected]"}' \
  "https://target.example.com/api/referrals/invite"

# Referral code reuse across multiple accounts
# Create multiple accounts and use same referral code

# Coupon stacking: apply multiple discount codes
curl -s -X POST \
  -H "Authorization: Bearer $TOKEN" \
  -H "Content-Type: application/json" \
  -d '{"coupon_codes": ["SAVE10", "WELCOME20", "VIP50"]}' \
  "https://target.example.com/api/cart/apply-coupons"

# Abuse free trial: re-register with same details
# Test if [email protected] or [email protected] bypass duplicate detection

# Gift card / credit manipulation
# Buy gift card with gift card balance (circular)
# Apply gift card with value > purchase price (get change as credit)

# Test reward point manipulation
# Earn points on order → Cancel order → Keep points
curl -s -X POST \
  -H "Authorization: Bearer $TOKEN" \
  "https://target.example.com/api/orders/12345/cancel"
# Check if reward points from order 12345 were revoked
ステップ 6:ロールと権限のロジックをテストする

ビジネスプロセスを通じた権限昇格が可能か、認可ロジックを評価します。

# Role escalation via registration parameter
curl -s -X POST \
  -H "Content-Type: application/json" \
  -d '{"email":"[email protected]","password":"Test1234!","role":"admin"}' \
  "https://target.example.com/api/auth/register"

# Organization tenant boundary testing
# User in Org A tries to access Org B resources via business workflows
curl -s -X POST \
  -H "Authorization: Bearer $TOKEN_ORG_A" \
  -H "Content-Type: application/json" \
  -d '{"org_id": "org_b_id", "action": "view_reports"}' \
  "https://target.example.com/api/reports"

# Test for privilege retention after role downgrade
# Admin → Regular user: can they still access admin functions?
# Employee → Terminated: can they still access company resources?

# Test invitation/delegation abuse
# Invite user with higher privileges than inviter has
curl -s -X POST \
  -H "Authorization: Bearer $REGULAR_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{"email":"[email protected]","role":"admin"}' \
  "https://target.example.com/api/users/invite"

主な概念

概念説明
ビジネスロジックの欠陥意図しない操作を可能にする、アプリケーションのワークフローまたはルールの脆弱性です
価格の改ざんクライアント側のリクエストで価格、数量、合計値を変更することです
ワークフローの回避複数ステップのビジネスプロセスで必須のステップをスキップすることです
競合状態同時リクエストの処理を悪用し、ビジネス上の制約に違反させることです
権限昇格ビジネスプロセスの改ざんを通じて、より高い権限を取得することです
ネガティブテスト想定外の値(負数、ゼロ、null、極端な値)を使ってテストすることです
状態の操作ビジネスロジックで意図されていない順序で、アプリケーションの状態を変更することです

ツールとシステム

ツール用途
Burp Suite Professionalリクエストの傍受、変更、シーケンスのテスト
Burp Turbo Intruder競合状態をテストするための高速なリクエスト送信
Burp Sequencer予測可能な参照値をテストするためのトークンのランダム性分析
OWASP ZAPプロキシベースのテストに使えるオープンソースの代替ツール
Postmanコレクションランナーと環境変数を使ったワークフローテスト
カスタムスクリプトビジネスロジックの自動テストに使う Python/bash スクリプト

よくあるシナリオ

シナリオ 1:クーポンコードの併用

ある EC サイトでは、複数のクーポンコードを適用できます。「WELCOME10」、「SAVE20」、「VIP30」を併用すると、割引額が商品の価格を上回り、残高がマイナスになったり、注文が無料になったりします。

シナリオ 2:資金振替における競合状態

ある銀行アプリケーションは振替前に残高を確認しますが、口座をロックしません。残高 $1000 の口座から $1000 の振替を同時に 2 件送信すると、どちらも成功し、何もないところから資金が生み出されます。

シナリオ 3:チェックアウト価格の上書き

チェックアウトフローでは、POST 本文に合計金額が含まれています。合計額を傍受し、$499.99 から $0.01 に変更すると、改ざんした価格で注文が成立します。

シナリオ 4:パスワードリセットトークンの再利用

パスワードリセットのフローではワンタイムトークンが生成されますが、使用後に無効化されません。同じトークンを繰り返し使用してパスワードをリセットできます。

出力形式

## Business Logic Vulnerability Finding

**Vulnerability**: Price Manipulation in Checkout Flow
**Severity**: Critical (CVSS 9.1)
**Location**: POST /api/checkout - `total` parameter
**OWASP Category**: A04:2021 - Insecure Design

### Reproduction Steps
1. Add item to cart (price: $499.99)
2. Proceed to checkout
3. Intercept POST /api/checkout request in Burp
4. Modify "total" from 499.99 to 0.01
5. Forward the request; order completes at $0.01

### Business Rules Violated
| Rule | Expected | Actual |
|------|----------|--------|
| Server-side price calculation | Total computed server-side | Client-submitted total accepted |
| Coupon single use | One coupon per order | Same coupon applied 5 times |
| Negative quantity check | Quantity >= 1 | Quantity -1 accepted (credit issued) |
| Race condition on transfer | Balance checked atomically | Dual transfer exceeded balance |

### Impact
- Financial loss: orders processed at attacker-controlled prices
- Inventory loss: products shipped for $0.01
- Reward abuse: unlimited referral credits via self-referral
- Double-spending via race condition on transfers

### Recommendation
1. Perform all price calculations server-side; never trust client-submitted totals
2. Implement server-side validation for quantity (positive integers only)
3. Use database-level locks or atomic transactions for financial operations
4. Implement idempotency keys to prevent duplicate transaction processing
5. Rate-limit and log coupon applications, referral submissions, and transfers

コメント