> 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/ru/web/web-cache-deception/cheating-the-cache-via-cache-server-side-normalization.md).

# Обман кэша через нормализацию на стороне кэширующего сервера

### Эксплуатация нормализации кэширующего сервера для обмана веб-кэша

#### Цель лабораторной работы

Извлечь \*\*API-ключ\*\* пользователя **carlos** используя **поведение нормализации URL** (разница в интерпретации между приложением и кэширующим сервером). / Доступно соединение: **wiener:peter**.

#### Начальное наблюдение

Мы тестируем статические суффиксы, чтобы вызвать кэш:

* Тестовый запрос:

```bash
GET /my-account~test.js
```

Существуют разные ответы в зависимости от определённых символов, и сервер принимает:

* `#`
* `?`
* `%23` (URL-кодирование для `#`)
* `%3f` (URL-кодирование для `?`)

<figure><img src="/files/22cb819a443338c13f41b6fa5d0521ec5a1b7dfc" alt=""><figcaption></figcaption></figure>

#### Интересный конечный пункт тоже кэшируется

Похоже, каталог ресурсов тоже скрыт:

```http
GET /resources/ HTTP/2
```

Это полезно, потому что мы попробуем направить кэш на `/resources` при этом сохранив маршрут, интерпретируемый приложением как `/my-account`.

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

#### Техника: Фрагмент + переход (с нормализацией)

URL строится так, что приложение продолжает обрабатывать **/my-account**, но при этом кэш нормализует/интерпретирует последовательность так, что получается **/resources**.

Тесты :

```bash
GET /my-account#/../resources
# Закодированная версия (та, которая здесь «проходит» лучше всего)
GET /my-account%23%2f%2e%2e%2fresources
```

Ключевой момент: **Сервер кэша принимает URL-кодированную версию**, которая вызывает ожидаемое поведение.

<figure><img src="/files/5dc72e0f9c220606ed3c9ba04fc5e6e363e2764d" alt=""><figcaption></figcaption></figure>

#### Эксплуатация: принудить жертву закэшировать страницу

Поскольку это сервер эксплойта, жертва перенаправляется на ловушечный URL:

{% code overflow="wrap" %}

```javascript
<script>
    document.location = "https://0abe00b00342ae8780a1bcdf00f10008.web-security-academy.net/my-account%23%2f%2e%2e%2fresources";
</script>
```

{% endcode %}

#### Результат

Как только жертва проходит по этому URL, ресурс, обслуживаемый из кэша, извлекается и получается \*\*API-ключ carlos\*\*, что подтверждает прохождение лабораторной работы.

<figure><img src="/files/6d5177f923a0db5e0c5ad8fd2b92ccd8f20334ba" 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/ru/web/web-cache-deception/cheating-the-cache-via-cache-server-side-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.
