vibe-audit.lab

guides · 2026-11-14

GraphQL Introspection and Batching: The Two Settings AI Starters Leave On

Published 2026-11-14 · Reviewed 2026-11-14 · By the Ingenious AI team

The short answer

Introspection in production publishes your full API map — every type, field and mutation — to anyone who asks, and batching lets one HTTP request carry a hundred operations, multiplying brute force. Disable introspection and the GraphiQL playground in production, cap batch size and query depth/complexity, and treat the schema as something an attacker should have to guess.

Check your own app free: paste your code or enter your site URL on the Vibe-Code Audit homepage — the free scan checks for exposed secrets, injection flaws, XSS patterns, missing headers and exposed .env/.git paths, with a copy-paste fix for every finding. No credit card.

What is GraphQL introspection?

a built-in query mechanism that returns the server's complete schema. Essential during development, it is reconnaissance-as-a-feature in production. Batching is the companion setting that accepts an array of operations in a single request.

The map you did not mean to publish

REST attackers must guess endpoints; a GraphQL attacker with introspection enabled downloads the map: every query, mutation, argument and hidden-looking field (adminSetRole, internalNotes, legacyLogin) enumerated in one request. Fields your frontend never calls — the ones the AI added 'for later' — are listed with the same prominence as public ones, and their authorization is often exactly as unfinished as their UI. Vibe-Code Audit flags introspection: True and graphiql: True as distinct findings because starters ship both: the schema map and the interactive playground to explore it with, on the production URL.

The damage is rarely introspection alone. It is introspection revealing the mutation whose per-field authorization check was never written — GraphQL's per-field model means 'the route requires login' says nothing about whether this field checks ownership. The map tells the attacker where to dig; missing field-level auth is what they find.

Batching: brute force at wholesale prices

Batching exists for chatty clients, but to an attacker it is a multiplier: one request, one rate-limit tick, one WAF inspection — containing 100 login mutations or 100 OTP checks. Aliases achieve the same inside a single operation. The advanced GraphQL detector flags batching enabled specifically for this brute-force/DoS amplification. The fix is layered: disable array batching unless a real client needs it, cap aliases and total operation count per request, and make rate limiters count operations rather than envelopes (the principle covered in the rate-limits guide).

Depth and complexity limits belong in the same change: without them, a recursive query (friends of friends of friends…) becomes a denial-of-service written in your own schema. Generated servers almost never include depth limiting because the demo queries are three levels deep and perfectly behaved.

A production configuration that closes the class

Set introspection off outside development (Apollo, graphql-yoga, Strawberry and Ariadne all support it as one flag, usually environment-driven — check the deployed value, not the code default). Disable GraphiQL/playground in production or put it behind admin auth. Enable persisted queries or an allow-list for first-party clients if your architecture supports it — the strongest option, turning the API into a fixed menu. Add depth (start at 7–10) and complexity limits, a batch cap if batching stays, and per-operation rate counting. Finally, audit field-level authorization on every mutation the schema exposes, prioritising any field with admin, role, balance or export in its name — because you must now assume the schema is known even with introspection off (it leaks via client bundles anyway).

Verify like an attacker, briefly

Send the standard introspection query to production: a proper configuration answers with an error, not a schema. Open /graphql in a browser: no playground should greet you. Fire a 50-operation batch at a staging clone and watch whether limits bite. These three probes take five minutes and cover the exact findings the scanner reports — run them after every GraphQL library upgrade, because defaults change between major versions.

Worked example: Trailhead Gear's store API

Trailhead Gear (fictional), a retailer with about $19,000/month in online sales, launched a GraphQL API generated from a starter with introspection and GraphiQL live. A scan flagged both, plus batching. Using only the published schema, the owner's tester found a priceOverride argument on the updateCart mutation — a leftover from development — that the checkout honoured. The API shipped a hardened config the same week: introspection and playground off in production, batch capped at 5, depth limited to 8, per-operation rate counting, and priceOverride removed server-side rather than merely hidden. The three attacker probes then returned errors across the board.

Five things to do before you ship

  1. Send an introspection query to your production GraphQL endpoint; a schema in the response is a finding.
  2. Disable introspection and GraphiQL in production via environment-driven config, and verify the deployed values.
  3. Cap or disable batching, limit aliases and operations per request, and make rate limiters count operations.
  4. Add query depth and complexity limits sized to your real clients' deepest legitimate query, plus a margin.
  5. Audit field-level authorization on every mutation — especially role, balance, admin and export fields — assuming the schema is known.

Sources

Frequently asked questions

Does disabling introspection break my frontend?

No. Frontends execute known queries; they do not introspect at runtime. Code-generation tools use introspection at build time — point them at staging, or export a schema file for them.

If the schema leaks through my JS bundle anyway, why bother?

Because effort asymmetry matters: introspection is a one-request complete map including fields no client uses. A bundle leaks only the operations that client performs. Deny the complete map; audit as if it leaked — both.

What depth limit should I choose?

Measure your clients' deepest real query and add a small margin — most apps land between 7 and 10. A limit chosen blind can break legitimate screens; a measured one cannot.

Is batching ever legitimate?

Yes, for known first-party clients with modest batches. Cap it (single digits), count operations for rate limits, and never let it near authentication mutations.

Related guides

Browse the full library on the guides index, run the checks in the launch audit, or compare plans on pricing.


Informational explainer, not a security guarantee. Scan your code free before every deploy.

← all guides

← Back