Engin Demirbilek
  • Intro
  • [Pinned] Community
  • OSWE Review
  • Code Pieces
    • C++: Shellcode Launcher
    • C++: Dynamic DLL Usage
    • C++: Sendin HTTP GET Request
    • C++: Sandbox Detection via Registry
    • C++: Enumerating Environment
    • C++: Dll Injection
    • VBA: HTTP File Dropper
    • Environment Enumeration via Pshell & Cmd
  • Projects
    • Reverse Shell Exploit chain With AV Bypass
    • Execute Shellcode Launcher with Dll Injection
    • Bypassing AVs with simple XOR
    • Bypassing Defender with Exclusion List
  • Vulnerability Research
    • [TR] Centreon 19.10.8 Remote Code Execution
    • [TR] rConfig 3.94 Remote Code Execution
    • [TR] PANDORAFMS 7.0 REMOTE CODE EXECUTION x4
  • Pentest Notes
  • An Uncommon OSINT way to Juicy Files
  • GraphQL Testing Tips
  • Server Side Request Forgery (SSRF)
Powered by GitBook
On this page

Was this helpful?

GraphQL Testing Tips

Make your life easier while testing GraphQL queries

PreviousAn Uncommon OSINT way to Juicy FilesNextServer Side Request Forgery (SSRF)

Last updated 2 years ago

Was this helpful?

  1. UNDERSTANDING THE GRAPHQL

This section contains descriptive and short examples of GraphQL queries.

1.1 What does it Look Like?

Example 1: Simple selective query with a variable

character: object

id: a variable query takes

name: Information will be retrieved from the character object

Example 2: Another selective query with a variable

HeroNameAndFriends: Query name

hero: object

name: Name attribute from the main object

friends: Subobject (Think it like a sub-attribute of a hero with a specified name)

episode: Variable

Example 3: An example of writing data with GraphQL

mutation: Keyword that is used for writing data in GraphQL

As shown in the examples above, GraphQL queries are already pretty descriptive by themselves. Just like every other web application security flaw, what we care about is to putting payloads to variables and/or testing if we can call functions without proper authorization.

2. UNDERSTANDING THE GRAPHQL in Wild

This section contains descriptive information about understanding GraphQL in actual targets/engagements.

2.1 Main Challenges

  1. How to detect GraphQL?

  2. How to detect which Queries/Mutations are exists?

  3. What to Try?

2.1.1 How to Detect GraphQL

GraphQL usually exists under /graphql endpoint. Additional to that, it would be a good idea to check requests from HTTP request history to see if there is any request with similar syntax has been sent by the application.

2.1.2 How to detect which Queries/Mutations are Exists

Introspection Query

The following string can be sent to the GraphQL endpoint in a POST request to dump the whole schema (of course, if Introspection is allowed).

{"query": "query IntrospectionQuery{__schema{queryType{name}mutationType{name}subscriptionType{name}types{...FullType}directives{name description locations args{...InputValue}}}}fragment FullType on __Type{kind name description fields(includeDeprecated:true){name description args{...InputValue}type{...TypeRef}isDeprecated deprecationReason}inputFields{...InputValue}interfaces{...TypeRef}enumValues(includeDeprecated:true){name description isDeprecated deprecationReason}possibleTypes{...TypeRef}}fragment InputValue on __InputValue{name description type{...TypeRef}defaultValue}fragment TypeRef on __Type{kind name ofType{kind name ofType{kind name ofType{kind name ofType{kind name ofType{kind name ofType{kind name ofType{kind name}}}}}}}}"}

It may look confusing but simply it returns a complete schema of which queries can be called, what parameters they take and some other information.

Luckily there is already a BurpSuite extension that exists for checking Introspection query and even showing each request separately in a way more readable format.

If Introspection Query is not Allowed

Well best you can try is to visit every part of the application and check HTTP history logs.

2.1.3 What to Try

There is not an exact list of what to try but the following list is what I do:

  1. Login, note down authenticated GraphQL requests and try them without your Cookie.

  2. If Introspection is Query allowed, try to find interesting queries that may cause scenarios like; data leak, access users' PII, adding yourself to an authenticated panel etc.

  3. Change variables to acheive IDOR .

  4. Try SSRF, SQLi and other payloads in the variables. (I've never seen an XSS in GraphQL).

References

If the Introspection query is enabled in the target GraphQL app, it is possible to dump the whole schema with a single request. Please see the following link for more info:

The extension is called InQL Scanner. Please see the following link for the official Github repo:

InQL Scanner,

https://graphql.org/learn/introspection/
https://github.com/doyensec/inql
GraphQL, https://graphql.org/
https://github.com/doyensec/inql
Figure 1: Simple GraphQL Query
Figure 2: Less-Complex GraphQL Query
Figure 3: Writing data with GRAPHQL
A Graphql request in Burps' HTTP History
An example result of Insrospection Query
InQL Scanner in Action