Q18 of 20 · GraphQL
What security risks are specific to GraphQL, and how do you test for them?
GraphQLSeniorgraphqlsecurityseniorapi
Short answer
Short answer: Beyond standard injection, GraphQL adds: introspection exposing the API surface, deeply-nested/expensive queries as a DoS vector, nested-authorisation bypass, and batching abuse. Test introspection per environment, query depth/complexity limits, field-level authz, and injection via variables.
Detail
GraphQL's flexibility creates a distinct security surface. The main risks and their tests:
- Introspection exposure —
__schemareveals the whole API. Test that production disables it (and dev enables it intentionally). - Query depth / complexity DoS — client-built queries can be made arbitrarily expensive. Test that depth and cost limits reject abusive queries.
- Nested authorisation bypass — a query traversing into nested fields can leak data if authz is only at the root. Test field/object-level authz (see the nested-authz question).
- Injection — SQL/NoSQL injection still applies through resolver arguments. Test that inputs passed as variables are handled safely and that interpolation isn't happening server-side.
- Batching abuse — GraphQL allows batched operations/aliases; an attacker can use aliases to brute-force (e.g. many
loginattempts in one request, bypassing naive rate limits). Test that rate limiting accounts for aliased/batched operations.
Pair this with a tool like Pynt for automated API security scanning driven from functional tests, and standard DAST tooling. The QA mindset: GraphQL's "ask for anything" power is also its attack surface.
// WHAT INTERVIEWERS LOOK FOR
GraphQL-specific risks beyond generic injection — introspection, depth/complexity DoS, nested authz, alias-batching abuse — each with a test.