The get_decoded_jwt_token() method in OAuth2ClientBase was decoding
JWT tokens with verify=False and verify_signature=False, allowing
an attacker to forge tokens with arbitrary claims (e.g. user identity
via the 'sub' claim).
This is a critical authentication bypass since the method is called
from permissions.py to authenticate users via get_user_from_oauth2().
Fix: When OAUTH2_PROVIDER_PUBLIC_KEY is configured, verify the JWT
signature using the provider's RSA public key before trusting claims.
When no key is configured, log a security warning to alert operators.
Also removes the deprecated 'verify' parameter (replaced by 'options'
in PyJWT >= 2.0).
CWE-347: Improper Verification of Cryptographic Signature
CVSS: High (authentication bypass)
Summary
The get_decoded_jwt_token() method in OAuth2ClientBase decodes JWT tokens with verify=False and options={"verify_signature": False}, allowing an attacker to forge tokens with arbitrary claims.
Security Impact
CWE-347: Improper Verification of Cryptographic Signature
This is a critical authentication bypass vulnerability. The unverified JWT decode is called from:
An attacker can craft a JWT with an arbitrary sub claim (pointing to any user) and an exp claim far in the future. Since the signature is never verified, the application will accept the forged token and authenticate the attacker as any user.
Note: The KeycloakDiffgramClient.verify_token() already properly verifies JWT signatures using the provider's public key — this fix brings the same verification to the base class method used in the permissions flow.
Fix
When OAUTH2_PROVIDER_PUBLIC_KEY is configured:
When no public key is configured:
Also removes the deprecated verify parameter (replaced by options dict in PyJWT >= 2.0).
Testing