GraphQL Introspection Query Enabled
Description:
GraphQL is a popular query language for APIs to help developers query for data using strongly typed queries. By default, GraphQL comes with the Introspection query enabled and requires no additional authentication or authorization. The introspection query returns a GraphQL schema with all the information about the GraphQL API, including what queries it supports like schemas, mutations, fields, but also in some cases, private fields. This can help a bad actor to learn everything about your API with one single request to the GraphQL API. It's a best practice to disable this for unauthenticated users and only allow access by your IDE or in your development environment as that's the intended use for it.
Testing:
To test if the introspection query is enabled in GraphQL, you'll first need to enumerate the API endpoint. Usually, this is one of the following API endpoints:
Once you identified the API endpoint, you can send the following query as a HTTP POST request in the response body:
This query should return all mutations, types, queries and (depreciated) fields.
You can help visualize and understand the returned data using a tool like GraphQL Voyager.
Remediation:
Depending on your development tools and environment, there are several ways to disable the introspection query. In Node.JS, it's simply passing the NoIntrospection to the GraphQL validationRules config field:
In case you use Apollo Server:
And for PHP:
Potential Impact:
A malicious actor is able to enumerate your entire GraphQL API and return back all possible queries, mutations, fields, etc. This information is often later used for further exploitation to aid in finding broken access control vulnerabilities or other methods that the API supports and can be abused by a bad actor.
References:
Last updated