Physical attacks
Mobile Apps Pentesting
Pentesting

3000 - GraphQL

Other links: https://medium.com/@apkash8/graphql-vs-rest-api-model-common-security-test-cases-for-graphql-endpoints-5b723b1468b4

POST From: http://ghostlulz.com/api-hacking-graphql/

Introduction

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.

GraphQL

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.

  • /graphql

  • /graphiql

  • /graphql.php

  • /graphql/console

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.

example.com/graphql?query={__schema{types{name,fields{name}}}}

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.

example.com/graphql?query={TYPE_1{FIELD_1,FIELD_2}}

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.

Batching brute-force in 1 API request

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.

Tools

Burp extension and tool: