Contents

🌐 JAuth

A detailed write-up of the Web challenge 'JAuth' from PicoGym Exclusive

/images/PicoGym/PicoGymExclusive/JAuth/challenge_presentation.png
Challenge Presentation

📊 Challenge Overview

Category Details Additional Info
🏆 Event PicoGym Event Link
🔰 Category Web 🌐
💎 Points 500 Out of 500 total
⭐ Difficulty 🟡 Medium Personal Rating: 3/10
👤 Author Geoffrey Njogu Profile
🎮 Solves (At the time of flag submission) 4.934 solve rate
📅 Date 20-02-2025 PicoGym
🦾 Solved By mH4ck3r0n3 Team:

📝 Challenge Information

Most web application developers use third party components without testing their security. Some of the past affected companies are:

  • Equifax (a US credit bureau organization) - breach due to unpatched Apache Struts web framework CVE-2017-5638
  • Mossack Fonesca (Panama Papers law firm) breach - unpatched version of Drupal CMS used
  • VerticalScope (internet media company) - outdated version of vBulletin forum software used

Can you identify the components and exploit the vulnerable one? The website is running here. Can you become an admin? You can login as test with the password Test123! to get started.

🎯 Challenge Files & Infrastructure

Provided Files

1
Files: None

🔍 Initial Analysis

First Steps

Initially, the website appears as follows:

/images/PicoGym/PicoGymExclusive/JAuth/site_presentation.png
Site Presentation

Trying to log in with the credentials provided in the challenge description username=test and password=Test123!, since the title of the challenge JAuth reminds me of JWT, I immediately checked the cookies:

/images/PicoGym/PicoGymExclusive/JAuth/login.png
Login

Indeed, there is a token cookie, which is a JWT. We can confirm this with https://jwt.io:

/images/PicoGym/PicoGymExclusive/JAuth/jwtio.png
Jwt.io

As with most JWT challenges, the goal will be to change the role from user to admin. Let’s proceed with the exploitation.

🔬 Vulnerability Analysis

Potential Vulnerabilities

  • JWT None Algorithm Confusion

🎯 Solution Path

Exploitation Steps

Initial setup

Since no attached files or other data are provided, the most basic thing related to JWT is the none algorithm. In fact, there is the possibility to specify the alg (algorithm) used to sign the JWT as none, which is a valid algorithm that does not require a signature. Sometimes there are no checks on this type of algorithm, and it allows the user to forge a JWT token by changing parameters and possibly authenticate as admin. To do this, the first thing to do is remove the signature from the JWT (everything after the last .). I extracted the following JWT from the page by logging in:

1
eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJhdXRoIjoxNzQwMDg1MDc2NTQyLCJhZ2VudCI6Ik1vemlsbGEvNS4wIChXaW5kb3dzIE5UIDEwLjA7IFdpbjY0OyB4NjQpIEFwcGxlV2ViS2l0LzUzNy4zNiAoS0hUTUwsIGxpa2UgR2Vja28pIENocm9tZS8xMzMuMC4wLjAgU2FmYXJpLzUzNy4zNiIsInJvbGUiOiJ1c2VyIiwiaWF0IjoxNzQwMDg1MDc3fQ.zILlnBuAMzwwmimXYDNdC15tiikwXmMUqxGhyLHKjag

As we can see, the JWT contains three . that separate the header, the payload, and the signature. When the none algorithm is specified, there must always be three .; otherwise, the basic structure of the JWT would be corrupted. Therefore, we can completely remove the signature, as it is not needed when the none algorithm is used:

1
eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJhdXRoIjoxNzQwMDg1MDc2NTQyLCJhZ2VudCI6Ik1vemlsbGEvNS4wIChXaW5kb3dzIE5UIDEwLjA7IFdpbjY0OyB4NjQpIEFwcGxlV2ViS2l0LzUzNy4zNiAoS0hUTUwsIGxpa2UgR2Vja28pIENocm9tZS8xMzMuMC4wLjAgU2FmYXJpLzUzNy4zNiIsInJvbGUiOiJ1c2VyIiwiaWF0IjoxNzQwMDg1MDc3fQ.

and proceed with the exploitation phase.

Exploitation

The exploitation phase is based on changing the value of alg to none as the first step. By default, JWTs are base64 encoded, so we can use bash, cyberchef, or any decoder to extract the plain text:

/images/PicoGym/PicoGymExclusive/JAuth/cyberchef.png
CyberChef

Now we can take the header plain text, modify the value of alg to none, and base64 encode it:

/images/PicoGym/PicoGymExclusive/JAuth/cyberchefheader.png
CyberChef Header

As we can see, we have obtained a valid header to forge the JWT with administrator privileges:

1
eyJ0eXAiOiJKV1QiLCJhbGciOiJub25lIn0

Now we just need to set the role to admin using the same procedure:

/images/PicoGym/PicoGymExclusive/JAuth/cyberchefpayload.png
CyberChef Payload

obtaining:

1
eyJhdXRoIjoxNzQwMDg1MDc2NTQyLCJhZ2VudCI6Ik1vemlsbGEvNS4wIChXaW5kb3dzIE5UIDEwLjA7IFdpbjY0OyB4NjQpIEFwcGxlV2ViS2l0LzUzNy4zNiAoS0hUTUwsIGxpa2UgR2Vja28pIENocm9tZS8xMzMuMC4wLjAgU2FmYXJpLzUzNy4zNiIsInJvbGUiOiJhZG1pbiIsImlhdCI6MTc0MDA4NTA3N30

Now we just need to concatenate the header, payload, and signature with . to obtain the complete and valid JWT:

1
eyJ0eXAiOiJKV1QiLCJhbGciOiJub25lIn0.eyJhdXRoIjoxNzQwMDg1MDc2NTQyLCJhZ2VudCI6Ik1vemlsbGEvNS4wIChXaW5kb3dzIE5UIDEwLjA7IFdpbjY0OyB4NjQpIEFwcGxlV2ViS2l0LzUzNy4zNiAoS0hUTUwsIGxpa2UgR2Vja28pIENocm9tZS8xMzMuMC4wLjAgU2FmYXJpLzUzNy4zNiIsInJvbGUiOiJhZG1pbiIsImlhdCI6MTc0MDA4NTA3N30.

Once the valid JWT is obtained with the role set to admin, we can use ChromeDevTools to change the token cookie by setting its value to the newly forged JWT. After refreshing the page (F5), we will get the flag.

Flag capture

/images/PicoGym/PicoGymExclusive/JAuth/manual_flag.png
Manual Flag

🛠️ Exploitation Process

Approach

The automated exploit logs in with a POST request, extracts the token, and modifies the alg to none and the role to admin. Then, it makes a GET request to /private with the forged token, logging in as admin and extracting the flag from the response using a regex.

🚩 Flag Capture

Flag

Proof of Execution

/images/PicoGym/PicoGymExclusive/JAuth/automated_flag.png
Automated Flag
Screenshot of successful exploitation

🔧 Tools Used

Tool Purpose
Python Exploit
Jwt.io JWT Testing

💡 Key Learnings

New Knowledge

I have learned that with JWTs, you can try specifying the none algorithm and remove the signature by changing some parameters, obtaining a valid JWT if there is no proper check in place.

Skills Improved

  • Binary Exploitation
  • Reverse Engineering
  • Web Exploitation
  • Cryptography
  • Forensics
  • OSINT
  • Miscellaneous

📚 References & Resources

Learning Resources


📊 Final Statistics

Metric Value Notes
Time to Solve 00:08 From start to flag
Global Ranking (At the time of flag submission) Challenge ranking
Points Earned 500 Team contribution

Created: 20-02-2025 • Last Modified: 20-02-2025 *Author: mH4ck3r0n3 • Team: *