-
Notifications
You must be signed in to change notification settings - Fork 119
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Adding the scan for Graphql Introspection Query Enabled
- Loading branch information
Showing
1 changed file
with
42 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
metadata: | ||
language: v1-beta | ||
name: "Graphql Introspection Query Enabled" | ||
description: "Refers to the condition where the GraphQL server allows introspection queries, potentially exposing sensitive schema information" | ||
author: "j3ssie" | ||
tags: "exposure", "graphql", "introspection" | ||
|
||
define: | ||
introQuery = "{\"query\":\"\n query IntrospectionQuery {\n __schema {\n \n queryType { name }\n mutationType { name }\n subscriptionType { name }\n types {\n ...FullType\n }\n directives {\n name\n description\n \n locations\n args {\n ...InputValue\n }\n }\n }\n }\n\n fragment FullType on __Type {\n kind\n name\n description\n \n fields(includeDeprecated: true) {\n name\n description\n args {\n ...InputValue\n }\n type {\n ...TypeRef\n }\n isDeprecated\n deprecationReason\n }\n inputFields {\n ...InputValue\n }\n interfaces {\n ...TypeRef\n }\n enumValues(includeDeprecated: true) {\n name\n description\n isDeprecated\n deprecationReason\n }\n possibleTypes {\n ...TypeRef\n }\n }\n\n fragment InputValue on __InputValue {\n name\n description\n type { ...TypeRef }\n defaultValue\n \n \n }\n\n fragment TypeRef on __Type {\n kind\n name\n ofType {\n kind\n name\n ofType {\n kind\n name\n ofType {\n kind\n name\n ofType {\n kind\n name\n ofType {\n kind\n name\n ofType {\n kind\n name\n ofType {\n kind\n name\n }\n }\n }\n }\n }\n }\n }\n }\n \"}" | ||
|
||
run for each: | ||
potential_path = | ||
"/", | ||
"/api", | ||
"/api/graphql", | ||
"/console", | ||
"/graph", | ||
"/graphiql", | ||
"/graphql", | ||
"/graphql/console/", | ||
"/v1/explorer", | ||
"/v1/graphiql" | ||
|
||
given request then | ||
send request called check: | ||
method: "POST" | ||
path: `{potential_path}` | ||
replacing headers: | ||
"Content-Type": "application/json" | ||
body: `{introQuery}` | ||
|
||
if {latest.response.status_code} is "200" and | ||
{latest.response.headers} matches "application/json" then | ||
if {latest.response.body} matches "__schema" and | ||
{latest.response.body} matches "defaultValue" and | ||
{latest.response.body} matches "queryType" then | ||
report issue: | ||
severity: low | ||
confidence: firm | ||
detail: `Graphql Introspection Query Enabled` | ||
end if | ||
end if |