November 19, 2026
How GraphQL Batching and Field Duplication Enable Denial of Service
Introduction

By T4nv1
2 min read
Introduction
As web applications transition from traditional REST APIs to GraphQL, microservices gain flexibility by allowing clients to request precisely the data they need in a single HTTP request. However, this flexibility introduces unique security challenges. Unlike REST endpoints, which typically map one-to-one with static backend controllers, GraphQL endpoints act as dynamic query execution engines.
In this write-up, we explore how unthrottled GraphQL query parsing โ specifically through query batching and field duplication โ can create asymmetrical resource consumption, leading to Application-Layer Denial of Service (DoS).
Target Architecture and Root Cause
The target application utilized a Node.js GraphQL gateway backed by an Apollo Server execution engine connected to a database cluster.
The primary API entry point served requests via a single endpoint:
HTTP
POST /graphql HTTP/2
Host: api.target-app.com
Content-Type: application/json
{
"query": "query GetUserProfile { me { id name email } }"
}POST /graphql HTTP/2
Host: api.target-app.com
Content-Type: application/json
{
"query": "query GetUserProfile { me { id name email } }"
}The vulnerability stemmed from two default configuration choices in the GraphQL engine:
- Batching Enabled: The server accepted an array of GraphQL queries within a single HTTP request payload.
- Lack of Query Cost Analysis: The engine parsed and executed complex or duplicate fields without calculating the computational cost of the requested tree structure prior to execution.
Step 1: Identifying the Query Amplification Vector
During initial testing of the /graphql endpoint, standard request limits (such as rate limiting 100 HTTP requests per minute per IP) were active at the WAF layer.
However, GraphQL batching allows a client to submit multiple queries inside a single JSON array:
JSON
[
{ "query": "query { systemStatus { uptime } }" },
{ "query": "query { systemStatus { uptime } }" }
][
{ "query": "query { systemStatus { uptime } }" },
{ "query": "query { systemStatus { uptime } }" }
]When sent over HTTP, the gateway executed each query sequentially or in parallel within the same process tick, returning an array of responses inside a single HTTP 200 OK wrapper.
By placing 500 distinct queries into a single array payload, an attacker could force the backend engine to perform 500 database operations while registering only a single HTTP request at the WAF level.
Step 2: Field Duplication and Execution Overload
Beyond array-based batching, field duplication within a single query string allows for nested resource consumption.
Because GraphQL allows field aliases, a client can request the same expensive field hundreds of times inside one query block:
GraphQL
query AmplificationCheck {
alias1: expensiveReportFetch(id: "1") { id data }
alias2: expensiveReportFetch(id: "1") { id data }
alias3: expensiveReportFetch(id: "1") { id data }
# ... repeated N times
}query AmplificationCheck {
alias1: expensiveReportFetch(id: "1") { id data }
alias2: expensiveReportFetch(id: "1") { id data }
alias3: expensiveReportFetch(id: "1") { id data }
# ... repeated N times
}When the execution engine parsed this payload, it resolved every alias individually. If the backend resolver lacked a caching or batching layer (such as DataLoader), each alias triggered an independent query execution against the database.
Combining array batching with field aliasing resulted in an exponential multiplier: a single HTTP request could trigger tens of thousands of database lookups, exhausting server thread pools and causing CPU spikes across worker nodes.
Remediation Strategies
- Disable Unnecessary Query Batching: If array batching is not required by front-end clients, disable it at the gateway configuration layer.
- Implement Query Depth and Complexity Limiting: Use libraries (such as
graphql-depth-limitorgraphql-query-complexity) to evaluate the structure of an incoming query before executing it. Set maximum threshold limits for depth and total field cost. - Use DataLoader for Resolver Batching: Implement DataLoader to coalesce duplicate database requests made during a single tick of the event loop into a single batch query.
- Enforce Rate Limiting based on Complexity: Calculate query complexity scores and enforce rate limits based on total cost consumed over time rather than simple HTTP request counts.
Key Takeaways for Security Researchers
- Inspect Engine Configurations: Default settings in popular API frameworks often leave advanced features (like batching or deep nesting) enabled without safety limits.
- Look Beyond HTTP Request Counts: Focus on asymmetric vectors where a small inbound payload forces heavy backend computation or database serialization.