> 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/web-cache-deception-by-path-manipulation.md).

# 通过路径操纵实现 Web 缓存欺骗

### 利用路径映射实施 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 密钥\*\* 的响应。

#### 结果

用于 **carlos** 的 API 密钥通过一个伪装的 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/web-cache-deception-by-path-manipulation.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.
