GraphQL Denial of Service
Resource exhaustion driven by a single client-shaped document — nesting, fan-out, aliases, duplication, fragments or directives — or by bugs in the parser, validator and query planner that process it before any resolver runs.
How it works
Cost in GraphQL scales with the shape of the query, not the request count, and by default depth and list size are unbounded. A secondary reason: the language is far harder to parse, normalize and validate than a URL, so each stage (parse → normalize/inline fragments → validate → plan → execute) has its own exhaustion bugs.
Query-shape vectors
| Vector | Shape |
|---|---|
| Depth / cyclic relationships | Bidirectional edges (Paste.owner.pastes... in DVGA, searchGroups{users{groups{users...}}}) grow work exponentially with depth |
| Amount / pagination bypass | searchGroups(name:"", limit:1000000) or unbounded list fields |
| Alias overloading | Same expensive field/mutation N times under aliases (see GraphQL Batching Attacks) |
| Field duplication | Same field repeated in one selection set; cheap to send, may be resolved repeatedly depending on engine |
| Directive overloading | Many directives on a field hammer validation |
| Fragment expansion | Deeply nested, reused named fragments expand exponentially |
| N+1 fan-out | Nested lists trigger one backend call per element absent DataLoader-style batching |
query evil { # depth 0
album(id: 42) { # 1
songs { # 2
album { # 3
songs { ... } # NEngine / infrastructure CVEs
- Apollo Router CVE-2025-32034 — named fragments expanded once per spread during query planning → exponential cost. Fixed in 1.61.2 / 2.1.1 with a “Query Fragment Expansion Limit”; only workaround was operation safelisting.
- Apollo Compiler CVE-2025-31496 (CVSS 7.5) — same fragment-reuse pattern hits validation; fixed 1.27.0.
- graphql-core CVE-2026-119286 —
validatereused a sharedValidationAbortedErrorinstance that accumulated traceback frames across repeated validation errors → unbounded memory growth; fixed 3.3.1. - graphql-core CVE-2026-134795 — the parser’s
max_tokenslimit was checked only afterLexer.lookaheadhad already tokenized consecutive comments, so an unauthenticated document consisting of long comment runs cost CPU and memory proportional to its size, regardless of the token limit. Affects 3.2.12–3.2.13 and 3.3.0rc1–3.3.1; fixed in 3.2.14 / 3.3.2. A token limit counts only the tokens it actually sees; cap raw body bytes as well (GHSA-5pww-59wv-hj9w). - Directus GHSA-g293-vf99-xv36 — anonymous alias amplification of argon2id hashing, SMTP sends and lockouts on
/graphql/system. - HackerOne $12,500 — aliased
verifyAccountRecoveryPhoneNumberdegraded account recovery. - CVE-2026-22014 (persisted-query fallback) — server fell back to the client-supplied
querywhenqueryIdwas unknown, voiding the allowlist and re-enabling arbitrary expensive queries. - Saleor GHSA-24jw-f244-qfpp — unbounded JSON-array batching; each element passed the per-query complexity limit, the request as a whole blocked uvicorn async workers and exhausted DB connections.
- SurrealDB GHSA-p3c2-wh5f-jwqm —
GET /graphqlWebSocket upgrade omitted the fivemax_frame_size/max_message_size/ buffer bindings present on/rpcand/sql, so tungstenite defaults applied (16 MiB frame, 64 MiB message,usize::MAXwrite buffer). Anonymous sessions only needed namespace and database names in headers; loweringSURREAL_WEBSOCKET_MAX_MESSAGE_SIZE(the mitigation for the earlier GHSA-65rj-r9fh-jp2v) gave false coverage. Fixed in 4.0.0; interim--deny-http graphqlor proxy-level frame limits.
Testing
- Map cycles from the schema (InQL flags circular references), then step depth upward on staging and record latency and response size; OWASP’s advice is literally to try to crash staging first.
- Separate limits: a depth rule rejecting depth ≥5 at validation still let 50 aliases of an in-limit query through — depth limit is not a cost limit.
- Probe alias count, token count, payload size, list
limit/firstcaps, fragment nesting and directive counts independently. - graphql-cop ships four DoS-class checks (alias overloading, array batching, directive overloading, circular introspection) alongside its misconfiguration tests; wrappers typically switch them off in stealth runs.
- Keep it bounded and get written permission: availability findings on prod are rarely in scope without it.
Defenses
- Depth limit:
graphql-depth-limit(validationRules: [depthLimit(7)]), graphql-javaMaxQueryDepthInstrumentation; Hasura and Graphene expose depth settings. - Cost analysis: graphql-java
MaxQueryComplexityInstrumentation, JS cost-analysis libraries; enforce a maximum cost per operation and rate-limit on cost, not requests. - Operation limits: GraphOS depth, height, aliases and root fields; GraphQL Armor max-aliases / max-tokens / max-depth; maximum request bytes.
- Envelope limits: cap JSON-array length and body size; apply WebSocket frame, message and buffer limits on every upgrade route via one shared helper so a new route cannot miss them.
- Timeouts at the resolver/application layer (stops work mid-query) plus infrastructure timeouts (nginx/httpd) as a backstop.
- Paginate every list with server-enforced maxima; DataLoader for N+1.
- Persisted/safelisted operations — and reject, never fall back, on unknown IDs.
- Patch engines: router, compiler and validator bugs bypass app-level limits.
Related
Sources
- Exploiting GraphQL Query Depth · original
- Cyclic Queries and Depth Limiting (Escape) · original
- Apollo Router Query Planner Excessive Resource Consumption via Named Fragment Expansion · original
- CVE-2025-31496: GraphQL Query Vulnerability in Apollo Compiler Leading to DoS · original
- graphql-core unbounded memory growth (CVE-2026-119286) · original
- Directus unthrottled system GraphQL resolvers allow anonymous DoS via alias amplification · original
- How GraphQL Mutation Aliasing Led to a $12,500 DoS Bug in HackerOne’s Account Recovery · original
- GraphQL persisted queries allowlist bypass via ID manipulation · original
- The Complete GraphQL Security Guide: Fixing the 13 Most Common Vulnerabilities · original
- GraphQL Security: 7 Common Vulnerabilities and Mitigations · original
- How GraphQL Batching and Field Duplication Enable Denial of Service · original
- Confirming GraphQL DAST findings: introspection, batching, depth/cost, CSRF over GET · original
- GraphQL Cheat Sheet · original
- Enforcing GraphQL security best practices with GraphOS · original
- GraphQL Security Testing: Introspection and graphql-cop · original
- Saleor: DoS via unbounded GraphQL query batching · original
- SurrealDB GraphQL WebSocket missing size limits (memory amplification) · original
- graphql-core parser max_tokens bypass DoS via comment runs · original