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

# Condición de carrera en un solo endpoint

### Condiciones de carrera en un único endpoint

### Contexto del laboratorio

La función de cambio de dirección de correo electrónico contiene una **condición de carrera** que te permite asociar una dirección arbitraria con nuestra cuenta.

Un usuario con la dirección **<carlos@ginandjuice.shop>** tiene una **invitación pendiente** para convertirse en administrador, pero **aún no ha creado una cuenta**. / Así que si alguien logra **revender esta dirección**, obtiene automáticamente los **permisos de administrador**.

### Objetivo

1. Encuentra una condición de carrera para reclamar una dirección de correo electrónico arbitraria.
2. Cambiar el correo electrónico de la cuenta a **<carlos@ginandjuice.shop>**.
3. Accede al **Panel de administración**.
4. Eliminar usuario **carlos**.

Credenciales proporcionadas: **wiener:peter**/ Acceso a un cliente de correo para direcciones **@exploit-...exploit-server.net**.

### Flujo normal de cambio de correo electrónico

El primer intento es cambiar el correo electrónico a una dirección controlada:

* Nueva dirección:/ `wiener@exploit-0a10009b04efd21981a1bafc0102005d.exploit-server.net`

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

Respuesta de la aplicación:

> “Por favor, haz clic en el enlace de tu correo electrónico para confirmar el cambio de correo electrónico a …”

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

Llega un correo electrónico con un enlace de confirmación, por ejemplo:/ `/confirm-email?user=wiener&token=ob0dI7AMlwX2Y2uw`

Una vez que se hace clic en el enlace:

> “Tu correo electrónico se ha actualizado correctamente”

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

En segundo plano, la solicitud se ve así:

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

### Prueba base sin condición de carrera

Enviamos varias solicitudes de cambio de correo electrónico, con distintos correos (test1, test2,... test20), cada una por separado, y las confirmaciones recibidas corresponden correctamente a las direcciones solicitadas.

<figure><img src="/files/f2159f6871a311fa4ef3c02ababf8e767bc6942a" 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/9cac1a7a73d3a7711f7fb0cd0f1ac9c6d4b77f04" alt=""><figcaption></figcaption></figure>

Pero cuando ejecutas estas mismas solicitudes **en paralelo**, aparece un comportamiento inesperado: a veces recibes confirmaciones que no corresponden al destinatario correcto.

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

<figure><img src="/files/2d11e07b1251bbd225814ff8748257ea90621688" alt=""><figcaption></figcaption></figure>

### Análisis de la condición de carrera

El comportamiento observado sugiere un procesamiento en dos fases\*\*:

1. Una fase que **prepara/escribe** correo electrónico de confirmación
2. Una fase que **determina qué dirección** se envía el correo electrónico

Al enviar en paralelo un lote de solicitudes, conseguimos cruzar estas dos fases: el contenido de un correo electrónico puede asociarse con otra dirección de destino.

Principio: envía en paralelo una mezcla de solicitudes que contengan:

Parte con:

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

Otra parte con una dirección controlada:

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

Resultado: recibimos un correo electrónico que dice:

> “Para confirmar el cambio de tu correo electrónico a **<carlos@ginandjuice.shop>**, haz clic en el enlace de abajo”

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

Así obtenemos el **enlace de confirmación** para la dirección de Carlos y podemos finalizar el cambio de correo electrónico a **<carlos@ginandjuice.shop>**.

<figure><img src="/files/afab80623b699447529f50736c9ba0fcca803f62" 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/es/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.
