> 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/web-cache-deception/cheating-the-cache-with-delimiters-in-the-path.md).

# 通过路径中的分隔符欺骗缓存

### 利用路径分隔符实施 Web 缓存欺骗

#### 背景

**实验：** 用于 Web 缓存欺骗的路径限制利用 / **目标：** 从用户处获取 \*\*API 密钥\*\* **carlos**. / **提供的访问：** 可能与……有关 `wiener:peter`. / **帮助：** 实验提供了一份可能的分隔符列表。

<figure><img src="/files/25d997e6f78dc33c26c095bac049529a38615123" alt=""><figcaption></figcaption></figure>

#### 初步观察

* 在 **我的账户** 页面上，我们看到一个标识，清楚地显示了我们自己的 API 密钥\*\*。
* 在后台，正常访问会触发一个请求：

```bash
GET /my-account HTTP/2
```

在这种情况下， **答案不是从缓存中提供的** （没有可见/可解释的缓存行为）。

<figure><img src="/files/6b1d3cf46771997e388797b359a1406d6cfda403" alt=""><figcaption></figcaption></figure>

#### 分隔符测试

* 通过添加一个 \*\*分号\*\* `;` 在路径中，\*\*应用程序仍然会将路由解析为\*\* `my-account`，但这一次 **伴随缓存行为**.

使用 **Intruder**，我们检查了几个分隔符，并发现 **分号有效**.

<figure><img src="/files/7084c6e7f9764d382bf92670cf7f3d0a0de59d08" alt=""><figcaption></figcaption></figure>

有效路径示例：

* `/my-account;test.js`

<figure><img src="/files/25c3ce613a01c902866eb7cbe7b1855d26b0ab60" alt=""><figcaption></figcaption></figure>

#### 利用

目的：确保受害者访问一个诱饵 URL，以使 **/my-account** 响应被 \*\*缓存\*\*，然后用另一个变体重新读取它，以获取 **carlos** 数据。

从**利用服务器**，受害者会被重定向到：

```javascript
<script>
    document.location="https://0a5e005c048218fb80a3f0ec00c2000d.web-security-academy.net/my-account/my-account;test.js";
</script>
```

<figure><img src="/files/49fbbe3f6962c0f4942270c78dbb09599c830a22" alt=""><figcaption></figcaption></figure>

#### API 密钥恢复

* 然后我们更改 URL 并访问：
* `/my-account;jordan.js`

此响应随后包含 **Carlos 的 API 密钥**.

<figure><img src="/files/931e8cb1c31a5c380c3cde4ac915356257fe0ac6" 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/web-cache-deception/cheating-the-cache-with-delimiters-in-the-path.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.
