GraphQL Vulnerabilities Explained: The API Bug Hunters Love


Modern apps run on APIs, and a growing share of those APIs speak GraphQL — a query language that lets a client ask a server for exactly the data it wants, no more and no less. That flexibility is great for developers. For attackers, it’s a buffet. Here’s how GraphQL vulnerabilities work and how bug bounty hunters find them — only on programs that authorize the testing.

What Makes GraphQL Different

A traditional REST API has fixed endpoints: /api/users/123 returns one thing. GraphQL has a single endpoint — usually /graphql — where the client sends a query describing the data it wants. The server’s full data model is described in a schema: every type, field and relationship. If that schema is exposed, an attacker gets a map of the entire API for free.

Vulnerability 1: Introspection Left Enabled

GraphQL has a built-in feature called introspection: send a special query and the server hands you its complete schema. In production, this should be disabled. When it’s not, an attacker learns every field, every type — including internal ones like isAdmin, ssn, or internalNotes that the app never shows in its UI.

Test (on an authorized target) with a simple introspection query:

query {
  __schema {
    types { name }
  }
}

If the server answers with its full type list, introspection is on — and the hunt begins.

Vulnerability 2: Broken Access Control

The classic GraphQL bug. The app’s UI only asks for your own data, but the API happily returns anyone’s. A query like this should never work for a normal user:

query {
  user(id: "123") {
    email
    passwordResetToken
  }
}

If the server doesn’t check authorization on every field — not just the endpoint — an attacker can enumerate user IDs and harvest data the UI never exposes. This is the GraphQL version of IDOR, and it’s one of the most common paid findings in bug bounty.

Vulnerability 3: Denial of Service by Nested Queries

GraphQL lets clients nest queries arbitrarily deep: friends of friends of friends of friends. Without depth limits, a single small query can force the server to do an enormous amount of work — a cheap denial-of-service attack. Responsible APIs set query depth limits, complexity limits and timeouts.

How Hunters Approach GraphQL (Legally)

  1. Find the endpoint — check /graphql, /api/graphql, or the app’s network traffic for GraphQL requests.
  2. Try introspection — if it’s on, you have the full map. If it’s off, tools like GraphQL Voyager or Clairvoyance can reconstruct the schema from error messages.
  3. Map the sensitive fields — look for admin flags, tokens, internal IDs and personal data in the schema.
  4. Test authorization field by field — log in as a low-privilege user and try to read another user’s data through each field.
  5. Report with impact — show exactly what data you could access and why it matters. A screenshot of another user’s email is worth more than a hundred words of theory.

How to Defend a GraphQL API

  • Disable introspection in production.
  • Enforce authorization on every field, not just at the endpoint level.
  • Set query depth and complexity limits to stop resource-exhaustion attacks.
  • Don’t expose internal fields in the schema at all — if a field exists, assume someone will find it.
  • Rate-limit the endpoint like any other login or sensitive surface.

GraphQL’s power is that clients can ask for anything. Your job — as a defender or a hunter — is making sure “anything” doesn’t include what it shouldn’t.

Comments

Popular Posts