GraphQL

An open-source data query and manipulation language for APIs, and a runtime for fulfilling queries with existing data.

Common Directories

To identify exposed GraphQL instances, the inclusion of specific paths in directory brute force attacks is recommended. These paths are:

/graphql
/graphiql
/graphql.php
/graphql/console
/api
/api/graphql
/graphql/api
/graphql/graphql

Identifying open GraphQL instances allows for the examination of supported queries. This is crucial for understanding the data accessible through the endpoint. GraphQL's introspection system facilitates this by detailing the queries a schema supports. For more information on this, refer to the GraphQL documentation on introspection: GraphQL: A query language for APIs.

Basic Operations - Queries

We can fetch field information by sending queries.

query {
	__typename
}

Fields

To fetch a field object, send a query like the following.

Arguments

We can get the specific information by padding arguments (e.g. id) to fields.

Aliases

We can set aliases each field to get multiple results in one request.

Fragments

We can define arbitrary fragment that is be reusable when fetching each field.

Operation Names

We can define an operation name to make an operation less ambiguous. By setting a name, it makes it easier to understand at a glance what kind of operation.

Variables

Directives

We can filter by passing a directive in fields.

  • include

Only include this field if the argument is true.

  • skip

Skip this field if the argument is true.

Basic Operations - Mutations

We can modify fields with the mutation field.

To modify a field, execute like the following.

Enumeration

SQL Injection

We might be able to inject SQL somewhere e.g. arguments. Please refer to SQL Injection Cheat Sheet for more payloads.

NoSQL Injection

We might be able to inject NoSQL somewhere e.g. arguments. Please refer to NoSQL Injection for more payloads.


References

Last updated