← Blog

GraphQL Security in Claude MCP Skills: Introspection, Depth Attacks, and Persisted Query Exploits

GraphQL endpoints in MCP skills carry a distinctive attack surface that REST endpoints do not. Five patterns dominate real-world audits: production introspection exposes the entire schema to any unauthenticated caller; depth bombs and alias-amplification attacks consume unbounded CPU without authentication; batch mutations route around per-request rate limits; and persisted query whitelists are bypassable through aliasing and operation naming tricks. This post covers all five with Apollo Server 3+ configuration, graphql-depth-limit, and graphql-validation-complexity examples.

By SkillAudit  |  6 Nov 2026

Contents

  1. Production introspection — full schema disclosure
  2. Query depth bombs — unbounded resolver recursion
  3. Alias complexity amplification — the 1000-alias attack
  4. Batch mutation rate limit bypass
  5. Persisted query whitelist bypass
  6. SkillAudit detection summary

1 — Production introspection: full schema disclosure without authentication

GraphQL's introspection system is a first-class feature of the specification: clients can send a __schema query and receive a complete machine-readable description of every type, field, argument, mutation, and subscription the server exposes. This is valuable in development, but in production it is an enumeration gift. An attacker who can POST a GraphQL query to your MCP skill's endpoint can recover the full type system in one round-trip — including internal admin mutations, deprecated fields that remain live, hidden debug resolvers, and the exact field names needed to construct a credential-extraction query.

The SkillAudit SA-SKL-INTROSPECT pattern covers this in detail. The core issue is that Apollo Server 3+ enables introspection by default regardless of NODE_ENV. Many MCP skills deploy with the Apollo defaults and never audit the endpoint from the outside. The fix is explicit: set introspection: false in ApolloServer options for production, and use a separate schema-aware API documentation tool (Apollo Studio, Rover, Postman) for internal consumers who need the schema.

// VULNERABLE — Apollo Server 3 default: introspection always on
import { ApolloServer } from '@apollo/server';

const server = new ApolloServer({
  typeDefs,
  resolvers,
  // No introspection config — defaults to enabled in all environments
  // curl -X POST https://skill.example.com/graphql \
  //   -H "Content-Type: application/json" \
  //   -d '{"query":"{ __schema { types { name fields { name } } } }"}' \
  // → returns every type, field, mutation, subscription with full docs
});
// FIXED — introspection off in production; on in development only
import { ApolloServer } from '@apollo/server';

const server = new ApolloServer({
  typeDefs,
  resolvers,
  introspection: process.env.NODE_ENV !== 'production',
  // Also disable the landing page (which links to Studio with schema explorer)
  plugins: [
    ...(process.env.NODE_ENV === 'production'
      ? [ApolloServerPluginLandingPageDisabled()]
      : [ApolloServerPluginLandingPageLocalDefault()]),
  ],
});

// For services that need schema access in production (CI schema checks, etc.)
// use Apollo Rover with an API key restricted to schema operations only:
// APOLLO_KEY=service:my-graph:xxxx rover graph introspect https://skill.example.com/graphql

SA-SKL-INTROSPECT-001: Apollo Server 3+ enables introspection in all environments by default. MCP skills deployed with default config expose the full schema — including internal admin mutations and experimental fields — to any unauthenticated HTTP client. Set introspection: false explicitly for production deployments.

2 — Query depth bombs: unbounded resolver recursion

GraphQL schemas commonly have recursive type relationships: a User has friends (also User), who each have friends, and so on. A well-formed GraphQL query can request this relationship to arbitrary depth — the specification places no limit on query nesting. A depth bomb is a query that nests 100 or 1000 levels deep: each level triggers additional database lookups, and the total CPU and memory cost grows exponentially with depth. The skill crashes or becomes unresponsive without the attacker needing valid credentials or a valid operation name.

The graphql-depth-limit npm package adds a validation rule that counts the nesting depth of any incoming query and rejects it before execution if it exceeds a configured maximum. The correct maximum depends on your schema: a schema with deep relationships may need 10-15 levels, but most CRUD schemas work fine with a limit of 7-8. Set it at the Apollo Server validation rules level so it runs before any resolver is called.

// VULNERABLE — no depth limit; 1000-level depth query crashes resolver chain
// Attacker sends:
// { user(id:"1") { friends { friends { friends { ... (1000 levels) } } } } }
// Each level = N database queries; exponential cost per request

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

const server = new ApolloServer({
  typeDefs,
  resolvers,
  // No validationRules — default GraphQL spec allows unlimited query depth
});
// FIXED — graphql-depth-limit rejects deep queries before any resolver runs
import { ApolloServer } from '@apollo/server';
import depthLimit from 'graphql-depth-limit';

const server = new ApolloServer({
  typeDefs,
  resolvers,
  validationRules: [
    depthLimit(
      7, // Maximum query nesting depth — tune to your schema
      { ignore: ['__schema', '__type'] }, // Allow introspection (dev only) to nest deeper
      (depths) => {
        // Log depth violations for monitoring
        if (Object.values(depths).some(d => d > 5)) {
          console.warn('Deep GraphQL query blocked:', depths);
        }
      }
    ),
  ],
});

// For schemas with legitimate deep relationships (tree data, org charts):
// Use connection-pattern pagination instead of unbounded recursive fields.
// A Users → Friends → Posts query should paginate at each level:
// user { friends(first: 10) { edges { node { posts(first: 5) { edges { ... } } } } } }
// This caps the N per level and makes depth attacks computationally uninteresting.

Depth limits are necessary but not sufficient. A flat query that requests 1000 sibling fields at depth 1 bypasses a depth limit but still generates 1000 resolver calls. This is the alias amplification attack covered in the next section.

3 — Alias complexity amplification: the 1000-alias attack

GraphQL aliases allow a client to rename any field in the response. This is a legitimate feature for fetching the same field with different arguments and naming both results. But it also allows a single query to call the same expensive resolver 1000 times in one request: each alias executes the full resolver, makes database calls, and returns a result — and the total cost is multiplied by the alias count. The SA-SKL-GRAPHQL general security page covers alias attacks as a denial-of-service vector.

Query complexity scoring via graphql-validation-complexity (or the Apollo Server built-in costLimit plugin) assigns a cost to each field and aggregates the total query cost before execution. Aliases multiply the cost of the aliased field by the number of aliases. A threshold of 1000 complexity points typically allows rich legitimate queries while blocking pathological alias amplification.

// VULNERABLE — no complexity limit; alias multiplication crashes server
// Attacker sends (truncated to show pattern):
// {
//   a1: expensiveSearch(query: "x") { results { title body }  }
//   a2: expensiveSearch(query: "x") { results { title body }  }
//   ...
//   a1000: expensiveSearch(query: "x") { results { title body } }
// }
// Each alias calls expensiveSearch resolver + N DB queries for results
// Total: 1000× the resolver cost in a single unauthenticated HTTP request

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

const server = new ApolloServer({
  typeDefs,
  resolvers,
  // No complexity limit
});
// FIXED — graphql-validation-complexity rejects queries exceeding cost threshold
import { ApolloServer } from '@apollo/server';
import { createComplexityRule, fieldExtensionsEstimator, simpleEstimator } from 'graphql-query-complexity';

const server = new ApolloServer({
  typeDefs,
  resolvers,
  validationRules: [
    createComplexityRule({
      maximumComplexity: 1000,
      variables: {},
      onComplete: (complexity: number) => {
        console.log('Query complexity:', complexity);
      },
      estimators: [
        // Field extensions estimator: use { complexity: N } in schema field extensions
        fieldExtensionsEstimator(),
        // Fallback: each field costs 1; list fields with args cost childComplexity * multiplier
        simpleEstimator({ defaultComplexity: 1 }),
      ],
    }),
  ],
});

// In schema: mark expensive fields with explicit complexity
// extend type Query {
//   expensiveSearch(query: String!): SearchResults
//     @complexity(value: 50, multipliers: ["first"])
// }
// 20 aliases of expensiveSearch = 20 × 50 = 1000 → rejected at threshold

// Alternatively, use Apollo Server's built-in cost limit plugin (Apollo Server 4+):
// import { ApolloServerPluginCostLimit } from '@apollo/server/plugin/costLimit';
// plugins: [ApolloServerPluginCostLimit({ maxCost: 1000 })]

Defense in depth: Run both depth limits and complexity scoring. A depth limit of 7 does not block a 1000-alias flat query. A complexity limit of 1000 does not block a depth-15 query that stays under the cost threshold through shallow field selection. Apply both rules simultaneously via the validationRules array.

4 — Batch mutation rate limit bypass

GraphQL supports sending multiple operations in a single HTTP request via batching — an array of operation objects rather than a single object. Many GraphQL servers (including Apollo Server with the @apollo/server/express4 HTTP integration) handle batched requests by executing each operation and returning an array of results. This creates a rate-limit bypass: if your rate limiter counts HTTP requests (which is the default for most Express middleware like express-rate-limit), one HTTP request containing 100 batched mutations counts as one request, not 100. An attacker can brute-force OTP codes, trigger 100 password reset emails, or run 100 account registration attempts using a single HTTP request at a rate that never triggers IP-based throttling.

// VULNERABLE — batch mutations bypass per-request rate limit
// Rate limiter configured for 10 requests/minute — attacker uses batching:
// POST /graphql with body:
// [
//   {"query":"mutation { login(email:\"victim@example.com\",password:\"aaa1\") { token } }"},
//   {"query":"mutation { login(email:\"victim@example.com\",password:\"aaa2\") { token } }"},
//   ... (100 mutations in one request)
// ]
// 100 login attempts counted as 1 by express-rate-limit

import express from 'express';
import rateLimit from 'express-rate-limit';
import { expressMiddleware } from '@apollo/server/express4';

const app = express();

app.use('/graphql', rateLimit({
  windowMs: 60 * 1000,
  max: 10, // 10 requests/minute — batching bypasses this
}));

app.use('/graphql', express.json(), expressMiddleware(server));
// FIXED — disable batching in production; rate limit by operation count inside batch
import express from 'express';
import rateLimit from 'express-rate-limit';
import { expressMiddleware } from '@apollo/server/express4';

const app = express();

// Option A: disable batching entirely (recommended for most skills)
// Apollo Server 4 disables batching by default — no extra config needed
// Apollo Server 3: use httpBatchMiddleware only in development
const allowBatching = process.env.NODE_ENV !== 'production';

// Option B: allow batching but rate limit by operation count in batch
app.use('/graphql', (req, res, next) => {
  const body = req.body;
  // Count operations: array body → N operations; object body → 1 operation
  const operationCount = Array.isArray(body) ? body.length : 1;
  // Hard limit: reject batches of more than 10 operations
  if (operationCount > 10) {
    res.status(400).json({ error: 'Batch size exceeds maximum of 10 operations' });
    return;
  }
  // Weight the rate limiter by operation count using a custom key generator
  // that increments a Redis counter by operationCount, not 1
  next();
});

// Operation-level rate limiting inside the resolver (belt-and-suspenders):
// Use a Redis counter keyed by (ip, operationName) with a TTL window
// Increment by 1 per operation call, not per HTTP request

Batch mutation bypasses are especially dangerous for sensitive operations: account creation, OTP verification, password reset, and email sending are all high-value targets. A skill that sends emails or SMS messages per mutation call will send 100 messages per batched HTTP request if batching is enabled without an operation count limit.

5 — Persisted query whitelist bypass

Persisted queries (also called automatic persisted queries, APQ) are a GraphQL performance optimization: the client sends only a hash of the query, and the server executes the pre-registered query matching that hash. Some teams deploy persisted queries as a security control — the idea being that only pre-approved queries can run. This is a valid approach when implemented correctly, but the implementation frequently contains bypasses. The SA-SKL-INTROSPECT-004 finding documents two common bypass paths.

The first bypass: the APQ cache is seeded on first use. Apollo's default APQ implementation stores the query in a cache on the first request that includes both the hash and the full query text. If you rely on APQ as a security boundary (not just a performance optimization), you must disable this seeding behavior and pre-load only your approved queries. Otherwise an attacker seeds the cache with a malicious query on first request, then executes it via hash on all subsequent requests.

The second bypass: GraphQL servers that allow both the APQ hash path and the raw query path simultaneously do not enforce the whitelist on the raw path. Any client that sends a full query field in the request body bypasses APQ entirely and executes arbitrary GraphQL. The fix is to disable raw query execution and only accept APQ hash lookups in production.

// VULNERABLE — APQ seeding allows whitelist bypass; raw query path also open
import { ApolloServer } from '@apollo/server';
import { KeyValueCache } from '@apollo/utils.keyvaluecache';

// Default APQ setup — seeding enabled, raw queries accepted
const server = new ApolloServer({
  typeDefs,
  resolvers,
  cache: new KeyValueCache(), // APQ hash cache — seeded on first request with query text
  // No enforcement: raw query POST with { "query": "mutation { deleteAllData }" }
  // bypasses APQ entirely and executes immediately
});
// FIXED — pre-load approved queries; block cache seeding; reject raw query path
import { ApolloServer } from '@apollo/server';
import { ApolloServerPluginPersistedQueries } from '@apollo/server-plugin-persisted-queries';

// Pre-approved query manifest (generated by Apollo Rover from your client apps)
// Map: sha256Hash → query text
const approvedOperations = new Map([
  ['a1b2c3...', 'query GetUserProfile($id: ID!) { user(id: $id) { name email } }'],
  ['d4e5f6...', 'mutation SubmitAudit($url: String!) { submitAudit(url: $url) { id status } }'],
  // ... all approved operations
]);

const server = new ApolloServer({
  typeDefs,
  resolvers,
  plugins: [
    ApolloServerPluginPersistedQueries({
      cache: {
        get: async (key: string) => approvedOperations.get(key) ?? null,
        set: async () => {
          // No-op: refuse to seed cache with new queries
          // Any hash not in approvedOperations returns null → error
        },
        delete: async () => {},
      },
    }),
  ],
});

// Block raw query path at the HTTP layer:
app.use('/graphql', (req, res, next) => {
  const body = req.body;
  const ops = Array.isArray(body) ? body : [body];
  for (const op of ops) {
    if (op.query) {
      // Raw query text in request — block entirely in production
      res.status(400).json({ error: 'Raw GraphQL queries are not accepted. Use persisted query hashes.' });
      return;
    }
  }
  next();
});

Persisted queries as a security boundary require all three conditions simultaneously: (1) the cache is pre-loaded from an approved manifest and seeding is disabled; (2) the raw query field is rejected at the HTTP layer; (3) the manifest is generated from your production client build artifacts and reviewed before each release. If any condition is missing, the whitelist provides no security guarantee — it is only a performance optimization.

SkillAudit detection summary

SkillAudit's GraphQL security scanner checks five surfaces for each skill that exposes a /graphql endpoint or imports @apollo/server, graphql-yoga, or express-graphql:

Pattern Severity Detection signal Fix
Production introspection enabled HIGH introspection not set to false in production Apollo Server config; or introspection: true explicit introspection: process.env.NODE_ENV !== 'production'
No depth limit validation rule HIGH validationRules array absent or does not include a depth-limit rule graphql-depth-limit with limit ≤ 10
No complexity limit HIGH No complexity estimator in validationRules and no ApolloServerPluginCostLimit graphql-query-complexity with max ≤ 1000
Batch mutations with per-request rate limit only MEDIUM Array body accepted by GraphQL endpoint; rate limiter uses express-rate-limit counting HTTP requests, not operations Disable batching in production, or rate-limit by operation count
APQ cache seeding enabled with no raw query block MEDIUM APQ plugin present but cache set method is not a no-op; or no middleware rejecting raw query fields Pre-load manifest; override set to no-op; block raw query path

All five detections run as static analysis over the skill source tree — no live endpoint required. SkillAudit traces the Apollo Server constructor call, reads the validationRules array, checks for the presence of depth and complexity rules, inspects the APQ plugin's cache object, and checks the Express middleware chain for a raw query rejection guard. See the full findings on the SA-SKL-INTROSPECT and SA-SKL-GRAPHQL pages for per-pattern detection logic and additional edge cases.

CORS misconfiguration is a frequent companion to GraphQL security gaps — a permissive CORS policy on a GraphQL endpoint allows cross-site requests that bypass the same-origin restriction and let attacker pages call mutations on behalf of logged-in users. See the SA-SKL-CORS5 page for the credentialed CORS patterns that most commonly co-occur with GraphQL endpoints in MCP skills.