appsec.fyi

GraphQL — A Practical Guide

A curated AppSec resource library covering XSS, SQLi, SSRF, IDOR, RCE, XXE, OSINT, and more.

GraphQL: A Practical Guide

Curated and synthesized by . Last updated 2026-07-01. Synthesized from 104 of 104 curated resources. Browse all 104 GraphQL resources →

The Problem: GraphQL's Flexible Power and its Security Pitfalls

GraphQL, lauded for its efficiency and flexibility, allows clients to request precisely the data they need in a single query. While this empowers developers and improves performance by avoiding over- or under-fetching common in REST APIs, this very flexibility creates a unique and often underestimated attack surface. The ability for clients to dynamically construct complex queries, combined with implementation flaws, opens the door to a range of sophisticated attacks that bypass traditional security controls. At its core, the issue stems from the potential for uncontrolled query execution and the inconsistent enforcement of access controls within GraphQL resolvers [1][2]. This dynamic nature means that the security posture of a GraphQL API is not static; every new schema addition, resolver, or field can introduce new vulnerabilities if not carefully managed [1].

Core Mechanics: How GraphQL Works and Where It Can Break

GraphQL operates on a schema-driven model, where the server defines the available data and operations. Clients interact with a single endpoint, typically /graphql, sending queries or mutations within JSON payloads. The server parses these requests, validates them against the schema, and then executes resolvers to fetch or modify data. This process, while efficient, relies heavily on how developers implement authorization and input validation within these resolvers.

Key components that influence security posture include:

Notable Vulnerabilities and Attack Techniques

The flexibility of GraphQL, coupled with common implementation oversights, gives rise to several critical vulnerabilities:

1. Broken Object-Level Authorization (BOLA) / Insecure Direct Object References (IDOR)

This remains one of the most prevalent and impactful vulnerabilities. It occurs when an API fails to properly validate whether a user is authorized to access a specific object or resource based on its identifier. In GraphQL, this often manifests when a query for a resource (e.g., getUser(id: 123)) returns data for unauthorized objects by simply incrementing or guessing the ID [8][9][10][2][11][12]. Attackers can leverage introspection to discover sensitive types and then probe for predictable IDs to bypass access controls and exfiltrate data belonging to other users.

2. Excessive Data Exposure and Schema Introspection Abuse

GraphQL introspection, while a powerful tool for development, becomes a significant liability when exposed in production environments. Attackers can query the __schema field to obtain a complete map of the API, revealing all available types, fields, and operations [3][4][5]. This detailed schema intelligence significantly aids attackers in identifying high-value targets, formulating injection payloads, and understanding authorization gaps. Even if introspection is disabled, field suggestions in error messages can offer clues to reconstruct parts of the schema [13][5][14].

3. Denial of Service (DoS) and Resource Exhaustion

GraphQL's ability to allow clients to request deeply nested or complex data structures can be exploited to overwhelm server resources. This includes:

4. Injection Attacks

As with any API, GraphQL endpoints are susceptible to injection attacks. Because arguments passed to queries and mutations are often directly used in backend operations (e.g., database queries), improper sanitization can lead to:

5. Authentication and Authorization Bypass

Beyond BOLA/IDOR, GraphQL implementations can suffer from broader authentication bypasses. This occurs when the mechanism for verifying a user's identity or permissions is flawed, allowing unauthorized access to protected data or functionalities. A common pattern is relying on client-side controls or improperly validating session tokens at the resolver level [8][34][35][36][2].

6. Cross-Site Request Forgery (CSRF)

GraphQL APIs, particularly those using cookies for authentication or relying on predictable POST endpoints, can be vulnerable to CSRF attacks. An attacker can trick a user's browser into submitting unintended GraphQL mutations or queries on their behalf [37][38][20][39][40][14][41][42].

Detection and Prevention Strategies

Securing GraphQL APIs requires a multi-layered approach, addressing vulnerabilities at various stages of the API lifecycle.

1. Robust Authentication and Authorization

2. Limiting Query Complexity and Resource Consumption

3. Input Validation and Sanitization

4. Securing Introspection and API Discovery

5. CSRF Protection

Tooling for GraphQL Security Testing

A range of specialized tools can assist in identifying GraphQL vulnerabilities:

Recent Developments and Trends

The security landscape for GraphQL is continuously evolving. Recent trends include the rise of AI-powered penetration testing platforms that can automate discovery and exploitation of GraphQL vulnerabilities [56]. There's also a growing awareness of supply chain attacks impacting GraphQL packages, highlighting the need for secure dependency management [57]. Furthermore, the complexity of securing federated GraphQL schemas and implementing fine-grained access control across distributed services is an ongoing challenge [45].

Where to Go Deeper

For a comprehensive understanding of GraphQL security, consult the following resources:

Sources cited in this guide

  1. GraphQL Security Testing Guide (2026) — levo.ai
  2. GraphQL API Security Risks Every Developer Should Know — wiz.io
  3. PayloadsAllTheThings — GraphQL Injection — github.com
  4. GraphQL Security Testing: Introspection Abuse, Injection, and DoS — redteamworldwide.com
  5. GraphQL Security from a Pentester's Perspective | AFINE — afine.com
  6. Exploiting GraphQL Query Depth — checkmarx.com
  7. 9 Ways To Secure your GraphQL API - Apollo Checklist — apollographql.com
  8. The Red Agent POV: Exploiting Broken Object-Level Authorization in an Airline GraphQL API — wiz.io
  9. IDOR Vulnerability In GraphQL Api On inmobi.com — 1mirabbas.medium.com
  10. GraphQL IDOR leads to information disclosure (Eshan Singh) — medium.com
  11. Hacking GraphQL Endpoints in Bug Bounty Programs | YesWeHack — yeswehack.com
  12. 👩‍💻Roadmap to Cybersecurity in 2022, Full-Read SSRF, IDOR in GraphQL, GCP Pentesting, and much… — infosecwriteups.com
  13. Exploiting GraphQL (Assetnote Research) — assetnote.io
  14. Exploiting GraphQL — blog.assetnote.io
  15. Cyclic Queries and Depth Limiting (Escape) — escape.tech
  16. GraphQL Security: 7 Common Vulnerabilities and Mitigations — tyk.io
  17. GraphQL Cheat Sheet | OWASP — cheatsheetseries.owasp.org
  18. Didn't Notice Your Rate Limiting: GraphQL Batching Attack — checkmarx.com
  19. BatchQL: GraphQL Security Auditing for Batch Attacks — github.com
  20. GraphQL API Vulnerabilities - PortSwigger — portswigger.net
  21. GraphQL Attacks and Vulnerabilities — beaglesecurity.com
  22. Avoid GraphQL Denial-of-Service Attacks through Batching and Aliasing — escape.tech
  23. Hacking (and Securing) GraphQL — blog.arcjet.com
  24. CVE-2025-31496: GraphQL Query Vulnerability in Apollo Compiler Leading to DoS — ameeba.com
  25. Apollo Router Query Planner Excessive Resource Consumption via Named Fragment Expansion (CVE-2025-32034) — github.com
  26. InQL: Advanced GraphQL Security Testing Burp Extension — github.com
  27. Escape-Technologies/awesome-graphql-security: A curated list of awesome GraphQL Security frameworks, libraries, software and resources — github.com
  28. Hasura GraphQL 1.3.3 Local File Read via SQL Injection — vulncheck.com
  29. HackerOne Report #435066: SQL injection in GraphQL endpoint — hackerone.com
  30. GraphQL API Vulnerabilities, Common Attacks & Security Tips — vaadata.com
  31. GraphQL - Security Overview and Testing Tips · Doyensec's Blog — blog.doyensec.com
  32. Damn Vulnerable GraphQL Application — github.com
  33. Prisma and PostgreSQL vulnerable to NoSQL injection? (Aikido) — aikido.dev
  34. Exploiting Broken Authentication Control in GraphQL — praetorian.com
  35. Apollo Authentication and Authorization Docs — apollographql.com
  36. How a GraphQL Bug Resulted in Authentication Bypass — hackerone.com
  37. CVE-2025-59845: CSRF Vulnerability in Apollo Studio Embeddable Explorer and Sandbox — ameeba.com
  38. Exploiting CSRF in GraphQL Applications — fdzdev.medium.com
  39. Facebook GraphQL CSRF – These aren't the access_tokens you're looking for — philippeharewood.com
  40. [TOKOPEDIA] SITE-WIDE CSRF THROUGH GRAPHQL REQUEST — rafiem.github.io
  41. Facebook GraphQL CSRF – These aren't the access_tokens you're looking for — philippeharewood.com
  42. [TOKOPEDIA] SITE-WIDE CSRF THROUGH GRAPHQL REQUEST — rafiem.github.io
  43. Authorization in GraphQL (Apollo) — apollographql.com
  44. Exploiting GraphQL for Penetration Testing (Raxis) — raxis.com
  45. Enforcing GraphQL security best practices with GraphOS — apollographql.com
  46. GraphQL Introspection Security: Lessons from the Parse Server Vulnerability — escape.tech
  47. GraphQL Security: 9 Best Practices to Protect Your API (Escape) — escape.tech
  48. GraphQL | HackTricks — book.hacktricks.xyz
  49. GraphQL introspection leads to sensitive data disclosure. — medium.com
  50. GraphQL Introspection leads to Sensitive Data Disclosure. — medium.com
  51. swisskyrepo/GraphQLmap: GraphQLmap is a scripting engine to interact with a — github.com
  52. doyensec/graph-ql: GraphQL Security Research Material — github.com
  53. https://github.com/gsmith257-cyber/GraphCrawler — github.com
  54. https://blog.assetnote.io/2021/08/29/exploiting-graphql/ — blog.assetnote.io
  55. GraphQLer: Context-Aware GraphQL API Fuzzing Tool — github.com
  56. DarkMoon AI-Powered Autonomous Penetration Testing Platform With 50 Tools — cybersecuritynews.com
  57. TanStack npm Packages Hit by Mini Shai-Hulud — snyk.io
  58. GraphQL API Vulnerabilities Learning Path — PortSwigger — portswigger.net
  59. GraphQL Discovery: Pentesting 101 Guide — escape.tech
📚 This guide is synthesized from the full text of resources curated in the GraphQL library, and refreshed as new material is added.