> 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/host-header/authentication-bypass-via-host-header.md).

# Contournement de l’authentification via l’en-tête Host

### Contournement de l’authentification par l’en-tête Host

**Description du laboratoire**

Ce laboratoire repose sur une mauvaise hypothèse côté serveur : le niveau de privilège de l’utilisateur est déterminé en fonction de la valeur de l’en-tête HTTP **Host**. / En manipulant cet en-tête, il est possible d’accéder à des fonctionnalités réservées à l’administrateur.

\*\* Objectif :\*\*/ Aller au panneau d’administration et supprimer l’utilisateur **carlos**.

\*\* Comportement initial observé\*\*

Lorsqu’on essaie d’accéder à la page d’administration avec une requête standard, l’accès est refusé.

Requête classique :

```http
GET /admin HTTP/2
Host: 0aa100b30336117186f29ede001a0029.web-security-academy.net
```

Réponse : accès non autorisé

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

**Analyse de la vulnérabilité**

L’application semble accorder des privilèges élevés lorsque la requête provient d’un hôte considéré comme « interne » ou digne de confiance, par ex. **localhost**. / Aucune vérification supplémentaire n’est effectuée pour confirmer l’origine réelle de la requête.

```http
Host: 0aa100b30336117186f29ede001a0029.web-security-academy.net
```

<figure><img src="/files/837438eb4d32cb3afd43191eef6140ba0d499cf2" alt=""><figcaption></figcaption></figure>

**Exploitation**

Il suffit de modifier manuellement le **Host** la valeur de l’en-tête dans la requête HTTP.

Requête modifiée :

```http
Host: localhost
```

Résultat : accès autorisé au panneau d’administration

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

**Action finale**

Une fois l’accès administrateur obtenu, il est possible de supprimer l’utilisateur cible :

```bash
/admin/delete?username=carlos
```

<figure><img src="/files/fb7c8c7491a3bba9c49db67a0ecff76c102ff12d" 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/host-header/authentication-bypass-via-host-header.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.
