SKF write-ups
Search…
Java - GraphQL Mutations

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

The application implements a very basic mutation to create a new post on the blog. The mutation used is the following
1
mutation {
2
createPost(title: "This is a new title", body: "This is a new post", author_id: 2) {
3
id
4
title
5
body
6
}
7
}
Copied!
If we look at the code we have a class CreatePost that will implement our logic to create a post.
1
public Post createPost(String title, String body, int user_id) throws org.hibernate.exception.GenericJDBCException{
2
Post post = new Post();
3
post.setTitle(title);
4
post.setBody(body);
5
post.setUser(new User(user_id));
6
postRepository.save(post);
7
return post;
8
}
Copied!
The method mutate will just get the new Post object and insert an instance in the database.

Exploit

What can you exploit? ;)

Additional resources

GraphQL - OWASP Cheat Sheet Series
Export as PDF
Copy link
Edit on GitHub