> 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/xss-with-csp-bypass.md).

# XSS مع CSP وتقنية تجاوز

### ثغرة XSS منعكسة محمية بواسطة CSP، مع تجاوز CSP

#### وصف المختبر

تخطيط المواقع المنعكس المحمي بسياسة أمان المحتوى (CSP). الهدف هو تنفيذ `alert()` عن طريق تجاوز CSP. الحل المقصود يعمل فقط على Chrome.

#### الهدف

ابحث عن متجه XSS مدروس يتجاوز CSP ويستدعي `alert()` الدالة.

الملاحظات

* من خلال حقن `<script>` وسم في المعامل، يظهر الوسم في HTML لكن JavaScript لا يعمل:/ مثال على الحقن: `'</h1><script>alert(0)</script>` — يكون الوسم مرئياً لكنه محظور بواسطة CSP.

```javascript
' </h1><script>alert(0)</script>
```

<figure><img src="/files/0466bfd6fb5fc7b962b7a14454466af62a127433" alt=""><figcaption></figcaption></figure>

تسمح CSP فقط بالبرامج النصية من نفس النطاق (`'self'`).

<figure><img src="/files/19f3414d2d7760d59814065d6641ab3a6d3d8e3b" alt=""><figcaption></figcaption></figure>

* يشير تقرير CSP إلى أنه من المتوقع وجود رمز مميز ( `رمز` يبدو أن المعامل مرتبط بسلوك CSP).

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

* من خلال إضافة `&token=test` إلى عنوان URL، يتم تفسير هذا المعامل بواسطة التطبيق.

```
&token=test
```

<figure><img src="/files/58e890f1a79d7be3510c62f4c44296fb896cf470" alt=""><figcaption></figcaption></figure>

يمكن حقن توجيه CSP مباشرة عبر `رمز` المعامل، على سبيل المثال:

```
&token=;script-src-elem 'unsafe-inline'
```

يتم أخذ التوجيه في الاعتبار

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

بعد فرض إضافة `script-src-elem 'unsafe-inline'`، يسمح الحقن التالي بتنفيذ JavaScript:

```javascript
<script>alert(0)</script>&token=;script-src-elem 'unsafe-inline'
```

<figure><img src="/files/815839dc7cb95295e006cc65d15b0ce939af9824" 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/xss-with-csp-bypass.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.
