Information Disclosure
Last updated
Last updated
A primary target for attackers is the GraphQL schema, which reveals the structure of an application's data. It's like having a map of the database, including all fields and types, and it is often exposed via the introspection feature which is enabled by default. This allows hackers to understand the data model, business logic and potential attack vectors. Tools like InQL can automate this process, extracting schema information and outputting it in formats that are useful for security testing. However, some GraphQL implementations allow the disabling of introspection, but there are ways around that.
Even if introspection is disabled, there are several techniques to gather schema information:
Non-Production Environments: Development and staging environments may have less stringent security than production, and therefore introspection might be enabled. Subdomains like 'staging' or 'dev' are worth checking for GraphQL services with introspection enabled.
The __type
Meta-field:
The WAF contains rules tailored to GraphQL applications, one of which blocks attempts to introspect the GraphQL API via the __schema
meta-field but doesn’t take into consideration other introspection meta-fields. The rule itself is defined in JSON in the following way:
This can be used as a "canary" to determine if introspection is disabled. By sending a query using __type
and checking the response, an attacker can confirm whether the meta-field is available.
Field Suggestions: When a client misspells a field, the server may return a suggestion, which can be abused to discover the fields in the schema. Tools like Clairvoyance exploit this feature by sending queries based on a dictionary of common words to reconstruct the schema. The edit-distance algorithm will determine whether suggestions are provided.
Field Stuffing: Attackers insert lists of potential field names into queries to discover additional information. By observing what is returned, they can uncover sensitive fields that are not intended for public access.
Type stuffing exploits weaknesses in GraphQL's introspection disabling by targeting the __type
meta-field to uncover schema details.
Technique:
By supplying potential type names in the __type(name:"TypeName")
query, attackers can identify valid types and their fields.
For example, querying for PasteObject
might reveal its fields, such as id
, title
, content
, public
, and more.
Naming Convention: GraphQL type names typically follow UpperCamelCase, like PrivatePasteProperties
. Testing these systematically can uncover existing types.
Example Query:
Response:
Tools like the Custom Word List Generator (CeWL), which comes preinstalled in Kali, can extract keywords from the application’s frontend HTML. Try using the following one-liner to profile and extract information from the DVGA interface:
This command will return a list of words that you can use in a manual field-stuffing attack. Alternatively, merge it with your list of 30,000 words and use it with Clairvoyance. You can merge two text files by using a simple Bash command:
GraphQL’s tendency to return verbose error messages, while helpful for developers, can be exploited. These messages may reveal internal information such as:
SQL statements used by the server to interact with the database.
Database column names.
User credentials.
Inferring Information from Stack Traces:
Some GraphQL implementations allow queries to be sent using the HTTP GET method. This may expose sensitive data, as the data is included in the URL and can be stored in various locations, such as browser history, referrer headers, and proxies.
Enabling Debugging: http://example.com/graphql?debug=1
Tools of the Trade
Several tools are mentioned to aid in information disclosure:
InQL: Extracts schema information, assists in fuzzing and brute-forcing, and can be used to automate tasks from the command line.
Clairvoyance: Uses field suggestions to reconstruct the schema when introspection is disabled.
Burp Suite: Used to intercept traffic, capture queries, and observe application behavior.
CeWL: Extracts keywords from the frontend HTML of an application, which can then be used in field-stuffing attacks.