Writeup · 31 Nights of Root

The Archive Request

webeasysolvedFlag: r00t{REDACTED}

Overview

The challenge presents a public-records portal with a home page, a “File a Request” form (/requests/new), a “Staff Login” page (/admin), and a request tracker at /requests/<id>. The application uses JWT-based authentication with a kid header that is vulnerable to path traversal, allowing an attacker to point it at an attacker-controlled public key. Combined with JWT algorithm confusion (accepting RS256 but verifying with HS256 using the public key bytes as the HMAC secret), an attacker can forge a valid admin JWT.

Prerequisites / Setup

export TARGET="<challenge URL or IP>"

curl and python3 (with pyjwt) are sufficient; no wordlist or credentials are required.

Recon

Step 1 — Inspect the application

Goal: Confirm the application endpoints and authentication mechanism.

curl "$TARGET/"

The homepage reveals three endpoints: /, /requests/new, and /admin (Staff Login).

Vulnerability Analysis

The flaw classes are Path Traversal (CWE-22) and JWT Algorithm Confusion (improper authentication, CWE-287), leading to Authentication Bypass.

Exploitation

Step 2 — Forge an admin JWT

Goal: Generate an RSA key pair, host the public key, and forge a JWT with kid pointing to it and alg: RS256.

The application fetches the public key from the kid path and verifies the JWT using HS256 with the public key bytes as the HMAC secret. By hosting our own RSA public key at a path reachable via the kid traversal, we can sign a token with role: admin that the application will accept.

Step 3 — Access the staff queue

Goal: Use the forged admin JWT to access the internal priority queue and retrieve the flag.

Present the forged JWT to the staff login endpoint, then access /requests/<id> for the staff queue to obtain the flag.

Flag

r00t{REDACTED}

Retrieved from the staff queue after authenticating as admin via the forged JWT.

Lessons / Takeaways

  • Never use the kid header value directly in a filesystem path without validation.
  • Enforce JWT algorithm allow-lists server-side; never accept alg from the client.
  • Validate both the signature and the embedded authorization claims server-side.

Mitigations

  • Validate kid values against an allowlist of known key IDs; never use them directly in file paths.
  • Enforce a single expected JWT signing algorithm (RS256 or HS256) and reject algorithm confusion.
  • Verify JWT signatures using only trusted, server-controlled public keys.

Techniques

References