VAITP Dataset

← Back to the dataset

CVE-2023-33290

Git-url-parse (Rust crate through 0.4.4) vulnerable to ReDos via crafted URL

  • CVSS 7.5
  • CWE-1333 Inefficient Regular Expression Complexity
  • Input Validation and Sanitization
  • Remote

The git-url-parse crate through 0.4.4 for Rust allows Regular Expression Denial of Service (ReDos) via a crafted URL to normalize_url in lib.rs, a similar issue to CVE-2023-32758 (Python).

CVSS base score
7.5
Published
2023-06-12
OWASP
A06 Vulnerable and Outdated Components
Orthogonal defect classification
Function
Code defect classification
Incorrect Functionality
Category
Input Validation and Sanitization
Subcategory
Insecure Parsing or Deserialization
Accessibility scope
Remote
Impact
Denial of Service (DoS)
Affected component
git-url-parse
Fixed by upgrading
Yes

Solution

Update git-url-parse crate to version 0.4.5 or higher.

Vulnerable code sample

import re

def normalize_url(url):
    # Vulnerable regex pattern that can cause ReDoS
    pattern = r'^(https?://)?(www\.)?([a-zA-Z0-9.-]+)(/.*)?$'
    
    # This regex can be exploited with crafted input
    match = re.match(pattern, url)
    if match:
        scheme = match.group(1) or 'http://'
        domain = match.group(3)
        path = match.group(4) or '/'
        return f"{scheme}{domain}{path}"
    else:
        raise ValueError("Invalid URL")

# Example usage
try:
    # Crafted input that could lead to ReDoS
    print(normalize_url("http://example.com/" + "a" * 10000 + "/path"))
except ValueError as e:
    print(e)

Patched code sample

import re

def normalize_url(url):
    # Use a more efficient regex pattern to avoid ReDoS
    pattern = r'^(https?://)?(www\.)?([^/]+)(/.*)?$'
    
    # Check if the URL matches the pattern
    match = re.match(pattern, url)
    if match:
        # Normalize the URL
        scheme = match.group(1) or 'http://'
        domain = match.group(3)
        path = match.group(4) or '/'
        return f"{scheme}{domain}{path}"
    else:
        raise ValueError("Invalid URL")

# Example usage
try:
    print(normalize_url("http://example.com/some/path"))
except ValueError as e:
    print(e)

Cite this entry

@misc{vaitp:cve202333290,
  title        = {{Git-url-parse (Rust crate through 0.4.4) vulnerable to ReDos via crafted URL}},
  author       = {Bogaerts, Fr\'ed\'eric and Ivaki, Naghmeh and Fonseca, Jos\'e},
  year         = {2023},
  note         = {VAITP Python Vulnerability Dataset, entry CVE-2023-33290},
  howpublished = {\url{https://netpack.pt/vaitp/vulnerability/CVE-2023-33290/}}
}

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.