Home / patterns

GraphQL APIs with introspection on and no depth or cost limits

A developer standing at a desk in a loft office in the evening studying an unbranded monitor with a blurred nested tree diagram and code, a whiteboard of boxes and arrows behind him, a mug and notebook on the desk, no brand logos
Quick answer: When an AI assistant scaffolds a GraphQL API, it usually gets the schema and resolvers working and stops there. Left as is, anyone can ask the server to describe its whole schema (introspection), open a GraphiQL or Sandbox explorer, send deeply nested or huge queries that tie up the database, or batch hundreds of login or lookup attempts in one request. OWASP’s GraphQL Cheat Sheet lists these insecure defaults and the fixes: turn off introspection and explorers in production, add depth, amount and cost limits, rate-limit per operation, and check authorization in every resolver.

Last updated November 14, 2026

Steps

  1. Find your GraphQL server setup (Apollo Server, GraphQL Yoga, a Next.js route handler or a hosted GraphQL backend) and check whether introspection and GraphiQL or Sandbox are enabled in production.
  2. Turn introspection off in production unless the API is meant for outside developers. In Apollo Server, introspection is on by default unless NODE_ENV is production, so check for an explicit introspection: true left over from development.
  3. Turn off stack traces in error responses (in Apollo Server, includeStacktraceInErrorResponses: false) and mask internal error messages.
  4. Add a query depth limit and limits on list sizes (for example a maximum for first or limit arguments), and paginate every list field.
  5. Add query cost or complexity limits and a server timeout so one expensive query cannot hog the database.
  6. Limit batching: cap how many operations or aliases one request may contain, and block batching on sensitive fields like login, password reset or one-time codes.
  7. Check authorization inside each resolver (and on node or nodes lookups by ID), not only at the gateway, so a nested field cannot return another user’s data.
  8. Retest with a deliberately deep nested query and an aliased batch of the same field; both should be rejected with a generic error.

Why it matters

OWASP’s GraphQL Cheat Sheet says expensive queries can cause denial of service and that depth and amount are unlimited by default unless you add limits. It recommends disabling introspection and GraphiQL in production or public environments, avoiding stack traces and debug mode, and applying access-control checks on both edges and nodes. It also describes batching attacks, where many queries or aliased lookups in a single request are used to enumerate objects or brute-force passwords and one-time codes, often slipping past rate limits that only count HTTP requests. OWASP’s API Security Top 10 ranks Unrestricted Resource Consumption as API4:2023. Apollo’s docs confirm introspection defaults to on unless NODE_ENV is production. This page is for reviewing your own API.

Sources

OWASP Cheat Sheet Series: GraphQL Cheat Sheet — https://cheatsheetseries.owasp.org/cheatsheets/GraphQL_Cheat_Sheet.html

OWASP API Security Top 10 2023: API4 Unrestricted Resource Consumption — https://owasp.org/API-Security/editions/2023/en/0xa4-unrestricted-resource-consumption/

GraphQL.org: Security — https://graphql.org/learn/security/

Apollo Server docs: ApolloServer options (introspection, includeStacktraceInErrorResponses) — https://www.apollographql.com/docs/apollo-server/api/apollo-server

Checked at the source on November 11, 2026.

Related patterns

Found a problem you'd rather not fix yourself?

Tell us what's wrong. A StorenTech engineer reviews your app and replies with a fixed quote, so you know the cost before any work starts.

Get it fixed by StorenTech

Vibe Security Weekly

One email a week with new failure patterns and how to fix them.

By joining you agree we may email you this newsletter. See our privacy policy. Free. Unsubscribe anytime. We'll never sell your email.