Skip to main content
MediumAPIOWASP A05:2021CWE-200

How to fix: GraphQL introspection enabled in production

__schema / __type queries dump the entire schema, including internal fields, admin-only mutations, and deprecation hints that aid targeted attacks.

Why it matters

Introspection in production gives attackers a complete blueprint of your data model: every type, field, mutation, and subscription, eliminating the recon phase and exposing internal-only operations that untrusted clients should never call.

__schema / __type queries dump the entire schema, including internal fields, admin-only mutations, and deprecation hints that aid targeted attacks.

How to fix it

  1. 1Disable introspection in production (Apollo: introspection: false, GraphQL.NET: ExposeMetadata = false)
  2. 2Allow introspection only for authenticated admin users if needed for internal tooling
  3. 3Use persisted queries to give clients what they need without exposing the full schema

Code examples

Apollo Server 4: disable introspection in production

JavaScript
import { ApolloServer } from '@apollo/server';

const server = new ApolloServer({
  typeDefs,
  resolvers,
  introspection: process.env.NODE_ENV !== 'production',
});

GraphQL Yoga: NoSchemaIntrospectionCustomRule

JavaScript
import { createYoga } from 'graphql-yoga';
import { NoSchemaIntrospectionCustomRule } from 'graphql';

const yoga = createYoga({
  schema,
  plugins: [
    {
      onValidate({ addValidationRule }) {
        if (process.env.NODE_ENV === 'production') {
          addValidationRule(NoSchemaIntrospectionCustomRule);
        }
      },
    },
  ],
});

References

Detected automatically by VulnRadar. The check id is api-graphql-introspection-enabled, stable across every scan so you can filter or diff on it.

See every api check

Questions

How severe is GraphQL introspection enabled in production?
VulnRadar rates this medium severity in the api category. The severity is fixed per check, not scored per site, so the same finding is the same severity on every scan.
Does VulnRadar check for this automatically?
Yes. It runs as part of every scan under the check id api-graphql-introspection-enabled, which stays the same between runs so you can filter, diff, or gate CI on it.
Which standards does GraphQL introspection enabled in production map to?
It maps to CWE-200. In the OWASP Top 10 it falls under A05:2021.

Missing a check?

The detection set is open. If you know a misconfiguration this does not catch, propose it: the issue template asks for the threat model, how to detect it, the false-positive risk, and a test fixture, which is the same thing a maintainer would have to work out anyway.

Propose a checkHow a check is built

Scan your own site for graphql introspection enabled in production

VulnRadar runs this check and hundreds more against a URL in seconds. No agent to install, just paste a URL.

Or scan this site as a demoRead the docs

GraphQL introspection enabled in production fix | VulnRadar