Skip to main content

Free 30-min security demo  — We'll scan your real code and show live findings, no commitment Book Now

Offensive360
Academy HTTP Parameter Pollution
Intermediate · 15 min

HTTP Parameter Pollution

See how duplicate query parameters confuse server-side logic and enable filter bypass attacks.

1 HPP Mechanics

HTTP Parameter Pollution (HPP) occurs when an attacker sends multiple values for the same parameter. Different web frameworks parse these duplicates differently, enabling logic bypass.

Parsing differences:

Request: GET /transfer?amount=100&amount=99999

Flask (Python):   request.args.get("amount") → "100" (first)
Django:           request.GET["amount"] → "99999" (last)
PHP:              $_GET["amount"] → "99999" (last)
Express (Node):   req.query.amount → ["100","99999"] (array)

Attack scenario (WAF bypass):

GET /search?q=normal&q=<script>alert(1)</script>

A WAF may check only the first parameter value and find it clean, while the backend uses the last value containing the XSS payload.

HPP is also used in OAuth attacks by duplicating the redirect_uri parameter when servers parse differently from each other.

2 Prevention

Prevent HPP by being explicit about how you extract parameters and by rejecting requests containing duplicate parameters for sensitive operations.

Explicit extraction (Node.js/Express):

app.get("/transfer", (req, res) => {
  // Explicitly reject if amount is an array (duplicated)
  const amount = req.query.amount;
  if (Array.isArray(amount)) {
    return res.status(400).json({ error: "Duplicate parameter not allowed" });
  }
  const parsed = parseInt(amount, 10);
  if (isNaN(parsed) || parsed <= 0) {
    return res.status(400).json({ error: "Invalid amount" });
  }
  // proceed with transfer
});

Defense checklist:

  • Explicitly check for and reject duplicate parameters in sensitive endpoints
  • Use typed input parsing that rejects arrays for scalar parameters
  • Ensure WAF and application backend parse parameters consistently
  • Log and alert on requests with duplicate parameters

Knowledge Check

0/3 correct
Q1

What is the core issue that enables HTTP Parameter Pollution attacks?

Q2

In Express.js (Node), what does req.query.param return when the URL contains ?param=a&param=b?

Q3

How can HPP be used to bypass a Web Application Firewall?

Code Exercise

Detect Duplicate Parameters

The transfer endpoint does not check for duplicate "amount" parameters. Add validation to reject requests where "amount" is an array (duplicated parameter).

javascript