JWT Attacks in 2025: alg=none Is Gone, But These Aren't
The alg=none bug is mostly gone — modern JWT libraries reject it by default and have for years. But the JWT attack surface did not shrink as much as it should have. Here are the attacks that still work in 2026.
APIs · By Thimmagurudu Bathini · Published · 6 min read · Last reviewed
Algorithm confusion (HS256 vs RS256)
If a library accepts the algorithm from the JWT header without verifying it against the expected algorithm, an attacker can craft a token with alg: HS256 and sign it with the server's RSA public key (which is, by definition, public). The library validates the HMAC using the public key as the secret — and the token passes. Old bug, still found in 2025.
kid header injection
The kid (key ID) header tells the server which key to use. If the server uses kid to look up the key in a database, in the file system, or via HTTP, the kid is an injection vector. SQLi via kid, LFI via kid, SSRF via kid — all real findings.
Weak HMAC secrets
HS256 with a short or guessable secret is crackable offline. Values such as secret, changeme, jwtsecret, the application name or the environment name turn up in real tokens.
JWE algorithm confusion
JWE adds another whole layer of alg + enc negotiation, and most libraries are even less strict about validating it than the JWS side. The 2023 ECDH-ES key reuse attacks (Curve25519 vs P-256) are still finding their way into libraries.
Defenses
Pin the algorithm explicitly in the verifier (verify(token, key, {algorithms: ["RS256"]})). Strong secrets only — 256 bits of entropy minimum for HS256. Validate kid against an allowlist, never look up against user-controlled data. Short expiry, refresh tokens with rotation, server-side revocation for high-value sessions.
See API security testing.
Written by Thimmagurudu Bathini, BERRY9 IT SERVICES PRIVATE LIMITED, Hyderabad. Questions about your own systems? Request a scoping call or call +91 86868 92922.
Plan your next security test
Tell us what needs testing and when you need it done, and we will propose a scope and timeline. We respond within 24 hours. If you would rather talk first, call or write to us.
- +91 86868 92922
- contact@berry9.com
- H.No: 8-3-945/A/12 & 13, Sri Venkata Sai Nest Apartments, Nagarjuna Nagar Colony, Yellareddyguda, Hyderabad 500073, Telangana