Discovering GraphQL endpoints and SQLi vulnerabilities
A GraphQL endpoint passed user-supplied arguments straight into database queries without parameterisation, so a single quote in an argument produced a MySQL syntax error. An attacker could then inject SQL to read data from the database.
medium.com
Published on medium.com
GraphQL is an open source data query language (DQL) and data manipulation language (DML). Initially, GraphQL was developed by Facebook around 2012 and publicly released in 2015.
The full write-up lives on its author's site
It belongs to its author, so we link to it rather than copy it. The other two tabs are our own rewrites, checked against it.
Not written yet. The AI write-up for this write-up has not been written yet. The Original tab links to the source.
How it worked
Root cause
Likely the application built database queries by concatenating GraphQL argument values instead of using parameterised queries.
Impact
An attacker could read data from the database, and the text notes the endpoint may also be vulnerable to blind, time-based or out-of-band injection even without visible errors.
What the attacker needed
Reachable GraphQL endpoint; endpoint accepts the chosen HTTP method
The fix
The application should use parameterised queries so argument values are never treated as SQL code.
How it was found
- Find the GraphQL endpoint, trying common paths and HTTP methods
- Confirm it is GraphQL by sending an invalid query and looking for a syntax error
- Query the schema via introspection to learn the available arguments
- Send a single quote in the type argument and observe a MySQL syntax error
- Exploit the injection by hand or with sqlmap to read database contents
Explained by bugbounty.wiki with AI from the original and checked against quotes from it; it can still be wrong. Read the original before relying on a detail.
Not written yet. The AI write-up for this write-up has not been written yet. The Original tab links to the source.
GraphQL is a way for a website to ask its server for exactly the data it needs. Here the server took a value the user typed and pasted it directly into a database command, so a special character broke the command and let an attacker add their own database instructions. That is called SQL injection.
What is SQL injection?
Input reaches a database query as code, letting an attacker read or change data the application never meant to expose.