At a glance
- Controls
- CWE-770
What it is
GraphQL and flexible search APIs let callers choose which related records to fetch. A query can ask for users, their orders, each order's users, and so on many levels down. The server may then run a vast number of database lookups for one request.
An attacker writes one deeply nested or very wide query and sends it a few times. The database stalls and other users see timeouts. AI tools can read a published schema and build the most expensive possible query almost at once.
Where it hides
What a reviewer can look for in the code and in the behaviour, before anyone proves it.
- Public or partner GraphQL endpoints with circular relations
- Schema introspection left on in production
- Search APIs that accept nested filters or expansions
- Batched requests that pack many queries into one call
How MATT tests it
The proof runs against the deployed product, on every release, whoever wrote the code.
- 01Sign in with the test login and read the schema to find relations that loop back on each other
- 02Send a query that nests these relations a few levels deeper than normal use needs
- 03Measure whether the server rejects it or how much response time grows, keeping depth low enough to avoid harm
Query depth and cost must be capped.
Executable checkas any user: POST /graphql with a query nested 20 levels deep expect: 400 with a depth or cost error as any user: POST /graphql with a batch of 100 queries expect: rejected or limited
Every rule MATT holds →What the fix looks like
- 01
Set a maximum query depth on the server
- 02
Give each field a cost and reject queries above a total cost
- 03
Limit how many queries one request may batch
- 04
Turn off introspection in production unless the API is meant to be public
A check that was never written is found by proving the deployed behaviour, fixed with the engineer who shipped it, and kept fixed by running the control on every change. What is ExploitOps? →