forbytten blogs

Passman walkthrough - Cyber Apocalypse 2023

Last update:

1 Introduction

I previously wrote about participating in the Hack The Box Cyber Apocalypse 2023 CTF (Capture the Flag) competition.

This walkthrough covers the Passman challenge in the Web category, which was rated as having an ‘easy’ difficulty. This challenge is a white box web application assessment, as the application source code was downloadable, including build scripts for building and deploying the application locally as a Docker container.

The description of the challenge is shown below.

Passman description

The key techniques employed in this walkthrough are:

2 Mapping the application via interaction

  1. The target website was opened in the Burp browser, revealing an “IGMS Passman” login form and a “Create” account link.

    The website displayed a login form and a “Create” account link
  2. The “Create” link was clicked, revealing a self-registration page hosted under /register

    Clicking on the “Create” link lead to a self-registration page hosted under /register
  3. In a terminal, a UUID v4 value was generated in order to obtain a universally unique value

    $ uuid -v4
    669d146c-7e93-4ab1-8a97-58d68d0a69e3

    The UUID v4 value was submitted as the username and password in the registration form, resulting in a dashboard being displayed. The approach of using a UUID v4 ensures the registered user will not be confused with any pre-existing user during any subsequent testing that manages to dump or enumerate users.

    UUID v4 value entered as the username and password in the registration form
  4. Logging in as the self-registered user displayed a dashboard at /dashboard

    Logging in as the self-registered user displayed a dashboard at /dashboard
  5. The raw HTTP request for the registration form submission was observed in Burp. The path of /graphql and the payload both seemed to indicate that GraphQL was being used:

    Raw HTTP request observed in Burp indicated the use of GraphQL
  6. In Burp, another GraphQL request was observed for querying phrases to be displayed on the dashboard:

    Raw HTTP request observed in Burp for querying phrases using GraphQL

3 Vulnerability analysis

3.1 Broken access control

  1. In the server side source code, routes/index.js maps the /graphql route to the GraphqlSchema on line 15:

    routes/index.js maps the /graqhql route to the GraphqlSchema
  2. In GraphqlHelper.js, a mutationType corresponding to the registration request was observed, with the three corresponding args of email, username, and password being declared:

    GraphqlHelper.js defines the mutationType with a RegisterUser field for registering a user
  3. Similarly, a queryType corresponding to the querying of phrases was observed:

    GraphqlHelper.js defines the queryType with a getPhraseList field for querying phrases
  4. Notably, the mutationType also defines an UpdatePassword field

    GraphqlHelper.js defines the mutationType with an UpdatePassword field for updating a user’s password

    Moreover, the implemented authorization control on line 104 is incorrect, as it permits any valid user to update the password of any other user. This is an instance of the common weakness CWE-284: Improper Access Control. A good reference for mitigating this type of vulnerability is the OWASP Authorization Cheat Sheet.

    The UpdatePassword resolver permits any user to update the password of any other user

3.2 Username enumeration

  1. In an attempt to discover a valid username, an attempt was made to register an account with a name of admin. This resulted in an error message indicating the username is already registered, which is an instance of the common weakness CWE-204: Observable Response Discrepancy. However, as CWE-204 indicates, this weakness can either be “inadvertent (bug) or intentional (design)”.1

    The registration form allows usernames to be enumerated, confirming the admin user exists

4 Exploitation

  1. A Burp repeater request based on the previously seen mutationType request was created but modified to invoke the UpdatePassword field in order to change the password of the admin user to an attacker controlled value. The cookie in the request was from the session of the authenticated self-registered user. This resulted in a response indicating the admin user’s password had been successfully changed.

    Burp repeater request to change the admin user’s password, whilst authenticated as the self-registered user
  2. The new admin password was used to successfully login as the admin user:

    The attacker controlled admin password was used to authenticate as the admin user
  3. The flag was obtained by revealing the phrase plaintext on the admin user’s dashboard:

    Flag revealed on the admin user’s dashboard

    The flag was also observable in the raw HTTP request in Burp for querying the phrases:

    Corresponding Burp proxy response which contains the flag

5 Conclusion

The flag was submitted and the challenge was marked as pwned

Submission of the flag marked the challenge as pwned