> 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/ja/web/web-cache-deception/cheating-the-cache-by-manipulating-paths.md).

# パスを操作してキャッシュを欺く

PortSwigger Web Security Academy のラボ向けメモ。悪用の手順、ペイロードのテスト、Burp Suite による検証、修復の文脈を含む。

### Webキャッシュ欺瞞のためのパスマッピングの悪用

#### ラボの目的

ユーザーから\*\* APIキー\*\*を回収する **carlos**. / 提供された認証情報: **wiener:peter**.

#### 観察事項

* 〜では **マイアカウント** (my-account) では、\*\* APIキー\*\* が表示される **平文で** 自分自身のユーザー用に。

<figure><img src="https://2001299964-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://2001299964-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://2001299964-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://2001299964-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 を指す「static」タイプのURLを読み込ませる:

{% code overflow="wrap" %}

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

{% endcode %}

<figure><img src="https://2001299964-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 key は **carlos** は、偽装されたURL（〜付き）を通じて表示される `.js` 拡張子）があり、キャッシュ/ルーティングの動作を利用できる（`/my-account/<quelque_chose>.js`).

<figure><img src="https://2001299964-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/ja/web/web-cache-deception/cheating-the-cache-by-manipulating-paths.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.
