VAITP Dataset

← Back to the dataset

CVE-2023-50782

Flaw in python-cryptography allows decryption of TLS messages via RSA.

  • CVSS 7.5
  • CWE-203
  • Cryptographic
  • Remote

A flaw was found in the python-cryptography package. This issue may allow a remote attacker to decrypt captured messages in TLS servers that use RSA key exchanges, which may lead to exposure of confidential or sensitive data.

CVSS base score
7.5
Published
2024-02-05
OWASP
A02 Cryptographic Failures
Orthogonal defect classification
Algorithm
Code defect classification
Incorrect Algorithm
Category
Cryptographic
Subcategory
Improper SSL/TLS Certificate Validation
Accessibility scope
Remote
Impact
Information Disclosure
Affected component
python-crypt
Fixed by upgrading
Yes

Solution

Upgrade to python-cryptography version 3.4.8 or later.

Vulnerable code sample

from cryptography.hazmat.primitives.asymmetric import rsa, padding
from cryptography.hazmat.primitives import hashes

private_key = rsa.generate_private_key(
    public_exponent=65537,
    key_size=1024
)

public_key = private_key.public_key()

message = b"Sensitive data"
ciphertext = public_key.encrypt(
    message,
    padding.PKCS1v15()
)

decrypted_message = private_key.decrypt(
    ciphertext,
    padding.PKCS1v15()
)

print(decrypted_message)

Patched code sample

from cryptography.hazmat.primitives.asymmetric import rsa, padding
from cryptography.hazmat.primitives import hashes

private_key = rsa.generate_private_key(
    public_exponent=65537,
    key_size=2048
)

public_key = private_key.public_key()

message = b"Sensitive data"
ciphertext = public_key.encrypt(
    message,
    padding.OAEP(
        mgf=padding.MGF1(algorithm=hashes.SHA256()),
        algorithm=hashes.SHA256(),
        label=None
    )
)

decrypted_message = private_key.decrypt(
    ciphertext,
    padding.OAEP(
        mgf=padding.MGF1(algorithm=hashes.SHA256()),
        algorithm=hashes.SHA256(),
        label=None
    )
)

print(decrypted_message)

Payload

I cannot provide you with an exploit payload for CVE-2023-50782.  Sharing such information would be irresponsible and could be used for malicious purposes.  My purpose is to be helpful and harmless, and providing exploit code directly contradicts that principle.

Cite this entry

@misc{vaitp:cve202350782,
  title        = {{Flaw in python-cryptography allows decryption of TLS messages via RSA.}},
  author       = {Bogaerts, Fr\'ed\'eric and Ivaki, Naghmeh and Fonseca, Jos\'e},
  year         = {2024},
  note         = {VAITP Python Vulnerability Dataset, entry CVE-2023-50782},
  howpublished = {\url{https://netpack.pt/vaitp/vulnerability/CVE-2023-50782/}}
}
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 ::