GraphQL query depth, complexity and batching abuse
GraphQL query flexibility can create disproportionate work from one request. Understanding GraphQL query depth and complexity and batching abuse helps establish which security property the feature needs and where that property is actually enforced.
What does this involve?
Availability controls need to bound the total work an operation can cause, including background jobs, nested queries, retries and paid services. Request size alone is a poor measure of cost when small inputs can trigger expensive processing.
GraphQL is becoming more common as a way of creating data-rich clients that are not tightly coupled to a variety of backend services. This section covers security considerations for GraphQL.
Why it matters
Consider a realistic failure: aliases and nested relationships cause repeated expensive resolver execution.
Resource abuse can slow legitimate work, increase service costs or leave queues and business state in an unhealthy condition. Assessment should use proportionate workloads and distinguish a missing limit from a demonstrated operational effect.
An API review follows the server-side behaviour behind the interface. Direct requests, alternate methods and background operations can reveal boundaries that the normal frontend journey does not exercise.
How penetration testers check for it
Assess complexity accounting, depth, batching and field-level cost.
- Confirm that a query allowlist, depth limiting, amount limiting, or query cost analysis is used to prevent GraphQL or data layer expression Denial of Service (DoS) as a result of expensive, nested queries.
- Confirm that GraphQL introspection queries are disabled in the production environment unless the GraphQL API is meant to be used by other parties.
- Check retries, cancellation and identity-based quotas.
- Observe useful service behaviour during bounded failure conditions.
How to fix it
Apply realistic complexity limits and protect expensive backend operations.
- Apply end-to-end work budgets and sensible defaults.
- Limit costly operations at relevant identity boundaries.
- Use bounded retries and safe cancellation.
- Monitor meaningful capacity and cost signals.
Load testing and penetration testing have different operational impacts. The test conditions should be agreed so the review can establish control behaviour without unnecessary service disruption.
Recheck the changed behaviour against the original failure conditions and the legitimate user journey. Keep enough evidence to show which release and configuration were verified, and include related entry points that depend on the same security decision.
Related issues
- GraphQL schema exposure and introspection decisions
- GraphQL resolver authorisation and nested data access
- GraphQL mutation and subscription security
Read about our methodology or contact pentested.com to discuss your APIs and integrations.