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

# Condition de concurrence à point de terminaison unique

### Conditions de concurrence sur un seul point de terminaison

### Contexte du laboratoire

La fonctionnalité de changement d'adresse e-mail contient une **condition de concurrence** qui vous permet d'associer une adresse arbitraire à notre compte.

Un utilisateur avec l'adresse **<carlos@ginandjuice.shop>** a une **invitation en attente** pour devenir administrateur, mais **n'a pas encore créé de compte**. / Donc si quelqu'un parvient à **revendre cette adresse**, elle récupère automatiquement les **droits d'administrateur**.

### Objectif

1. Trouvez une condition de concurrence pour réclamer une adresse e-mail arbitraire.
2. Changez l'adresse e-mail du compte en **<carlos@ginandjuice.shop>**.
3. Accédez au **panneau d'administration**.
4. Supprimer l'utilisateur **carlos**.

Identifiants fournis : **wiener:peter**/ Accès à un client de messagerie pour les adresses **@exploit-...exploit-server.net**.

### Flux normal de changement d'e-mail

La première tentative consiste à changer l'e-mail vers une adresse contrôlée :

* Nouvelle adresse :/ `wiener@exploit-0a10009b04efd21981a1bafc0102005d.exploit-server.net`

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

Réponse de l'application :

> « Veuillez cliquer sur le lien dans votre e-mail pour confirmer le changement d'e-mail vers … »

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

Un e-mail contient un lien de confirmation, par exemple :/ `/confirm-email?user=wiener&token=ob0dI7AMlwX2Y2uw`

Une fois le lien cliqué :

> « Votre adresse e-mail a été mise à jour avec succès »

<figure><img src="/files/5554d67a8d35f0be80c7e016a6eafb864b9261bd" alt=""><figcaption></figcaption></figure>

En arrière-plan, la requête ressemble à :

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

### Test de base sans course

Nous envoyons plusieurs requêtes de changement d'e-mail, avec différents e-mails (test1, test2,... test20), chacune séparément, et les confirmations reçues correspondent bien aux adresses demandées.

<figure><img src="/files/ceb9b22348281b63c2bc410c754991bc3445ea21" 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/bf0b034a95cbb5d95c37c44afdd0c5143408fe8f" alt=""><figcaption></figcaption></figure>

Mais lorsque vous exécutez ces mêmes requêtes **en parallèle**, un comportement inattendu apparaît : vous recevez parfois des confirmations qui ne correspondent pas au bon destinataire.

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

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

### Analyse de la condition de concurrence

Le comportement observé suggère un traitement en deux phases\*\* :

1. Une phase qui **prépare/écrit** l'e-mail de confirmation
2. Une phase qui **détermine quelle adresse** l'e-mail est envoyé

En envoyant un lot de requêtes en parallèle, nous parvenons à faire se chevaucher ces deux phases : le contenu d'un e-mail peut être associé à une autre adresse de destination.

Principe : envoyer en parallèle un mélange de requêtes contenant :

Partie avec :

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

Une autre partie avec une adresse contrôlée :

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

Résultat : nous recevons un e-mail indiquant :

> « Pour confirmer votre changement d'e-mail vers **<carlos@ginandjuice.shop>**, cliquez sur le lien ci-dessous »

<figure><img src="/files/368a00e7c8665a3821596a65688fc4241c511129" alt=""><figcaption></figcaption></figure>

Nous obtenons donc le **lien de confirmation** pour l'adresse de Carlos et nous pouvons finaliser le changement d'e-mail vers **<carlos@ginandjuice.shop>**.

<figure><img src="/files/11a414b3e6e4be5c7186a3dab1953f070d19b898" 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/fr/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.
