リソース · 37

GraphQL APIのセキュリティ確保:認可、クエリコスト、および証拠

オブジェクトとフィールドの権限を強制し、サーバー側の処理をバインドし、拒否パスをテストする。

更新済み · 15 min

ガラスの立方体と接続ノード、抽象グラフ、えんじ色のケース、暗い机上のネットワーク機器を備えた架空の無人サイバー設計室 AIで生成した編集用イラスト

このガイドが達成するのに役立つこと

  • 公開スキーマのマッピング
  • 権限の行使
  • バインドクエリのコスト
  • 拒否の検証

クイックチェック

  • あるアカウントが別のアカウントのオブジェクトを読み取ることができるか?
  • 機密フィールドは親のアクセス決定に従うか?
  • 深度、エイリアス、ページネーションのコストは合計でどのくらいか?
  • エラーによって漏洩する詳細情報は何か?
  • 拒否と不正使用を監視するのは誰か?

手順

  1. 1

    操作のインベントリ

    型、フィールド、ミューテーション、ロール、オブジェクト所有者、機密データを一覧表示する。 現在のクライアントクエリと使用頻度の低いパスを含める。

    成果物:操作、ロール、オブジェクト、フィールドのマトリックス

  2. 2

    各アクセス決定をテストする

    個別のテストアカウントを作成し、ネストされたオブジェクトを含むオブジェクトIDを交換する。 リゾルバはデータを返す前に認証を適用する必要がある。

    成果物:再現可能な許可および拒否ケース。

  3. 3

    バインドされたサーバー作業

    フィールドとコレクションの実際のコストを測定する。 深さ、幅、エイリアス、ページネーション、バッチ処理、および時間を同時にテストし、適切な制限を設定する。

    成果物:コストポリシーと敵対的クエリセット。

  4. 4

    不要な露出の削減

    コンテキストに対するイントロスペクションを決定し、内部エラーの詳細を非表示にし、クライアントが必要とする以上の情報を明らかにするフィールドを削除する。

    成果物:レビュー済みの公開構成とエラー応答。

  5. 5

    抑制された監視

    機密情報と機密性の高い引数を除外し、有用な技術的ID、操作、コスト、拒否、および相関関係をログに記録する。 アラートの所有者を割り当てる。

    成果物:ダッシュボードと調査手順。

  6. 6

    変更後のリプレイ

    フィールド、ロール、またはクライアントが変更された場合、承認を再実行し、ケースをロードする。 改訂後のグラフをたどる古いクエリを確認してください。

    成果物:回帰テスト結果とリリース決定

管理指標

指標測定対象最初のアクション
アクセスオブジェクトとフィールドのケースが想定どおりに拒否されるリゾルバを修正
コスト重いクエリはポリシーによって制限されるフィールドと制限を調整
エラー内部詳細を含まない公開レスポンス公開される詳細情報を削減
回帰分析変更後にクライアント操作がリプレイされる意図しない破損を防ぐ

よくある間違い

  • エンドポイントアクセスのみを信頼する
  • 深さを制限するが幅を無視する
  • ネストされたフィールドの認証を忘れる
  • 機密データを含む引数をログに記録する

よくある質問

GraphQLは通常のAPI認証を不要にする?

いいえ。すべてのオブジェクトとフィールドへのアクセスには、IDとコンテキストに基づく判断が必要です。

イントロスペクションを無効にするだけで十分か?

いいえ。スキーマの露出を減らすことはできますが、アクセスやクエリのコストは解決しません。

深さ制限だけで十分か?

いいえ。エイリアス、幅、リスト、フィールド固有のコストも重要です。

GraphQL:エラー・リスト・部分データ

この言語版の詳しい参照メモは英語で提供しています。

How should a client read a GraphQL response when part of the data fails? Start with the processing phase, then follow Non-Null constraints to the first position that permits null. A screen that displays success simply because transport returned can hide an incomplete record. This dossier connects schema, JSON result and interface decisions through a fictional evidence-viewing scenario.

Reference: the published September 2025 edition, reviewed on 23 October 2026. The eight rules below are a CIE editorial selection, not a conformance certification. All scenarios and sample data are fictional.

GraphQL Specification · September 2025 · Published edition · September 2025

Eight points for interpreting the result

Eight points for interpreting the result
PointClient consequenceSource
Request error resultAn error preventing execution yields errors and no data entry. Invalid variables follow this route even when the document parses.GraphQL 2025
Execution resultAfter execution, data is present. Its value may be a partial object or null. With no raised error, errors must be absent rather than an empty list.GraphQL 2025
errors[].messageEach error includes a developer-facing message. Give visitors useful wording without exposing internal details or sensitive identifiers.GraphQL 2025
errors[].locationsWhen a document position can be associated with an error, locations should give line and column starting at 1. These are not data paths.GraphQL 2025
errors[].pathThe path uses response names, including aliases, and zero-based integer indices. It keeps the failing position even when a parent is subsequently replaced with null.GraphQL 2025
List / Non-NullSeparate list nullability from item nullability. A failing non-null item nulls the list; a non-null list propagates the error further to its parent.GraphQL 2025
extensionsResponse and error extensions are metadata maps defined by implementations. A code in extensions is not a universal GraphQL error-code catalogue.GraphQL 2025
GraphQL / HTTPThe GraphQL specification does not define transport. GraphQL over HTTP is identified here as a working draft; test its media-type negotiation separately.HTTP draft

Identify the phase before choosing the message

Identify the phase before choosing the message
SituationExpected shapeJourney action
Request rejected before executionNon-empty errors; data absentFix the operation or its variables. Keep an actionable error instead of automatically replaying an unchanged request.
Execution with no raised errordata present; errors absentDisplay returned data. A schema-permitted null may be normal and alone does not diagnose failure.
Execution with partial resultObject data; non-empty errorsSeparate retained fields from failing positions. Prevent confirmation that depends on unavailable evidence.
Propagation reaches the rootdata: null; non-empty errorsPresent an unavailable state for this operation. Do not silently recycle a response belonging to another case.

GraphQLのnull許容シミュレーター

The model fixes a query using affaire as the alias of dossier. The case contains reference: String! and preuves, a three-item String list. statut: String! is a root sibling. Items are A-01, A-02 and A-03 before the injected failure. Choose the preuves type, dossier nullability and failing item.

query Demo {
  affaire: dossier { reference preuves }
  statut
}

Local simulation of one item-resolution error on this fixed schema. No API call, query parser, permission test, cost calculation or HTTP verdict. Nested types, subscriptions and incremental delivery are outside the model. The JSON illustrates propagation and contains no real investigation data.

Four list types, two distinct constraints

Four list types, two distinct constraints
preuves typeNull list allowedNull item allowedSingle item failure
[String]YesYesOne item becomes null.
[String!]YesNoThe list becomes null.
[String]!NoYesOne item becomes null; the list remains present.
[String!]!NoNoPropagation reaches dossier, then the root depending on its type.

Eight reference results, readable without JavaScript

G01 · [String] · affaire: Dossier

Only item 1 becomes null; the other two items and the case remain readable.

{
    "data": {
        "affaire": {
            "reference": "DEMO-01",
            "preuves": [
                "A-01",
                null,
                "A-03"
            ]
        },
        "statut": "fictif"
    },
    "errors": [
        {
            "message": "Illustrative item resolution failure",
            "path": [
                "affaire",
                "preuves",
                1
            ]
        }
    ]
}

Acceptance check : Check the received JSON and retain errors[0].path = ["affaire", "preuves", 1], even when affaire is replaced by null.

G02 · [String!] · affaire: Dossier

The preuves list becomes null; the case reference and status remain readable.

{
    "data": {
        "affaire": {
            "reference": "DEMO-01",
            "preuves": null
        },
        "statut": "fictif"
    },
    "errors": [
        {
            "message": "Illustrative item resolution failure",
            "path": [
                "affaire",
                "preuves",
                1
            ]
        }
    ]
}

Acceptance check : Check the received JSON and retain errors[0].path = ["affaire", "preuves", 1], even when affaire is replaced by null.

G03 · [String]! · affaire: Dossier

Only item 1 becomes null; the other two items and the case remain readable.

{
    "data": {
        "affaire": {
            "reference": "DEMO-01",
            "preuves": [
                "A-01",
                null,
                "A-03"
            ]
        },
        "statut": "fictif"
    },
    "errors": [
        {
            "message": "Illustrative item resolution failure",
            "path": [
                "affaire",
                "preuves",
                1
            ]
        }
    ]
}

Acceptance check : Check the received JSON and retain errors[0].path = ["affaire", "preuves", 1], even when affaire is replaced by null.

G04 · [String!]! · affaire: Dossier

The affaire case becomes null; the sibling statut field remains available.

{
    "data": {
        "affaire": null,
        "statut": "fictif"
    },
    "errors": [
        {
            "message": "Illustrative item resolution failure",
            "path": [
                "affaire",
                "preuves",
                1
            ]
        }
    ]
}

Acceptance check : Check the received JSON and retain errors[0].path = ["affaire", "preuves", 1], even when affaire is replaced by null.

G05 · [String] · affaire: Dossier!

Only item 1 becomes null; the other two items and the case remain readable.

{
    "data": {
        "affaire": {
            "reference": "DEMO-01",
            "preuves": [
                "A-01",
                null,
                "A-03"
            ]
        },
        "statut": "fictif"
    },
    "errors": [
        {
            "message": "Illustrative item resolution failure",
            "path": [
                "affaire",
                "preuves",
                1
            ]
        }
    ]
}

Acceptance check : Check the received JSON and retain errors[0].path = ["affaire", "preuves", 1], even when affaire is replaced by null.

G06 · [String!] · affaire: Dossier!

The preuves list becomes null; the case reference and status remain readable.

{
    "data": {
        "affaire": {
            "reference": "DEMO-01",
            "preuves": null
        },
        "statut": "fictif"
    },
    "errors": [
        {
            "message": "Illustrative item resolution failure",
            "path": [
                "affaire",
                "preuves",
                1
            ]
        }
    ]
}

Acceptance check : Check the received JSON and retain errors[0].path = ["affaire", "preuves", 1], even when affaire is replaced by null.

G07 · [String]! · affaire: Dossier!

Only item 1 becomes null; the other two items and the case remain readable.

{
    "data": {
        "affaire": {
            "reference": "DEMO-01",
            "preuves": [
                "A-01",
                null,
                "A-03"
            ]
        },
        "statut": "fictif"
    },
    "errors": [
        {
            "message": "Illustrative item resolution failure",
            "path": [
                "affaire",
                "preuves",
                1
            ]
        }
    ]
}

Acceptance check : Check the received JSON and retain errors[0].path = ["affaire", "preuves", 1], even when affaire is replaced by null.

G08 · [String!]! · affaire: Dossier!

data becomes null: the chain of non-null response positions reaches the root.

{
    "data": null,
    "errors": [
        {
            "message": "Illustrative item resolution failure",
            "path": [
                "affaire",
                "preuves",
                1
            ]
        }
    ]
}

Acceptance check : Check the received JSON and retain errors[0].path = ["affaire", "preuves", 1], even when affaire is replaced by null.

Six business checks for a GraphQL viewing API

Six business checks for a GraphQL viewing API
CIE scenarioEvidence to collectDecision criterion
G-ACC · Another tenant’s objectTwo test identities and the same case ID, without production data.The service enforces access on the object, relations and fields; possessing an ID grants no access.
G-ALIAS · Two aliases, one objectTwo aliased selections and correlated traces in an authorized environment.Aliases change neither access scope nor cost policy. The client links each error to the received response name.
G-CACHE · Account changeThe sign-out journey followed by sign-in as another test account.Cached data does not cross identity changes. Partial responses do not present an old proof as newly read.
G-COST · Volume and depthTest measurements of cardinality, depth, time and service-specific quotas.Depth alone is insufficient: bound list size, expensive fields and grouped operations. No universal threshold is invented.
G-ERROR · Public messageExamples of visitor-facing messages and operator-only traces.Expose no stack, secret, table name or sensitive evidence. A non-sensitive correlation identifier supports troubleshooting.
G-SXO · Missing evidence blocks an actionKeyboard and screen-reader journey with a required field failing.Announce the partial state, keep retained data readable, and explain then prevent confirmation that depends on the unavailable field.

OWASP · GraphQL Cheat Sheet · Living guidance consulted 2026-10-23

A partial response proves neither a leak nor correct protection. Only service-side authorization tests can verify access. Link each acceptance case to the deployed schema, its version and client observations: data controls, interface resilience and transport need coordinated checks with distinct criteria.

Provenance, edition and licence

GraphQL Specification · September 2025 · reviewed 2026-10-23. CIE: original explanations, fictional scenarios and limited educational model.

GraphQL HTML SHA-256: 39fb3aeffd9b5acebb0830ddc6dcc243c1280a9f0e977897ae59c5cc165511d6

HTTP draft HTML SHA-256: 90a686f8251073b05e105697c6028288520d0c0fa6442924c0d1751cad3f14ac

GraphQL over HTTP · Current Working Draft · Working draft consulted 2026-10-23 · may change

GraphQL · Copyright and Licensing · Open Web Foundation Agreement 1.0

公式参照文献

参照文献はメソッドを裏付けるものです。 チェックは状況に合わせて調整してください。 これらは認証ではありません。 元の参照文献のタイトルやソース文書は別の言語で書かれている場合があります。

参照資料の確認日 .