VAITP Dataset

← Back to the dataset

CVE-2022-0718

Python-oslo-utils exposes plaintext passwords in debug logs when they contain a double quote

  • CVSS 4.9
  • CWE-532
  • Input Validation and Sanitization
  • Remote

A flaw was found in python-oslo-utils. Due to improper parsing, passwords with a double quote ( " ) in them cause incorrect masking in debug logs, causing any part of the password after the double quote to be plaintext.

CVSS base score
4.9
Published
2022-08-29
OWASP
A09 Security Logging and Monitoring Failures
Orthogonal defect classification
Function
Code defect classification
Incorrect Functionality
Category
Input Validation and Sanitization
Subcategory
Insecure Parsing or Deserialization
Accessibility scope
Remote
Impact
Information Disclosure
Affected component
python-oslo-utils
Fixed by upgrading
Yes

Solution

Update python-oslo-utils to a version that fixes the parsing issue.

Vulnerable code sample

import logging

def mask_password(password):
    # Improperly masking the password, which leads to a vulnerability
    # Only masking part of the password if it contains a double quote
    if '"' in password:
        return password.split('"')[0] + '*' * (len(password) - len(password.split('"')[0]))
    else:
        return '*' + password[1:]

def log_credentials(username, password):
    # Log the username and improperly masked password
    logging.debug(f"Username: {username}, Password: {mask_password(password)}")

# Example usage
log_credentials('user1', 'mypassword"secret')
log_credentials('user2', 'mypassword')

Patched code sample

import logging

def mask_password(password):
    # Properly mask the password to avoid exposing it in logs
    if '"' in password:
        # Mask the entire password if it contains a double quote
        return '*' * len(password)
    else:
        # Mask only the first character for demonstration purposes
        return '*' + password[1:]

def log_credentials(username, password):
    # Log the username and masked password
    logging.debug(f"Username: {username}, Password: {mask_password(password)}")

# Example usage
log_credentials('user1', 'mypassword"secret')
log_credentials('user2', 'mypassword')

Cite this entry

@misc{vaitp:cve20220718,
  title        = {{Python-oslo-utils exposes plaintext passwords in debug logs when they contain a double quote}},
  author       = {Bogaerts, Fr\'ed\'eric and Ivaki, Naghmeh and Fonseca, Jos\'e},
  year         = {2022},
  note         = {VAITP Python Vulnerability Dataset, entry CVE-2022-0718},
  howpublished = {\url{https://netpack.pt/vaitp/vulnerability/CVE-2022-0718/}}
}

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.