> 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 缓存欺骗

面向 PortSwigger Web Security Academy 实验室的通过路径操纵进行 Web 缓存欺骗笔记，包括利用流程、载荷测试、Burp Suite 验证和修复背景。

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

#### 实验目标

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

#### 观察

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

<figure><img src="https://1574813340-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fl4EVJpcOrsgjSGsLI7p2%2Fuploads%2Fgit-blob-108b38e85bcc7723d3655ed256ab94e6d6ab23ed%2F%7B6D0C2C89-1F6B-48CA-B915-C9EDF0F5E9DE%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-29183f864d0e6633e8eec334dd43f232517f9326%2F%7BA44A17EA-B46B-4E3B-89DF-96104A9B1F59%7D.png?alt=media" alt=""><figcaption></figcaption></figure>

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

测试示例：

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

<figure><img src="https://1574813340-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fl4EVJpcOrsgjSGsLI7p2%2Fuploads%2Fgit-blob-2b3e00bdbf8e94e2755b444e3c6e8968ff9597eb%2F%7B3B320FBE-E2BE-43DB-8AEC-6223464C1F8E%7D.png?alt=media" alt=""><figcaption></figcaption></figure>

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

<figure><img src="https://1574813340-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fl4EVJpcOrsgjSGsLI7p2%2Fuploads%2Fgit-blob-3b7e90f784764ff27fd8de94be4cbafb6aca535d%2Fimage%20(3133).png?alt=media" 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="https://1574813340-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fl4EVJpcOrsgjSGsLI7p2%2Fuploads%2Fgit-blob-5ee7d2cf564ad6368a92b92c410e95cc212a7ce5%2F%7B6ABD89DC-A971-48F3-8542-76823C922CFC%7D.png?alt=media" alt=""><figcaption></figcaption></figure>

1. 通过访问：

* `/my-account/jordan.js`/ 可以得到一个显示 \*\*carlos API 密钥\*\* 的响应。

#### 结果

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

<figure><img src="https://1574813340-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fl4EVJpcOrsgjSGsLI7p2%2Fuploads%2Fgit-blob-7aed730f89d4e5583776766836cb14dca0d58b14%2F%7BA88CD920-5D43-48A2-834E-F59F2D901B5F%7D.png?alt=media" 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 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/web-cache-deception/web-cache-deception-by-path-manipulation.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.
