VAITP Dataset

← Back to the dataset

CVE-2020-26244

OpenID Connect Python oic < 1.2.1: IdToken issues – missing signature checks, 'none' algorithm, unverified IdTokens, unchecked 'iat' claims

  • CVSS 6.8
  • CWE-347
  • Cryptographic
  • Remote

Python oic is a Python OpenID Connect implementation. In Python oic before version 1.2.1, there are several related cryptographic issues affecting client implementations that use the library. The issues are: 1) The IdToken signature algorithm was not checked automatically, but only if the expected algorithm was passed in as a kwarg. 2) JWA `none` algorithm was allowed in all flows. 3) oic.consumer.Consumer.parse_authz returns an unverified IdToken. The verification of the token was left to the discretion of the implementator. 4) iat claim was not checked for sanity (i.e. it could be in the future). These issues are patched in version 1.2.1.

CVSS base score
6.8
Published
2020-12-02
OWASP
A02 Cryptographic Failures
Orthogonal defect classification
Function
Code defect classification
Incorrect Functionality
Category
Cryptographic
Subcategory
Cryptographic Implementation Error
Accessibility scope
Remote
Impact
Information Disclosure
Affected component
oic
Fixed by upgrading
Yes

Solution

Update Python oic to version 1.2.1 or higher.

Vulnerable code sample

from oic import oic
from oic.oauth2 import Client
from oic.utils.keyio import KeyJar

class VulnerableConsumer(oic.consumer.Consumer):
    def parse_authz(self, authz_response):
        # No automatic checking of IdToken signature algorithm
        id_token = authz_response['id_token']

        # Allow 'none' algorithm
        if id_token['alg'] == 'none':
            print("Warning: IdToken signature algorithm is 'none'")

        # Return unverified IdToken
        return id_token

# Example usage
client = Client(client_id='your_client_id', client_secret='your_client_secret')
consumer = VulnerableConsumer(client)
authz_response = {
    'id_token': {
        'alg': 'none',  # Vulnerable to accepting 'none' algorithm
        'iat': 1609459200  # Example iat claim
    }
}
id_token = consumer.parse_authz(authz_response)
print("Parsed IdToken:", id_token)

Patched code sample

from oic import oic
from oic.oauth2 import Client
from oic.utils.keyio import KeyJar
from oic.utils.authn import ClientSecretBasic
from oic.utils.time_util import utc_now

class SecureConsumer(oic.consumer.Consumer):
    def parse_authz(self, authz_response):
        # Ensure the IdToken signature algorithm is checked
        if 'alg' not in authz_response['id_token']:
            raise ValueError("Missing 'alg' in IdToken")
        
        expected_alg = 'RS256'  # Example expected algorithm
        if authz_response['id_token']['alg'] != expected_alg:
            raise ValueError(f"Unexpected IdToken signature algorithm: {authz_response['id_token']['alg']}")

        # Reject 'none' algorithm
        if authz_response['id_token']['alg'] == 'none':
            raise ValueError("IdToken signature algorithm 'none' is not allowed")

        # Verify the IdToken
        id_token = authz_response['id_token']
        if not self.verify_id_token(id_token):
            raise ValueError("IdToken verification failed")

        # Check iat claim for sanity
        if 'iat' in id_token:
            if id_token['iat'] > utc_now():
                raise ValueError("iat claim is in the future")

        return id_token

    def verify_id_token(self, id_token):
        # Implement actual verification logic here

Published fix

Public sources link this CVE to the changes below. The code samples above were generated to illustrate the defect; these links lead to the code the project actually changed.

Cite this entry

@misc{vaitp:cve202026244,
  title        = {{OpenID Connect Python oic < 1.2.1: IdToken issues - missing signature checks, 'none' algorithm, unverified IdTokens, unchecked 'iat' claims}},
  author       = {Bogaerts, Fr\'ed\'eric and Ivaki, Naghmeh and Fonseca, Jos\'e},
  year         = {2020},
  note         = {VAITP Python Vulnerability Dataset, entry CVE-2020-26244},
  howpublished = {\url{https://netpack.pt/vaitp/vulnerability/CVE-2020-26244/}}
}

Download this entry as JSON Download the whole dataset

Introducing the "VAITP dataset": a specialized repository of Python vulnerabilities and patches, meticulously compiled for the use of the security research community. As Python's prominence grows, understanding and addressing potential security vulnerabilities become crucial. Crafted by and for the cybersecurity community, this dataset offers a valuable resource for researchers, analysts, and developers to analyze and mitigate the security risks associated with Python. Through the comprehensive exploration of vulnerabilities and corresponding patches, the VAITP dataset fosters a safer and more resilient Python ecosystem, encouraging collaborative advancements in programming security.

The supreme art of war is to subdue the enemy without fighting.

Sun Tzu – “The Art of War”

:: Shaping the future through research and ingenuity ::

Before you use the VAITP AI models

Please read and accept the following disclaimer:

By choosing "I understand and accept", you acknowledge that you understand and agree to these terms.