Skip to content

Commit

Permalink
Adding the scan for Graphql Introspection Query Enabled
Browse files Browse the repository at this point in the history
  • Loading branch information
j3ssie committed Feb 6, 2024
1 parent 9e21fbe commit 73492d6
Showing 1 changed file with 42 additions and 0 deletions.
42 changes: 42 additions & 0 deletions other/GraphQL/graphql-introspection-enabled.bcheck
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

0 comments on commit 73492d6

Please sign in to comment.