HackTheBox - Principal
Why It Matters
A single null‑check oversight can let attackers forge admin tokens and gain root, highlighting the urgent need for strict JWT validation and protected SSH CAs in production environments.
Key Takeaways
- •CVE‑2024‑XXXX in JJWT allows unsigned JWT validation to bypass authentication
- •SSH service accepts signed keys from unprotected CA, enabling root login
- •Attacker crafts 'none' algorithm JWT using public JWKS endpoint
- •Exploiting JWT flaw grants admin role, revealing service account passwords
- •Lesson: never trust unsigned tokens; enforce strict algorithm validation
Summary
The HackTheBox "Principal" machine centers on a freshly disclosed CVE 2024‑XXXX in the JJWT Java library, which mistakenly skips signature verification when a JWT’s signature field is null. Combined with an SSH daemon that trusts keys signed by an unprotected Certificate Authority, the box offers a textbook chain of privilege‑escalation exploits.
The vulnerability stems from a null‑check that returns early instead of validating the JWT signature, allowing an attacker to submit a token with "alg":"none" and forge any claims. By querying the public JWKS endpoint, the researcher extracts the RSA public key, crafts a token with admin privileges, and injects it via session storage. The forged token bypasses the login API, reveals a service‑account password, and, thanks to the lax SSH CA, grants root SSH access.
Key moments include the observation that "algorithm set to none" is usually unrealistic, yet the library’s bug makes it viable, and the developer’s comment that the null check prevents a server crash but opens a security hole. The exploit script demonstrates building the JWT manually, adjusting the "role" claim to "RO_admin", and using the token to access the dashboard and extract credentials.
The case underscores the critical need for strict JWT validation—rejecting "none" algorithms outright—and for securing SSH CA private keys. Organizations running Java web services must audit their JWT handling logic and ensure certificate authorities are properly locked down to prevent similar privilege‑escalation pathways.
Comments
Want to join the conversation?
Loading comments...