← All lessons Stage 4 · Lesson 6
20 min

GraphQL introspection & exposure

Stage 4 · Lesson 6 · 20 minutes · Requires Lesson 1


The one-line answer

GraphQL is an API style where the client asks for exactly the data it wants in one query — powerful, but if introspection is left on and field-level permissions are missing, it can hand an attacker the whole map of your data and then the data itself.

The boundary: querying a GraphQL API beyond what the app normally does is testing. Labs and your own local apps only.


Why you should care

GraphQL is increasingly common in modern web and mobile apps. It changes how APIs are called, but the bugs from Lessons 2–5 — BOLA, exposed properties, missing rate limits — all reappear, sometimes in sharper form. And GraphQL adds a feature, introspection, that can describe the entire API to anyone who asks.


How it actually works

How GraphQL differs from REST

Recall Lesson 1: REST has many endpoints, each returning a fixed shape:

GET /api/users/1043
GET /api/users/1043/orders

GraphQL usually has one endpoint (often /graphql) and the client sends a query describing exactly what it wants:

POST /graphql HTTP/2
Content-Type: application/json

{"query": "{ user(id: 1043) { name email orders { id total } } }"}

Response:

{
  "data": {
    "user": {
      "name": "Priya",
      "email": "[email protected]",
      "orders": [{ "id": 88213, "total": 1299 }]
    }
  }
}

Key terms:

  • Schema — the full description of every type, field and operation the API supports.
  • Query — read data.
  • Mutation — change data (create, update, delete).
  • Fields — the individual pieces of data you can ask for (name, email, orders).

Introspection: the API describes itself

GraphQL has a built-in feature called introspection: a special query that asks the server "what is your schema?" When enabled, the server returns every type, every field, every query and every mutation — including ones the front-end never uses, like deleteUser or internalNotes.

For developers, it powers handy tools. For an attacker, it's the complete map from Stage 2 Lesson 3, delivered in one request. Burp can help here: send a GraphQL request to Repeater and use the GraphQL tab's option to set an introspection query, then view the schema.

Where things go wrong

1. Introspection on in production. Not a vulnerability by itself, but it removes all guesswork about what to attack.

2. Missing field-level authorisation. The API checks that you can see a user, but not which fields of that user. So a normal user can request { user(id: 1043) { name passwordResetToken isAdmin } }. This is the same idea as API3 from Lesson 3 — property-level authorisation — but GraphQL makes asking for extra fields trivial.

3. BOLA in arguments. user(id: 1043) → change to user(id: 1044). Same bug as Lesson 2, now in a query argument.

4. Over-fetching through relationships. Queries can follow links: user → orders → shipping address → other users at that address. Each hop needs its own permission check.

5. Batching and deep queries (resource abuse).

  • Batching / aliases: one HTTP request can contain many operations — e.g. hundreds of login attempts in one request — slipping past rate limits that count requests (recall Lesson 5).
  • Deep or huge queries: nested queries (friends of friends of friends...) can make the server do enormous amounts of work, causing denial of service.

6. Exposed development tools. In-browser GraphQL explorers (like GraphiQL) left accessible in production.


See it yourself

Only on PortSwigger labs:

  1. Read the GraphQL API vulnerabilities topic introduction (link below).
  2. Do the apprentice lab on accessing private GraphQL posts. Use Burp's GraphQL support in Repeater to run an introspection query and read the schema. Which field looks interesting that the front-end never requested?
  3. Do the lab on accidental exposure of private GraphQL fields.
  4. Write down: the introspection result that helped, the field or argument you changed, and which check was missing.

How attackers abuse this

Attackers find the GraphQL endpoint (common paths like /graphql, /api/graphql, or from JavaScript), run introspection to get the schema, then request sensitive fields, change IDs in arguments, and use batching to brute-force logins or OTPs in a single request.

The defensive fix:

  • Disable introspection in production (or restrict it to authenticated internal users). It removes the free map — but it's not a substitute for the fixes below.
  • Field-level authorisation: check permissions for each sensitive field and each relationship, not just the top-level object. Implement it in the resolvers (the code that fetches each field) or a central authorisation layer.
  • Object-level authorisation on every argument that identifies an object (Lesson 2).
  • Query cost limits: maximum depth, maximum complexity/cost, timeouts, and result-size limits.
  • Limit batching and aliases, and apply rate limits per operation, not just per HTTP request (Lesson 5).
  • Disable or protect development tools (GraphiQL and similar) in production.
  • Don't expose internal fields in the public schema at all; keep separate internal and public schemas where needed.
  • Log and monitor introspection queries, unusual depth, and large batches.

Common mistakes

  • Thinking "introspection off" means secure. Field names can still be guessed or found in front-end code; authorisation is the real fix.
  • Authorising only the top-level query and not nested fields.
  • Rate-limiting per HTTP request when one request can hold hundreds of operations.
  • No depth or cost limits.
  • Leaving GraphiQL open in production.

Check yourself

  1. What does GraphQL introspection reveal, and why does it help an attacker?
  2. A query { user(id: 5) { email isAdmin } } returns isAdmin for any user. Which kind of authorisation is missing?
  3. Why can a REST-style rate limit fail against GraphQL?
Answers
  1. It reveals the entire schema — every type, field, query and mutation, including unused or internal ones. It gives an attacker a complete map without any guessing.
  2. Field-level (property-level) authorisation — the API checks the object but not which fields the caller may see. (And if id can be changed to see other users, object-level authorisation — BOLA — too.)
  3. One HTTP request can contain many operations (batching/aliases). A limit that counts HTTP requests lets hundreds of attempts through in one request. Limits must count operations.

Your lab

  • PortSwigger GraphQL API vulnerabilities: https://portswigger.net/web-security/graphql

Writeup: the endpoint, what introspection revealed, the exposed field or argument, and the field-level fix.


Summary in your language

தமிழில் சுருக்கம்

GraphQL என்பது client தனக்கு வேண்டிய தரவை ஒரே query-யில் சரியாகக் கேட்கும் API முறை — பொதுவாக ஒரே /graphql endpoint. Introspection இயக்கப்பட்டிருந்தால், server தனது முழு schema-வையும் யாருக்கும் சொல்லிவிடும். Field-level அனுமதி இல்லையென்றால் கேட்கும் எந்த field-உம் கிடைக்கும். Batching மூலம் rate limits-ஐத் தாண்டலாம். தீர்வு: production-இல் introspection-ஐ முடக்குதல், field மற்றும் object-நிலை அனுமதிச் சரிபார்ப்பு, query depth/cost வரம்புகள், operation அடிப்படையிலான rate limits.

हिंदी में सारांश

GraphQL एक API तरीका है जिसमें client एक ही query में ठीक वही data माँगता है जो उसे चाहिए — आमतौर पर एक ही /graphql endpoint होता है। Introspection चालू हो तो server अपना पूरा schema किसी को भी बता देता है। Field-level authorisation न हो तो माँगा गया हर field मिल जाता है। Batching से rate limits को चकमा दिया जा सकता है। इलाज: production में introspection बंद करना, field और object-level authorisation, query depth/cost की सीमाएँ, और operation के हिसाब से rate limits।

Want this summary in Malayalam, Telugu, Kannada or another language? Tell us — the most requested languages get added next.


What's next

Stage 4 complete — you've seen how applications break. Now switch sides and learn to catch these attacks as they happen: Stage 5 · Blue Team / SOC