#0803
JWT supports an 'alg: none' mode where no signature is required. An attacker can craft a token with any claims, set alg to 'none', and skip the signature entirely.
Your header validation function returns the algorithm without rejecting the 'none' value.
An attacker can forge admin tokens with zero cryptographic protection.
The alg:none vulnerability was present in multiple major JWT libraries (CVE-2015-9235 and similar). It completely bypasses signature verification, letting attackers forge arbitrary tokens.
validateTokenHeader({alg:'none',typ:'JWT'})// Returns {algorithm:'none'} — should have thrown!
validateTokenHeader({alg:'HS256',typ:'JWT'})// Returns {algorithm:'HS256'}