JWT - Unsecure File Signature (Root-Me): JWT Algorithm Confusion Attack

279 words
1 minute
JWT - Unsecure File Signature (Root-Me): JWT Algorithm Confusion Attack

banner
banner

Statement#

A previous Root Me administrator is trying to replicate the website after being banned for sharing
challenge solutions.
Try to find out if he is hiding any other flags on his new website.

Web-View#

web-view
web-view

I’m having difficulty deciphering the location of Buttons on this website.

Upon inspecting the page’s source code, I discovered certain endpoints that seem intriguing.

/admin
static/challs/htmllecture.html
static/challs/irc.html
static/challs/obfu6.html
static/https://www.youtube.com/watch?v=ZYrmrflWBmY
static/challs/samboxv5.html

/admin#

Upon accessing the ‘admin’ endpoint at http://challenge01.root-me.org:59081/admin, I encountered an ‘Unauthorized’ error.

{"Unauthorized":"You are not admin !"}

burp#

I attempted to intercept the request using Burp in order to uncover more information.

Burp-request
Burp-request

It appears that the situation involves JWT (JSON Web Tokens).

To gain a clearer understanding, I searched for information on jwt.io to access helpful visualizations and explanations.

JWT.IO#

jwt-io
jwt-io

While encoding the JWT, I observed that it utilizes the HS256 (HMAC_SHA256) algorithm along with a “kid” (Key ID) parameter.

The “kid” (key ID) claim is a string that signifies the key responsible for digitally signing the JWT.

If you’re interested in delving deeper into attacks involving the “kid” parameter in JWTs, you can find more information here: kid-parameter

Afterwards, I proceeded to modify the JWT by signing it with a particular secret key and conducting attacks on the JWT “kid” header, such as SQL injection and OS injection. Eventually, I identified a path traversal vulnerability in the “kid” header. I attempted to alter the “kid” header to “/dev/null” and sign the JWT with an empty secret key.

empty-sign
empty-sign

path-traversal
path-traversal

However, a complication arose: there seems to be a replace function or a similar mechanism in place that eliminates our ”../” sequences.

Yet, we can overcome this by using the pattern ....//....//....// to bypass the restriction and continue with our intended manipulation.

final_sol
final_sol

As a result of these efforts, we successfully obtained the flag!

flag
flag

have Fun 💜

Share Article

If this article helped you, please share it with others!

JWT - Unsecure File Signature (Root-Me): JWT Algorithm Confusion Attack
https://achux21.github.io/posts/jwt-unsecure-file-signature/
Author
ACHUX21
Published at
2024-02-20
License
CC BY-NC-SA 4.0
Profile Image of the Author
ACHUX21
CTF player & security researcher
Notice
CTF writeups and security research. New posts coming soon.
Music
Cover

Music

No playing

0:00 0:00
No lyrics available
Categories
Tags
Site Statistics
Posts
28
Categories
3
Tags
81
Total Words
26,137
Running Days
0 days
Last Activity
0 days ago

Table of Contents