DEV Community

Is your GraphQL API wide open? A 10-minute check for AI-built apps

If your AI-built app uses GraphQL, there is one question to ask first: can a stranger ask your API what it contains, and can they ask for everything at once?

GraphQL gives clients a lot of freedom. That is the point of it, and it is also why a few default settings matter more than they do in a plain REST API.

Who is at risk

Any app with a /graphql endpoint, including apps that use Hasura, Apollo, Supabase's GraphQL layer, or a Next.js API route that exposes one. AI tools turn on the friendly defaults because they make the demo easier to build.

What tends to go wrong

  • Introspection is open in production. Anyone can download the full list of types, queries and mutations, which is a free map of your data.
  • No authorization on the resolvers. The endpoint checks that you are signed in, but not that the record belongs to you. This is the same IDOR problem as in REST.
  • No depth or size limits. A query can ask for users, then their orders, then each order's items, then each item's users, and keep going until the server runs out of memory.
  • No limit on batching. One request can hold hundreds of queries, which turns a login limit of 5 tries into 500.
  • Verbose errors that show field names, stack traces or SQL.

The 10-minute check (your own app only)

  • Find the endpoint. It is often /graphql or /api/graphql.
  • Send an introspection query with a tool like curl or your browser's dev tools: ask for { __schema { types { name } } }. If you get the full type list back without signing in, introspection is open.
  • Sign in as test user A, copy a request that fetches A's record, and change the ID to one belonging to test user B. If you get B's data, an authorization check is missing.
  • Send a query nested several levels deep (user, orders, items, user, orders). If it still runs and takes long, there is no depth limit.
  • Send a request that holds the same login mutation ten times in an array. If every one runs, batching is not limited.
  • Send a malformed query and read the error. It should be short and generic.

Pass: introspection is off in production, user B cannot read user A's data, deep and batched queries are refused, and errors are short.

What to fix

  • Turn introspection off in production (keep it on in development).
  • Check ownership in every resolver, not only that the user is signed in.
  • Set a maximum query depth and cost, and a request timeout.
  • Limit or disable query batching on sensitive mutations like login.
  • Return generic errors to clients and log the details on the server.

A prompt you can paste into your AI builder

"Review the GraphQL server. Disable introspection in production, add authorization checks for ownership in every resolver, set a maximum query depth and complexity, limit batched operations on login and password mutations, and return generic error messages to clients."

What a scanner can and cannot tell you

An outside scan that never signs in can notice a public endpoint, but it cannot test whether user B can read user A's data. That check needs two real accounts, so run it yourself as in step 3.

I work on ProofForge. The free scan covers what a visitor can see and says plainly what it could not check.

Check your own app from the outside, free

Run the free ProofForge scan on your live URL. No account needed for the first scan. It looks at your public site the way a stranger would and says pass, fail or inconclusive, so you know what is confirmed and what it could not see.

One-time reports start at $9: see pricing. Building with an AI agent? There is an MCP server so it can check before it deploys.

Read on DEV Community ↗ ← Back to News

Comments

No comments yet. Start the discussion.