← Blog

Claude skill GraphQL introspection and schema exposure in production — SA-SKL-INTROSPECT

GraphQL introspection is a development convenience that becomes a reconnaissance tool in production. MCP skills that expose a GraphQL API without disabling introspection hand attackers a complete map of every type, field, mutation, and input argument — including hidden admin endpoints that were never meant to be public. SA-SKL-INTROSPECT covers four schema exposure patterns: full introspection, field suggestion leakage, __typename meta-field enumeration, and persisted query whitelist bypass.

By SkillAudit  |  6 Nov 2026

Why GraphQL schema exposure is a first-step attack, not a standalone vulnerability

Schema exposure by itself does not cause direct data loss — it is an intelligence-gathering step that dramatically lowers the cost of every subsequent attack. An attacker with introspection output from a production GraphQL API can enumerate all mutations (including deleteOrg, impersonateUser, and rotateApiKey), discover all input types and their validation requirements, identify which fields are nullable (potential null-dereference paths), and spot fields that were added after the initial public launch (and therefore probably never reviewed for authorization). Without introspection, the attacker must guess or brute-force field names; with introspection, they have a complete typed API specification. For MCP skills that use GraphQL to back their tool call handlers, schema exposure means that Claude Desktop can be used to enumerate the skill's full data model in a single query.

SA-SKL-INTROSPECT in scope: INTROSPECT-001 (introspection enabled in production), INTROSPECT-002 (field suggestions via error messages), INTROSPECT-003 (__typename meta-field type enumeration), INTROSPECT-004 (persisted query whitelist bypass via introspection). Each pattern includes SkillAudit detection rules and correct fixes.

INTROSPECT-001 — GraphQL introspection enabled in production

Apollo Server 2 enabled introspection by default in all environments. Apollo Server 3+ disabled it in production, but many skill deployments use older versions, fork from pre-Apollo-3 boilerplate, or explicitly re-enable introspection for "convenience." A single POST /graphql with the introspection query returns every type name, field name, argument, description, and deprecation message in the schema. This gives attackers a blueprint of AdminMutation types, internal service field names, and enum values that exist in the codebase but were removed from the public UI. The fix is to disable introspection in production via the server configuration, and to verify the fix by running the standard introspection query against the production endpoint.

// VULNERABLE — Apollo Server with introspection left at default (or re-enabled)
import { ApolloServer } from '@apollo/server';
import { startStandaloneServer } from '@apollo/server/standalone';

const server = new ApolloServer({
  typeDefs,
  resolvers,
  // introspection: not set — defaults to true in Apollo 3 when NODE_ENV is not 'production'
  // Or worse: explicitly re-enabled:
  introspection: true,  // "We need this for the GraphiQL playground"
});

await startStandaloneServer(server, { listen: { port: 4000 } });

// Attacker query:
// { __schema { types { name fields { name type { name } } } } }
// Returns: AdminQuery, deleteUser, impersonateOrg, internalAuditLog ...
// FIXED — disable introspection in production; keep enabled in development only
import { ApolloServer } from '@apollo/server';

const server = new ApolloServer({
  typeDefs,
  resolvers,
  // Disable introspection in production — enable only for local development
  introspection: process.env.NODE_ENV !== 'production',
});

// Verify the fix is working in production:
// curl -X POST https://api.skillaudit.dev/graphql \
//   -H 'Content-Type: application/json' \
//   -d '{"query":"{ __schema { types { name } } "}' \
// Should return: {"errors":[{"message":"GraphQL introspection is not allowed..."}]}
HIGH
SA-SKL-INTROSPECT-001 — GraphQL introspection enabled in production returns a complete schema blueprint including hidden admin types, mutation names, and internal field descriptions, dramatically reducing the effort required to find authorization bypass targets; fix by setting introspection: process.env.NODE_ENV !== 'production' and verifying the standard __schema introspection query returns an error on the production endpoint. Detection: SkillAudit flags Apollo Server or GraphQL Yoga configurations where introspection: true is hardcoded, or where the introspection setting is not gated on a non-production environment check.

INTROSPECT-002 — Field suggestions via error messages reveal undiscovered fields

Even when introspection is disabled, Apollo Server's default error messages include "Did you mean X?" suggestions when a queried field name is close to an existing one. An attacker who queries { adminQuery } and receives "Cannot query field 'adminQuery' on type 'Query'. Did you mean 'admin_query'?" has discovered a field that introspection would have revealed. By systematically querying typo variants of common field names (admin, internal, delete, superuser, impersonate), an attacker can enumerate much of the schema through error messages alone. The fix is to disable field suggestions in production, which Apollo Server 3+ supports via a custom error formatter that strips the "Did you mean" text from validation errors.

// VULNERABLE — default Apollo Server sends field suggestion errors
// Attacker probes: { adminUsers } → "Did you mean 'admin_users'?"
//                  { deleteUser } → "Did you mean 'deleteUserByOrg'?"
//                  { impersonate } → "Did you mean 'impersonateAsUser'?"
// Without introspection, suggestions enumerate hidden field names

// Apollo default configuration — no changes needed to be vulnerable:
const server = new ApolloServer({
  typeDefs,
  resolvers,
  introspection: false, // Correctly disabled
  // But field suggestions are still active in validation errors — missing fix
});
// FIXED — custom error formatter strips "Did you mean" from validation errors
import { ApolloServer } from '@apollo/server';
import { GraphQLError } from 'graphql';

const server = new ApolloServer({
  typeDefs,
  resolvers,
  introspection: process.env.NODE_ENV !== 'production',
  formatError: (formattedError, error) => {
    // Strip field suggestion text from validation errors in production
    if (process.env.NODE_ENV === 'production' &&
        formattedError.message.includes('Did you mean')) {
      return new GraphQLError('Field not found', {
        extensions: { code: 'GRAPHQL_VALIDATION_FAILED' },
      });
    }
    // For development, preserve the full helpful message
    return formattedError;
  },
});
MEDIUM
SA-SKL-INTROSPECT-002 — GraphQL "Did you mean" field suggestion error messages enable attackers to enumerate hidden field names through targeted typo queries even when introspection is disabled; fix by adding a custom formatError handler that strips suggestion text from validation errors in production. Detection: SkillAudit tests production GraphQL endpoints for field suggestion leakage by probing common admin field name variants and checking whether response error messages contain the substring "Did you mean".

INTROSPECT-003 — __typename meta-field enables type enumeration without introspection

The __typename meta-field is part of the GraphQL execution layer and cannot be disabled without forking the GraphQL execution engine — unlike introspection, which is a separate system. Disabling introspection still allows attackers to use { __typename } on any reachable type to confirm its name, and to use inline fragments with ... on SomeType { __typename } to test whether SomeType exists as a concrete type in the schema. By iterating over guessed type names in a loop of inline fragments, attackers can enumerate concrete types without introspection. When combined with field suggestion leakage (INTROSPECT-002), type enumeration via __typename provides enough schema intelligence to identify targets for authorization testing. The fix is to implement depth and complexity limits that make bulk type enumeration impractical, and to monitor for queries containing unusually large numbers of inline fragments.

// VULNERABLE — introspection disabled but __typename still reveals type names
// (This cannot be fully "fixed" at config level — mitigated via rate limiting)

// Attacker probes types via inline fragments:
const probeQuery = `{
  skill(id: "1") {
    ... on AdminSkill { __typename }   # returns "AdminSkill" if type exists
    ... on InternalSkill { __typename } # returns "InternalSkill" if type exists
    ... on SuperuserSkill { __typename }
  }
}`;

// Each fragment that matches returns its __typename, confirming the type exists
// Without query complexity limits, 100+ type probes can run in one request
// FIXED — depth limits + query complexity limits + rate limiting on introspective queries
import { ApolloServer } from '@apollo/server';
import depthLimit from 'graphql-depth-limit';
import { createComplexityLimitRule } from 'graphql-validation-complexity';

const server = new ApolloServer({
  typeDefs,
  resolvers,
  introspection: false,
  validationRules: [
    // Limit query nesting depth to prevent deeply recursive type enumeration
    depthLimit(5),
    // Limit total query complexity — each field costs 1; fragments cost 10
    createComplexityLimitRule(500, {
      onCost: (cost) => console.log('Query complexity:', cost),
    }),
  ],
  formatError: (formattedError) => {
    // Strip suggestions in production (see INTROSPECT-002)
    if (process.env.NODE_ENV === 'production' &&
        formattedError.message.includes('Did you mean')) {
      return { message: 'Field not found', extensions: { code: 'GRAPHQL_VALIDATION_FAILED' } };
    }
    return formattedError;
  },
});
MEDIUM
SA-SKL-INTROSPECT-003 — The __typename meta-field cannot be disabled in standard GraphQL and allows type name confirmation via inline fragment probing even when introspection is off; mitigate by implementing query depth limits (5 or fewer) and query complexity scoring that makes bulk type enumeration economically infeasible. Detection: SkillAudit checks production GraphQL endpoints for the absence of depth-limit and complexity-limit validation rules, and probes whether inline fragment __typename queries return type names for guessed concrete types.

INTROSPECT-004 — Persisted query whitelist bypassed via introspection discovery

Persisted query whitelists (also called Automatic Persisted Queries or operation allowlists) restrict GraphQL endpoints to a predetermined set of approved query hashes, preventing arbitrary query execution. However, whitelists are often frozen at a point in time — when the frontend was shipped — and new mutations added to the schema after that freeze are not in the whitelist. If introspection is still enabled, attackers can discover these post-freeze mutations and execute them either by computing their expected hash and registering them as new persisted queries, or by bypassing the whitelist entirely if the server accepts full query documents as a fallback when a persisted query ID is not found. The fix is to enforce a strict allowlist mode that never falls back to full query execution, and to audit the schema for mutations added after the last whitelist update.

// VULNERABLE — persisted query whitelist with unsafe fallback to full query execution
import { ApolloServer } from '@apollo/server';
import { createPersistedQueryLink } from '@apollo/client/link/persisted-queries';

// Server-side: allowlist loaded from a file frozen at last deploy
const QUERY_ALLOWLIST = new Map(JSON.parse(fs.readFileSync('query-allowlist.json')));

const server = new ApolloServer({
  typeDefs,
  resolvers,
  introspection: true,  // Left enabled — attacker discovers new mutations
  plugins: [{
    async requestDidStart() {
      return {
        async didResolveOperation({ request, document }) {
          const queryHash = sha256(print(document));
          if (!QUERY_ALLOWLIST.has(queryHash)) {
            // UNSAFE: falls back to execution instead of rejecting
            console.warn('Query not in allowlist — executing anyway:', queryHash);
            // Attacker submits a full query document (not a persisted ID)
            // containing a newly discovered mutation — executes successfully
          }
        },
      };
    },
  }],
});
// FIXED — strict allowlist mode that rejects queries not in the list
import { ApolloServer, GraphQLError } from '@apollo/server';
import crypto from 'crypto';
import { print } from 'graphql';

const QUERY_ALLOWLIST = new Map(JSON.parse(fs.readFileSync('query-allowlist.json')));

const server = new ApolloServer({
  typeDefs,
  resolvers,
  introspection: process.env.NODE_ENV !== 'production',
  plugins: [{
    async requestDidStart() {
      return {
        async didResolveOperation({ request, document }) {
          if (process.env.NODE_ENV !== 'production') return; // Allow any query in dev

          const queryHash = crypto
            .createHash('sha256')
            .update(print(document))
            .digest('hex');

          if (!QUERY_ALLOWLIST.has(queryHash)) {
            // STRICT: reject queries not in the allowlist — no fallback execution
            throw new GraphQLError('Query not in allowlist', {
              extensions: { code: 'OPERATION_NOT_ALLOWED', http: { status: 403 } },
            });
          }
        },
      };
    },
  }],
});
HIGH
SA-SKL-INTROSPECT-004 — Persisted query allowlists with fallback-to-full-execution mode allow attackers to bypass the whitelist by submitting full query documents; introspection discovery of post-freeze mutations compounds the issue by providing targets; fix by enforcing strict allowlist rejection with no fallback execution and by disabling introspection in production. Detection: SkillAudit flags GraphQL servers with persisted query plugins where the operation handler emits a warning or no-ops instead of throwing an error on non-allowlisted query hashes.