> For the complete documentation index, see [llms.txt](https://docs.cooku222.kr/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.cooku222.kr/security/web-hacking/portswigger/web-cache-deception-2.md).

# Web Cache Deception (2)

**URL 경로 매핑**

* **URL 경로 매핑**은 **URL 경로를 파일, 스크립트, 또는 명령 실행과 같은 서버 상의 리소스와 연결하는 과정**이다. 프레임워크와 기술에 따라 다양한 매핑 스타일이 적용된다.&#x20;

전통적인 URL 매핑은 파일 시스템에 위치한 리소스로의 직접적인 경로를 나타낸다. 전형적인 예시는 다음과 같다.

<http://example.com/path/in/filesystem/resource.html>

* `http://example.com` 은 서버를 가리킨다.
* `/path/in/filesystem/`은 서버 파일 시스템 내의 디렉터리 경로를 나타낸다.
* `resource.html`은 접근하려는 특정 파일이다.

반면 **REST 스타일의 URL은 물리적인 파일 구조가 꼭 일치하진 않**는다. 대신 **파일 경로를 API의 논리적인 부분으로 추상화**한다.&#x20;

<http://example.com/path/resource/param1/param2>

* `http://example.com`은 서버를 가리킨다.
* `/path/resource/`는 리소스를 나타내는 엔드포인트이다.
* param1과 param2는 서버가 요청을 처리하는 데 사용하는 경로 매개변수이다.&#x20;

캐시와 원본 서버가 URL 경로를 리소스에 매핑하는 방식은 웹 캐시 디셉션 취약점을 유발할 수 있다.

<http://example.com/user/123/profile/wcd.css>

* RESTful API의 URL 매핑을 사용하는 원본 서버는 이를 /user/123/profile 엔드포인트에 대한 요청으로 해석된다. 따라서 사용자 123의 프로필 정보를 반환해 wcd.css는 유의미하지 않은 매개변수로 취급해 무시한다.
* 전통적인 URL 매핑을 사용하는 캐시는 이를 /user/123 하위의 /profile 디렉터리에 위치한 wcd.css라는 파일에 대한 요청으로 간주할 수 있다. 즉, URL 경로를 /user/123/profile/wcd.css로 해석한다.&#x20;

만약 캐시가 경로 .css로 끝나는 요청에 대한 응답을 저장하도록 설정되어 있다면 캐시는 프로필 정보를 마치 CSS 파일인 것처럼 저장하고 사용자에게 제공하게 될 것이다.&#x20;

* 이쯤에서 RESTful API에선 Path Traversal이 안 생기나 의문이 생겨 찾아봤다. RESTful API 사용 여부와 Path Traversal 취약점 존재 여부는 무관하며 사용자 입력이 파일 경로에 직접 사용되는 순간 언제든 발생할 수 있다.&#x20;

경로 매핑 불일치 악용하기

* 원본 서버가 URL 경로를 리소스에 매핑하는 방식을 확인하고 싶으면 대상 엔드포인트의 URL에 임의의 경로 세그먼트를 추가한다. 응답이 여전히 기본 응답과 동일한 민감 데이터를 포함하고 있다면 원본 서버가 URL 경로를 추상화해 해석하며 추가된 세그먼트를 무시한다. 예를 들어 /api/orders/123을 /api/orders/123/foo로 수정해도 여전히 주문 정보를 반환한다.
* 캐시가 URL 경로를 리소스에 어떻게 매핑하는지 테스트하려면 정적 확장자를 추가해 경로를 수정하고 캐시 규칙과 일치를 시도한다. /api/orders/123/foo를 /api/orders/123/foo.js로 변경해본다. 만약 응답이 캐시되면&#x20;
  * 캐시가 정적 확장자가 포함된 전체 URL 경로를 해석하고 있다.
  * .js로 끝나는 요청에 대한 응답을 저장하는 캐시 규칙이 존재한다.

캐시는 특정 정적 확장자에 기반한 규칙을 가진다. .css, .ico, .exe를 포함한 다양한 확장자를 시도한다.

이렇게 하면 캐시에 저장되는 동적 응답을 반환하는 URL을 제작할 수 있다. 단, 원본 서버는 종종 엔드포인트마다 서로 다른 추상화 규칙을 적용하므로, 이 공격은 테스트한 특정 엔드포인트에 국한된다.

***

{% embed url="<https://portswigger.net/web-security/learning-paths/web-cache-deception/wcd-web-caches/web-cache-deception/web-caches>" %}


---

# 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:

```
GET https://docs.cooku222.kr/security/web-hacking/portswigger/web-cache-deception-2.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
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.
