GraphQL Exploitation
GraphQL is a query language for APIs that exposes a single endpoint (typically /graphql or /api/graphql). Unlike REST, GraphQL lets clients request exactly the data they want, including deeply nested relationships. Misconfigurations commonly expose introspection (full schema disclosure), allow unauthorized data access through query manipulation, and enable denial of service through deeply nested queries.
Endpoint Discovery
GraphQL endpoints are not always at /graphql. Common paths to check:
/graphql/api/graphql/graphql/v1/api/v1/graphql/graphiql(interactive IDE)/playground/console/query
{"data":{"__typename":"Query"}}
A response with __typename confirms GraphQL. A 400 with a GraphQL error message also confirms the endpoint.
Introspection Query
Introspection reveals the entire API schema: types, fields, queries, mutations, and their arguments. Enabled by default in most GraphQL implementations.
The schema dump shows all available queries and mutations. Look for sensitive types (User, Admin, Secret, Token, Config) and mutations (createUser, updateRole, deleteAccount, resetPassword).
For a more readable output, use tools like graphql-voyager (visual schema explorer) or pipe the introspection result through a schema formatter.
Unauthorized Data Access
GraphQL often exposes more data than the frontend uses. Query fields the application does not normally request.
Fields like password, apiKey, ssn may be accessible even when the frontend only requests id and username. GraphQL resolves every requested field unless field-level authorization is implemented.
IDOR via GraphQL
Query other users' data by manipulating the ID argument.
{"data":{"user":{"id":"1","username":"admin","email":"admin@target.local","role":"ADMIN"}}}
Iterate IDs to enumerate all users. If the query resolves without authorization checks, this is an IDOR vulnerability.
Mutation Abuse
Mutations modify data. Test whether sensitive mutations are accessible without proper authorization.
If the mutation succeeds, the API lacks authorization checks on role changes. Common targets: updateUser, createAdmin, resetPassword, deleteAccount mutations.
Batching and Alias Attacks
GraphQL supports query batching and aliases, enabling brute-force attacks in a single request (bypassing rate limits).
Each alias (a0, a1, a2) is a separate login attempt in one HTTP request. Rate limiters that count requests instead of operations are bypassed. Scale to hundreds of attempts per request.
Introspection Disabled Bypass
When introspection is disabled, use field suggestion errors to reconstruct the schema. GraphQL implementations often suggest similar field names in error messages.
{"errors":[{"message":"Cannot query field \"us\" on type \"Query\". Did you mean \"user\" or \"users\"?"}]}
Error messages leak valid field names. Tools like Clairvoyance automate schema reconstruction from suggestion errors. Try common prefixes: us, adm, log, sec, con, tok, pass.
References
-
GraphQL: IntrospectionLINK: GraphQL: Introspection, graphql.org/learn/introspection (opens in new tab)
Official documentation on introspection queries.
-
Clairvoyance: GraphQL Schema ReconstructionREPO: Clairvoyance: GraphQL Schema Reconstruction, github.com/nikitastupin/clairvoyance (opens in new tab)
Tool for reconstructing schemas when introspection is disabled.
-
HackTricks: GraphQLTOOL: HackTricks: GraphQL, hacktricks.wiki/en/network-services-pentesting/pentesting-web/graphql.html (opens in new tab)
GraphQL pentesting techniques and common vulnerabilities.