The Tracker That Forwarded Too Much: Server-Side Parameter Pollution
The challenge
Parcelo's tracker calls an internal API for you. Smuggle a second parameter in with %26. Bring back the test parcel's pickup code.
What you'll learn
- Recognise a front end that forwards input into an internal request
- Inject a parameter with %26 and prove it reached the internal API
- Explain why a repeated parameter loses when the server keeps the last value
- Truncate the rest of an internal URL with %23
- Encode values before building URLs and enforce access in the internal API
Skills tested
Prerequisites
- What a query string is
- What URL encoding (%XX) does
How it works
Many front ends do not hold the data themselves: they call an internal API and pass the answer back. If the front end builds that internal URL by concatenating user input, the input is no longer a value, it is part of the URL. Server-side parameter pollution abuses this: characters that the front end decodes (%26 becomes &, %23 becomes #) reach the internal request raw.
Here the tracker sends number=<parcel>&view=tracking. Adding %26view=full creates a second view, but the internal FastAPI service keeps the last value of a repeated parameter, so the tracker's own view=tracking still wins. Different servers pick differently (first, last, or a list), which is the heart of HTTP parameter pollution. Adding %23 makes the rest of the internal URL a fragment, which an HTTP client never sends, so your view is the only one.
Common mistakes
- Typing a raw
&or#. The tracker itself splits on them:&view=fullis a parameter of the tracker (ignored) and#never leaves your browser. Only the encoded%26and%23survive into the internal URL. - Stopping at
%26view=full. The response still says"view":"tracking": the last value wins, so cut the tracker's own parameter off with%23. - Guessing view names. The 422 error lists the allowed values:
tracking,supportandfull. The support view masks the code. - Taking the first code.
731905isVOID: that locker went offline and the parcel was rerouted. TheACTIVEassignment holds264418. - Double-encoding.
%2526arrives as a literal%26inside the number, so the service just finds no such parcel.
How to defend against it
- Never concatenate input into a URL. Build it with
URLSearchParamsorencodeURIComponent, so&and#stay inside the value. - Validate the input against its format (a tracking number is letters and digits) before using it.
- Do not let a request parameter choose how much an internal API reveals: the internal service should decide from the caller's identity, and the public tracker should only ever get tracking fields.
- Reject repeated parameters in internal APIs instead of silently keeping the first or last one.