POST From: http://ghostlulz.com/api-hacking-graphql/
GraphQL is a data query language developed by Facebook and was released in 2015. GraphQL acts as an alternative to REST API. Rest APIs require the client to send multiple requests to different endpoints on the API to query data from the backend database. With graphQL you only need to send one request to query the backend. This is a lot simpler because you don’t have to send multiple requests to the API, a single request can be used to gather all the necessary information.
As new technologies emerge so will new vulnerabilities. By default graphQL does not implement authentication, this is put on the developer to implement. This means by default graphQL allows anyone to query it, any sensitive information will be available to attackers unauthenticated.
When performing your directory brute force attacks make sure to add the following paths to check for graphQL instances.
Once you find an open graphQL instance you need to know what queries it supports. This can be done by using the introspection system, more details can be found here:GraphQL: A query language for APIs. It’s often useful to ask a GraphQL schema for information about what queries it supports. GraphQL allows us to do so…graphql.org
Issuing the following requests will show you all the queries that are available on the endpoint.
As you can see there is a type called “User” and it have two fields called “username” and “password”. Types that start with a “__” can be ignored as those are part of the introspection system.
Once an interesting type is found you can query its field values by issuing the following query.
Once the query is submitted it will pull the relevant information and return the results to you. In this case we get a set of credentials that can be used to login to the application.
GraphQL is a relatively new technology that is starting to gain some traction among startups and large corporations. Other than missing authentication by default graphQL endpoints can be vulnerable to other bugs such as IDOR.
This information was take from https://lab.wallarm.com/graphql-batching-attack/. Authentication through GraphQL API with simultaneously sending many queries with different credentials to check it. It’s a classic brute force attack, but now it’s possible to send more than one login/password pair per HTTP request because of the GraphQL batching feature. This approach would trick external rate monitoring applications into thinking all is well and there is no brute-forcing bot trying to guess passwords.
Below you can find the simplest demonstration of an application authentication request, with 3 different email/passwords pairs at a time. Obviously it’s possible to send thousands in a single request in the same way:
As we can see from the response screenshot, the first and the third requests returned null and reflected the corresponding information in the error section. The second mutation had the correct authentication data and the response has the correct authentication session token.
Burp extension and tool: