GraphQL Security Risks and Controls

GraphQL introduces a flexible query interface that changes the attack surface of web APIs in ways that REST-based security models do not fully address. This page covers the principal vulnerability classes associated with GraphQL implementations, the control frameworks and standards bodies that define remediation requirements, and the structural decisions that separate adequately secured deployments from exposed ones. The scope extends from schema design through runtime enforcement, and is relevant to security engineers, API architects, and assessors evaluating applications verified in the Application Security Providers.


Definition and scope

GraphQL is a query language for APIs and a server-side runtime for executing those queries, originally developed at Meta and open-sourced in 2015. Unlike REST APIs, which expose fixed endpoints with predetermined response shapes, GraphQL exposes a single endpoint through which clients construct arbitrary queries against a typed schema. This architectural flexibility creates a class of security risks that are structurally distinct from conventional REST vulnerabilities.

The scope of GraphQL security covers four primary domains:

  1. Schema exposure and introspection abuse — the ability of clients to query the API's own structure
  2. Query complexity and depth attacks — unbounded recursive queries that exhaust server resources
  3. Authorization and access control failures — field-level and object-level permission gaps not enforced at the resolver layer
  4. Injection and data exfiltration — input validation failures that permit injection into underlying data stores or over-fetching of sensitive fields

OWASP addresses GraphQL risks through the OWASP API Security Top 10, where GraphQL-specific exposures map to API3 (Broken Object Property Level Authorization), API4 (Unrestricted Resource Consumption), and API8 (Security Misconfiguration). NIST SP 800-53 Rev. 5 (csrc.nist.gov) controls SC-5 (Denial of Service Protection) and AC-3 (Access Enforcement) provide the federal control baseline applicable to GraphQL endpoints within FedRAMP-authorized systems.


How it works

GraphQL's execution model begins with a client submitting a query document to a single HTTP endpoint — typically POST /graphql. The server parses the document, validates it against the schema, and resolves each field by invoking resolver functions that fetch data from databases, microservices, or other backends.

The risk surface follows this execution path in discrete phases:

  1. Parse phase — The server parses raw query text into an abstract syntax tree (AST). Malformed or deeply nested queries can trigger excessive CPU consumption before any validation occurs.
  2. Validation phase — The server validates the AST against the schema. Without query depth limits or complexity scoring, a valid but adversarially constructed query (sometimes called an "alias amplification" or "batching attack") can pass validation while generating thousands of backend resolver calls.
  3. Execution phase — Resolvers execute per field. If authorization checks are implemented at the route level rather than the resolver level, a client that bypasses top-level guards gains unrestricted access to nested object fields.
  4. Response phase — GraphQL responses return exactly the fields requested. Without field-level logging, exfiltration of sensitive fields such as password hashes or PII may produce no anomaly in access logs.

Introspection — a built-in GraphQL feature that allows clients to query the full schema structure — is enabled by default in major server implementations including Apollo Server and Graphene. OWASP explicitly recommends disabling introspection in production environments, as it provides attackers with a complete map of available types, fields, and mutations (OWASP GraphQL Cheat Sheet).


Common scenarios

Introspection-enabled production endpoint: An assessor sends a standard __schema introspection query to a production endpoint and receives the full type system, including internal administrative mutations and deprecated fields containing legacy user data structures. This scenario is a direct Security Misconfiguration finding under OWASP API8.

Deeply nested query (DoS via query complexity): A client submits a query nesting 15 levels deep — for example, users → friends → posts → comments → author → friends — generating an exponential number of resolver calls. Without a maximum query depth setting (commonly set to 7–10 levels in production hardened deployments), the server exhausts connection pool resources. This maps to OWASP API4 (Unrestricted Resource Consumption) and implicates NIST SP 800-53 SC-5.

Broken object property-level authorization: A GraphQL schema exposes a User type with fields including email, role, and internalScore. Route-level authentication is enforced, but individual field resolvers do not check whether the authenticated user is authorized to read internalScore. A low-privilege authenticated client queries the field directly and retrieves it without restriction — a pattern OWASP API3 identifies as the most prevalent GraphQL-specific authorization failure.

Batch query abuse: GraphQL allows multiple operations in a single request using aliases or batching. An attacker submits 500 aliased login mutations in one HTTP request, effectively bypassing rate-limiting controls applied per HTTP request rather than per operation. This technique is documented in the OWASP GraphQL Cheat Sheet and is functionally equivalent to credential stuffing amplified by the protocol.


Decision boundaries

The central architectural decision in GraphQL security is where authorization is enforced: at the gateway, the resolver, or both. Gateway-only enforcement fails when clients construct valid queries that traverse object relationships to reach sensitive fields without hitting the guarded entry point.

A comparison of enforcement models:

Control Layer Covers Does Not Cover
Gateway / route-level auth Unauthenticated access, endpoint exposure Field-level access, nested object traversal
Resolver-level auth Field and object permissions per request context Requires consistent implementation across all resolvers
Schema stitching / federated gateway Centralized policy enforcement across microservices Complexity overhead; misconfigurations propagate broadly

The frames how API security disciplines — including GraphQL — are classified within the broader application security service sector.

Qualification standards for practitioners assessing GraphQL implementations draw from certifications including the GIAC Web Application Penetration Tester (GWAPT) and Offensive Security Web Expert (OSWE), both of which address API authorization and injection testing. Federal systems subject to FedRAMP must address GraphQL controls under NIST SP 800-53 CA-8 (Penetration Testing) and SA-11 (Developer Security and Privacy Testing).

Organizations determining whether GraphQL security falls within scope for a formal assessment should reference PCI DSS Requirement 6.2.4 (attacks against applications), which applies to all entities processing cardholder data regardless of API protocol, and the How to Use This Application Security Resource page for sector navigation.


References