> 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-by-manipulating-paths.md).

# 通过操纵路径欺骗缓存

### 利用路径映射进行 Web 缓存欺骗

#### 实验目标

从用户处获取 \*\*API 密钥\*\* **carlos**. / 提供的凭据： **wiener:peter**.

#### 观察

* 在 **我的账户** (my-account)，\*\*API 密钥\*\* 出现 **以明文形式** 针对我们自己的用户。

<figure><img src="/files/64b0431a941feafbecd4ff1cf9f8eef2d8345e5a" alt=""><figcaption></figcaption></figure>

* 起初，（在答案中）并没有直接表明存在 **缓存**.

<figure><img src="/files/29943cfc9f26b7ebfc74368b73d15060994ed088" alt=""><figcaption></figcaption></figure>

* 然而，通过向 URL 添加路径段，应用程序仍会显示 **my-account** 页面，这表明存在一种 **路由的映射逻辑** 可能与缓存兼容。

测试的示例：

* `/my-account/TESTTTTTT` → 应用程序始终将其视为 **my-account**

<figure><img src="/files/e35e5f044136bd8de986a1d040801e9d8058dea2" alt=""><figcaption></figcaption></figure>

* `/my-account/TESTTT.js` → 扩展名 **.js** 被接受并被解释（这有助于欺骗缓存规则）

<figure><img src="/files/376a8a824ac89d44390abb7bb0cc1e46cbbe755d" alt=""><figcaption></figcaption></figure>

从**利用服务器**，强迫受害者加载一个指向 my-account 的“静态”类型 URL：

{% code overflow="wrap" %}

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

{% endcode %}

<figure><img src="/files/3bec41b0c0ef7a9c4c64c4e4a6788d6244988a8b" alt=""><figcaption></figcaption></figure>

1. 通过访问：

* `/my-account/jordan.js`/，会得到一个显示 \*\*carlos API 密钥\*\* 的答案。

#### 结果

的 API 密钥 **carlos** 通过一个伪装的 URL（带有 `.js` 扩展名）显示出来，这使你可以利用缓存/路由行为（`/my-account/<quelque_chose>.js`).

<figure><img src="/files/569938ae9f01406101b59b378aebbb3a768fbf29" 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-by-manipulating-paths.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.
