Attacking GraphQL
Kavisha Sheth
What to Expect
● What is GraphQL
● How GraphQL differs from Rest API
● How does GraphQL works
● GraphQL Terminologies
● Introspection
● Why Introspection can be dangerous
● Tools
● Common vulnerabilities & how to exploit them
What is GraphQL?
GraphQL is query language used by APIs to access data from the database
through a single endpoint and it make this possible by using a defined schema
which specifies exactly what we want to access.
How GraphQL differs from Rest API ?
❖ Rest API
● It fetches all data, whether required or not ( “over-fetching”).
● It makes multiple network requests to get multiple resources.
❖ GraphQL
● GraphQL allows multiple resource requests in a single query call
● Saves time and bandwidth
● Increased complexity == more error
https://www.apollographql.com/blog/how-do-i-graphql-
2fcabfc94a01/
Where to find endpoints?
GraphQL usually located at specific endpoints
● /graphql
● /qql
● /graphiql
● /graphql/console
● /graph
● /graphql.php
Also, look for request and response referencing for queries and mutations
GraphQL Terminologies
● Query : To fetch the data
● Mutations: To modify the data
● Fields: It’s specify that exactly what data we want to receive.
● Node : Object containing the data
● Edge : Connect two nodes
Query
Mutation
Introspection
GraphQL server supports introspection over its schema using the same GraphQL query language.
A server exposes the following introspection queries on the Query operation type.
● __schema : Which enable us to fetch whole schema
● __type : What types schema has
● __queryType : What are the operation available in the schema
Introspection
Query
https://apis.guru/graphql-voyager/
Using Introspection for evil purpose
● Get all Queries
● Get all mutations
● Look for error message/ stack trace
● Look for sensitive informations
Enumeration using error message
It reveals actual
value
Tools
● InQL burp extension
● GraphQL IDE
● Altair Graphql IDE
● GraphQL map
● graphql-path-enum
Attacking GraphQL
Vulnerabilities worth looking for !!
● Information Disclosure
● IDOR
● Injections
● Denial of Service
● Authorization Bypass
● Business Logic
Injection :: Stored Cross Site Scripting
Authorization Bypass :: GraphQL Interface Protection Bypass
Code Execution :: OS Command Injection
Thank you

Attacking GraphQL

  • 1.
  • 2.
    What to Expect ●What is GraphQL ● How GraphQL differs from Rest API ● How does GraphQL works ● GraphQL Terminologies ● Introspection ● Why Introspection can be dangerous ● Tools ● Common vulnerabilities & how to exploit them
  • 3.
    What is GraphQL? GraphQLis query language used by APIs to access data from the database through a single endpoint and it make this possible by using a defined schema which specifies exactly what we want to access.
  • 4.
    How GraphQL differsfrom Rest API ? ❖ Rest API ● It fetches all data, whether required or not ( “over-fetching”). ● It makes multiple network requests to get multiple resources. ❖ GraphQL ● GraphQL allows multiple resource requests in a single query call ● Saves time and bandwidth ● Increased complexity == more error
  • 5.
  • 6.
    Where to findendpoints? GraphQL usually located at specific endpoints ● /graphql ● /qql ● /graphiql ● /graphql/console ● /graph ● /graphql.php Also, look for request and response referencing for queries and mutations
  • 7.
    GraphQL Terminologies ● Query: To fetch the data ● Mutations: To modify the data ● Fields: It’s specify that exactly what data we want to receive. ● Node : Object containing the data ● Edge : Connect two nodes
  • 8.
  • 9.
  • 10.
    Introspection GraphQL server supportsintrospection over its schema using the same GraphQL query language. A server exposes the following introspection queries on the Query operation type. ● __schema : Which enable us to fetch whole schema ● __type : What types schema has ● __queryType : What are the operation available in the schema
  • 11.
  • 13.
  • 14.
    Using Introspection forevil purpose ● Get all Queries ● Get all mutations ● Look for error message/ stack trace ● Look for sensitive informations
  • 15.
    Enumeration using errormessage It reveals actual value
  • 16.
    Tools ● InQL burpextension ● GraphQL IDE ● Altair Graphql IDE ● GraphQL map ● graphql-path-enum
  • 17.
  • 18.
    Vulnerabilities worth lookingfor !! ● Information Disclosure ● IDOR ● Injections ● Denial of Service ● Authorization Bypass ● Business Logic
  • 19.
    Injection :: StoredCross Site Scripting
  • 22.
    Authorization Bypass ::GraphQL Interface Protection Bypass
  • 24.
    Code Execution ::OS Command Injection
  • 26.

Editor's Notes

  • #12 How do we know what api functionalioty exist and we can do by sending introspection query
  • #15 https://the-bilal-rizwan.medium.com/graphql-common-vulnerabilities-how-to-exploit-them-464f9fdce696