> 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/race-conditions/single-endpoint-race-condition.md).

# Race Condition an einem einzelnen Endpunkt

### Race Conditions mit einem Endpunkt

### Laborkontext

Die Funktion zum Ändern der E-Mail-Adresse enthält eine **Race Condition** die es ermöglicht, eine beliebige Adresse mit unserem Konto zu verknüpfen.

Ein Benutzer mit der Adresse **<carlos@ginandjuice.shop>** hat eine **ausstehende Einladung** um Administrator zu werden, aber **hat noch kein Konto erstellt**. / Wenn also jemand dazu kommt **diese Adresse weiterzuverkaufen**, erhält er automatisch die **Administratorrechte**.

### Ziel

1. Finde eine Race Condition, um eine beliebige E-Mail-Adresse zu übernehmen.
2. Ändere die Konto-E-Mail zu **<carlos@ginandjuice.shop>**.
3. Greife auf das **Admin-Panel**.
4. Benutzer löschen **carlos**.

Bereitgestellte Zugangsdaten: **wiener:peter**/ Zugriff auf einen E-Mail-Client für Adressen **@exploit-...exploit-server.net**.

### Normaler Ablauf zum Ändern der E-Mail

Der erste Versuch besteht darin, die E-Mail-Adresse in eine kontrollierte Adresse zu ändern:

* Neue Adresse:/ `wiener@exploit-0a10009b04efd21981a1bafc0102005d.exploit-server.net`

<figure><img src="/files/46b12c7757a2efc49872db7d3e3c7c5f6c7aad7e" alt=""><figcaption></figcaption></figure>

Antwort der Anwendung:

> „Bitte klicken Sie auf den Link in Ihrer E-Mail, um die Änderung der E-Mail zu … zu bestätigen“

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

Eine E-Mail kommt mit einem Bestätigungslink, zum Beispiel:/ `/confirm-email?user=wiener&token=ob0dI7AMlwX2Y2uw`

Sobald der Link angeklickt wurde:

> „Ihre E-Mail wurde erfolgreich aktualisiert“

<figure><img src="/files/577c8889ca0bf46fe6043aa009d60d967a0dfe90" alt=""><figcaption></figcaption></figure>

Im Hintergrund sieht die Anfrage so aus:

```bash
email=wiener%40exploit-0a10009b04efd21981a1bafc0102005d.exploit-server.net&csrf=UoUvroZsYvL6IJPN7GKumJSoEuLFdBYk
```

### Grundtest ohne Race Condition

Wir senden mehrere Anfragen zum Ändern der E-Mail mit unterschiedlichen E-Mails (test1, test2,... test20), jeweils getrennt, und die erhaltenen Bestätigungen stimmen gut mit den angeforderten Adressen überein.

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

```bash

email=test1@exploit-0a10009b04efd21981a1bafc0102005d.exploit-server.net&csrf=UoUvroZsYvL6IJPN7GKumJSoEuLFdBYk

email=test2@exploit-0a10009b04efd21981a1bafc0102005d.exploit-server.net&csrf=UoUvroZsYvL6IJPN7GKumJSoEuLFdBYk

email=test3@exploit-0a10009b04efd21981a1bafc0102005d.exploit-server.net&csrf=UoUvroZsYvL6IJPN7GKumJSoEuLFdBYk

email=test4@exploit-0a10009b04efd21981a1bafc0102005d.exploit-server.net&csrf=UoUvroZsYvL6IJPN7GKumJSoEuLFdBYk

email=test5@exploit-0a10009b04efd21981a1bafc0102005d.exploit-server.net&csrf=UoUvroZsYvL6IJPN7GKumJSoEuLFdBYk

email=test6@exploit-0a10009b04efd21981a1bafc0102005d.exploit-server.net&csrf=UoUvroZsYvL6IJPN7GKumJSoEuLFdBYk

email=test7@exploit-0a10009b04efd21981a1bafc0102005d.exploit-server.net&csrf=UoUvroZsYvL6IJPN7GKumJSoEuLFdBYk

email=test8@exploit-0a10009b04efd21981a1bafc0102005d.exploit-server.net&csrf=UoUvroZsYvL6IJPN7GKumJSoEuLFdBYk
.....

email=test20@exploit-0a10009b04efd21981a1bafc0102005d.exploit-server.net&csrf=UoUvroZsYvL6IJPN7GKumJSoEuLFdBYk
```

<figure><img src="/files/7b06c2adcd177e9e4f1e790e595b6eadd3937e0b" alt=""><figcaption></figcaption></figure>

Aber wenn du dieselben Anfragen ausführst **parallel**, tritt ein unerwartetes Verhalten auf: Du erhältst manchmal Bestätigungen, die nicht zum richtigen Empfänger passen.

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

<figure><img src="/files/66d23c587737b9c3b7287bc5f5773ab9c6068507" alt=""><figcaption></figcaption></figure>

### Analyse der Race Condition

Das beobachtete Verhalten deutet auf eine Verarbeitung in zwei Phasen hin\*\*:

1. Eine Phase, die **vorbereitet/schreibt** Bestätigungs-E-Mail
2. Eine Phase, die **bestimmt, welche Adresse** die E-Mail gesendet wird

Durch das parallele Senden einer Reihe von Anfragen gelingt es uns, diese beiden Phasen zu überlappen: Der Inhalt einer E-Mail kann einer anderen Zieladresse zugeordnet werden.

Prinzip: Sende parallel eine Mischung aus Anfragen, die Folgendes enthalten:

Teil mit:

```bash
email=carlos@ginandjuice.shop&csrf=UoUvroZsYvL6IJPN7GKumJSoEuLFdBYk
```

Ein anderer Teil mit einer kontrollierten Adresse:

```bash
email=test@exploit-0a10009b04efd21981a1bafc0102005d.exploit-server.net&csrf=UoUvroZsYvL6IJPN7GKumJSoEuLFdBYk
```

Ergebnis: Wir erhalten eine E-Mail mit dem Inhalt:

> „Um Ihre E-Mail-Änderung zu **<carlos@ginandjuice.shop>**, klicken Sie auf den untenstehenden Link“

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

So erhalten wir den **Bestätigungslink** für Carlos’ Adresse und können die Änderung der E-Mail zu **<carlos@ginandjuice.shop>**.

<figure><img src="/files/7ae67ee66e294091c27b81967919927f3e146a26" 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/race-conditions/single-endpoint-race-condition.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.
