VAITP Dataset

← Back to the dataset

CVE-2021-3572

Python-pip Mishandling Unicode separators in git references allows remote attackers to potentially install a different repository revision

  • CVSS 5.7
  • CWE-20 Improper Input Validation
  • Input Validation and Sanitization
  • Remote

A flaw was found in python-pip in the way it handled Unicode separators in git references. A remote attacker could possibly use this issue to install a different revision on a repository. The highest threat from this vulnerability is to data integrity. This is fixed in python-pip version 21.1.

CVSS base score
5.7
Published
2021-11-10
OWASP
A08 Software and Data Integrity Failures
Orthogonal defect classification
Function
Code defect classification
Incorrect Functionality
Category
Input Validation and Sanitization
Subcategory
Insecure Parsing or Deserialization
Accessibility scope
Remote
Impact
Data Theft
Affected component
python-pip
Fixed by upgrading
Yes

Solution

Update python-pip to version 21.1 or higher.

Vulnerable code sample

def install_package(git_url, reference):
    # Vulnerable code: does not sanitize the reference
    # This could allow an attacker to inject a Unicode separator
    print(f"Installing package from {git_url} at reference {reference}")

# Example usage
install_package("https://github.com/example/repo.git", "main\u2028branch")

Patched code sample

import re

def sanitize_git_reference(reference):
    # Remove any Unicode separator characters from the reference
    sanitized_reference = re.sub(r'[\u2028\u2029]', '', reference)
    return sanitized_reference

def install_package(git_url, reference):
    sanitized_reference = sanitize_git_reference(reference)
    # Proceed with the installation using the sanitized reference
    print(f"Installing package from {git_url} at reference {sanitized_reference}")

# Example usage
install_package("https://github.com/example/repo.git", "main\u2028branch")

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:cve20213572,
  title        = {{Python-pip Mishandling Unicode separators in git references allows remote attackers to potentially install a different repository revision}},
  author       = {Bogaerts, Fr\'ed\'eric and Ivaki, Naghmeh and Fonseca, Jos\'e},
  year         = {2021},
  note         = {VAITP Python Vulnerability Dataset, entry CVE-2021-3572},
  howpublished = {\url{https://netpack.pt/vaitp/vulnerability/CVE-2021-3572/}}
}

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.