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

# Bypass de autenticação via Host Header

### Bypass de autenticação por cabeçalho Host

**Descrição do laboratório**

Este laboratório é baseado em uma hipótese ruim do lado do servidor: o nível de privilégio do usuário é determinado com base no valor do cabeçalho HTTP **Host**. / Ao manipular esse cabeçalho, é possível acessar recursos reservados ao administrador.

\*\* Objetivo:\*\*/ Acesse o painel de administração e exclua o usuário **carlos**.

\*\* Comportamento inicial observado\*\*

Quando se tenta acessar a página de administração com uma requisição padrão, o acesso é negado.

Requisição clássica:

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

Resposta: acesso não autorizado

<figure><img src="/files/126d58182bd96da9d485481f1a52d61ea61a7827" alt=""><figcaption></figcaption></figure>

**Análise da vulnerabilidade**

A aplicação parece conceder privilégios elevados quando a requisição vem de um host considerado "interno" ou confiável, por exemplo. **localhost**. / Nenhuma verificação adicional é realizada para confirmar a origem real da requisição.

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

<figure><img src="/files/828f6c2b323bf6b0fd36a086c5f8bb95606553fd" alt=""><figcaption></figcaption></figure>

**Exploração**

Basta alterar manualmente o **Host** valor do cabeçalho na consulta HTTP.

Requisição modificada:

```http
Host: localhost
```

Resultado: acesso autorizado ao painel de administração

<figure><img src="/files/57dc5a9a02c554f83cb7cca50cc4ab489fc00b8a" alt=""><figcaption></figcaption></figure>

**Ação final**

Depois que o acesso de administrador é obtido, é possível excluir o usuário-alvo:

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

<figure><img src="/files/1a8aec79881051653ee4991a2aae9488f88266da" 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/pt-br/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.
