VAITP Dataset

← Back to the dataset

CVE-2023-26112

configobj package: Vulnerable to ReDoS in validate function with the pattern (.+?)(.∗)(.∗)

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

All versions of the package configobj are vulnerable to Regular Expression Denial of Service (ReDoS) via the validate function, using (.+?)\((.*)\).

CVSS base score
5.9
Published
2023-04-03
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
configobj
Fixed by upgrading
Yes

Solution

Update configobj package to a non-vulnerable version.

Vulnerable code sample

import re

def validate(input_string):
    # Vulnerable regex pattern that can lead to ReDoS
    pattern = r'(.+?)\((.*)\)'
    if re.match(pattern, input_string):
        return True
    return False

# Example usage
print(validate("valid_input(param)"))  # True
print(validate("invalid_input("))  # False

Patched code sample

import re

def validate(input_string):
    # Fixed the regex to avoid catastrophic backtracking
    pattern = r'^[^\(\)]+(\([^\(\)]+\))?$'
    if re.match(pattern, input_string):
        return True
    return False

# Example usage
print(validate("valid_input"))  # True
print(validate("valid_input(param)"))  # True
print(validate("invalid_input("))  # False

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:cve202326112,
  title        = {{configobj package: Vulnerable to ReDoS in validate function with the pattern (.+?)(.∗)(.∗)}},
  author       = {Bogaerts, Fr\'ed\'eric and Ivaki, Naghmeh and Fonseca, Jos\'e},
  year         = {2023},
  note         = {VAITP Python Vulnerability Dataset, entry CVE-2023-26112},
  howpublished = {\url{https://netpack.pt/vaitp/vulnerability/CVE-2023-26112/}}
}

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.