VAITP Dataset

← Back to the dataset

CVE-2023-40267

GitPython < 3.1.32 has an insecure fix for , allowing insecure options in cloning

  • CVSS 9.8
  • CWE-285: Improper Authorization
  • Input Validation and Sanitization
  • Remote

GitPython before 3.1.32 does not block insecure non-multi options in clone and clone_from. NOTE: this issue exists because of an incomplete fix for CVE-2022-24439.

CVSS base score
9.8
Published
2023-08-11
OWASP
A06 Vulnerable and Outdated Components
Orthogonal defect classification
Function
Code defect classification
Incorrect Functionality
Category
Input Validation and Sanitization
Subcategory
Insecure Direct Object References (IDOR)
Accessibility scope
Remote
Impact
Unauthorized Access
Affected component
GitPython
Fixed by upgrading
Yes

Solution

Update GitPython to version 3.1.32 or higher.

Vulnerable code sample

import git

def insecure_clone(repo_url, destination, **kwargs):
    # No validation of non-multi options, allowing potentially insecure options
    git.Repo.clone_from(repo_url, destination, **kwargs)

# Example usage
insecure_clone('https://github.com/user/repo.git', '/path/to/destination', depth=10)

Patched code sample

import git

def safe_clone(repo_url, destination, **kwargs):
    # Block insecure non-multi options
    if 'depth' in kwargs and kwargs['depth'] != 1:
        raise ValueError("Insecure option 'depth' must be set to 1 for safety.")
    
    # Proceed with cloning
    git.Repo.clone_from(repo_url, destination, **kwargs)

# Example usage
try:
    safe_clone('https://github.com/user/repo.git', '/path/to/destination', depth=1)
except ValueError as e:
    print(e)

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:cve202340267,
  title        = {{GitPython < 3.1.32 has an insecure fix for , allowing insecure options in cloning}},
  author       = {Bogaerts, Fr\'ed\'eric and Ivaki, Naghmeh and Fonseca, Jos\'e},
  year         = {2023},
  note         = {VAITP Python Vulnerability Dataset, entry CVE-2023-40267},
  howpublished = {\url{https://netpack.pt/vaitp/vulnerability/CVE-2023-40267/}}
}

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.