Back to list

JWT Authentication Bypass via Flawed Signature Verification

Description

JWT vulnerabilities typically arise due to flawed JWT handling within the application itself. The various specifications related to JWTs are relatively flexible by design, allowing website developers to decide many implementation details for themselves. This can result in them accidentally introducing vulnerabilities even when using battle-hardened libraries. These implementation flaws usually mean that the signature of the JWT is not verified properly. This enables an attacker to tamper with the values passed to the application via the token's payload. Even if the signature is robustly verified, whether it can truly be trusted relies heavily on the server's secret key remaining a secret. If this key is leaked in some way, or can be guessed or brute-forced, an attacker can forge tokens or modify existing tokens to bypass authentication.

Remediation

Implement strict JWT signature verification using robust, well-maintained libraries. Ensure that algorithms such as 'none' or weaker hashing methods are not allowed. Store your secret keys securely—avoid committing them to source control or using guessable values. Regularly rotate keys if feasible, and enforce strong complexity requirements to protect against brute-force attacks. Verify the claims within the token (e.g., issuer, audience, expiration) to prevent tampering. Additionally, maintain server-side controls to promptly invalidate tokens when needed. Perform ongoing security reviews and testing to confirm that no flaws exist in JWT handling and signature verification.

References

https://owasp.org/www-community/attacks/JSON_Web_Token_(JWT)_Security_Cheat_Sheethttps://auth0.com/docs/secure/tokens/json-web-tokens

Severity

HIGH

Owasp

Code: A07:2021

Category: Identification and Authentication Failures

Classification

CWE-347
CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:H/I:H/A:N

8.2

CVSS:4.0/AV:N/AC:L/PR:N/UI:N/S:U/C:H/I:H/A:N

8.2