๐ Token of Trust
A detailed write-up of the Web challenge 'Token of Trust' from ACECTF1.0 - 2025
๐ Challenge Overview
Category Details Additional Info ๐ Event ACECTF - 2025 Event Link ๐ฐ Category Web ๐ ๐ Points 200 Out of 500 total โญ Difficulty ๐ข Easy Personal Rating: 1/10 ๐ค Author Unknown Profile ๐ฎ Solves (At the time of writeup writing) 113 solve rate ๐ Date 27-02-2025 ACECTF - 2025 ๐ฆพ Solved By mH4ck3r0n3 Team: QnQSec
๐ Challenge Information
At first, this web app seems straightforward, but thereโs something more lurking beneath the surface. It relies on a token for user authentication, but not everything is as secure as it seems. Look closely, and you might discover that the systemโs trust can be manipulated. The secret is hidden within the way this token is used. Can you find the key to unlock whatโs been concealed? The challenge is waiting for you to crack it. Submit your answer in the following format: ACECTF{3x4mpl3_fl4g}. http://34.131.133.224:9999/
๐ฏ Challenge Files & Infrastructure
Provided Files
1Files: None
๐ Initial Analysis
First Steps
Initially, the website appears as follows:
We are told to log in to the
/loginroute with a POST request, but even so, it’s always better to try with a GET request.In fact, as we can see from the GET request, I was able to extract the
userandpassfields. Additionally, we are told that regardless of the credentials we send, just following the request format is enough to access. By openingBurpSuite, intercepting the request, and forming a POST with the fields in the JSON format I just found, I was able to receive atokenas a response:Most likely, it is a
jwt, so I immediately tried to analyze it with https://jwt.io:As we can see from the analysis, the
HS256algorithm is used for the signature, and the payload is"user":"guest". In the case of theHS256algorithm, the vulnerability to exploit is most likely anAlgorithm Confusion, perhaps by setting the algorithm toNoneor performing asecret crackingto craft the token with the cracked secret key. (By runningjwt-crackerwith therockyou.txtwordlist, I did not find any occurrences, so I decided to proceed withAlgorithm Confusion). Let’s move on to the exploitation.
๐ฌ Vulnerability Analysis
Potential Vulnerabilities
- JWT None Algorithm Supported
๐ฏ Solution Path
Exploitation Steps
Initial setup
First of all, when specifying the
Nonealgorithm, thesignatureof thejwt(the part after the last dot) must be removed. So we initially have:
1eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ1c2VyIjoiZ3Vlc3QifQ.JT3l4_NkVbkQuZpl62b9h8NCZ3cTcypEGZ1lULWR47MAfter removing the signature:
1eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ1c2VyIjoiZ3Vlc3QifQ.(Attention not to remove the last
.since removing it would make thejwtformat invalid, knowing that it consists ofheader.payload.signature). Once this is done, there are many ways to modify the fields of thejwt, for example by doingbase64decode, changing the field, and then re-encoding it to assemble the token. Alternatively, you can use the fasterjwt-tool. Let’s proceed with the exploitation phase.
Exploitation
Once the signature is removed, we can pass the token to
jwt-tooland specify the-T(Tamper) flag to modify the fields of thejwtprovided:
1python /home/mh4ck3r0n3/Tools/Web/jwt_tool/jwt_tool.py -T eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ1c2VyIjoiZ3Vlc3QifQ.As we can see, I changed
alg:Noneanduser:admin, generating a validadmintoken. Now, with the valid token:
1eyJhbGciOiJOb25lIiwidHlwIjoiSldUIn0.eyJ1c2VyIjoiYWRtaW4ifQ.The last thing we need to figure out is which route to send it to in order to get the flag, since sending it to
/loginor/will return an error in the first case (due to the expecteduserandpassfields) and aNot Modifiedstatus code in the second case, indicating we’re not on the right track. So, I decided to inspect therobots.txtfile to see if it contains any route:In fact, as we can see, the
/flagroute is specified. I tried making anOPTIONSrequest with curl:
1curl -X OPTIONS http://34.131.133.224:9999/flagI get that the only available method is
POST. So, I assume the new token needs to be forwarded in ajsonpayload, exactly as we received it during theloginphase. Indeed, by making aPOSTrequest to/flagset up in the way just mentioned, I was able to obtain the flag.
Flag capture
๐ ๏ธ Exploitation Process
Approach
The automated exploit makes a
POSTrequest to/loginto extract theJWTtoken, then removes the signature and setsalgtoNoneandusertoadmin. After that, it makes aPOSTrequest to/flagwith the forged token and extracts the flag from the response.
๐ฉ Flag Capture
Flag
Proof of Execution
๐ง Tools Used
Tool Purpose Python Exploit Jwt-Tool JWT Testing Burpsuite Web Testing
๐ก Key Learnings
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:04 | From start to flag |
| Global Ranking (At the time of writeup writing) | 4/468 | Challenge ranking |
| Points Earned | 200 | Team contribution |
Created: 27-02-2025 โข Last Modified: 27-02-2025 Author: mH4ck3r0n3 โข Team: QnQSec