CVE-2021-41500
String comparison vulnerability in cvxopt.org <= 1.2.6 allows DoS via fake Capsule objects
- CVSS 7.5
- CWE-697 Incorrect Comparison
- Design Defects
- Remote
Incomplete string comparison vulnerability exits in cvxopt.org cvxop <= 1.2.6 in APIs (cvxopt.cholmod.diag, cvxopt.cholmod.getfactor, cvxopt.cholmod.solve, cvxopt.cholmod.spsolve), which allows attackers to conduct Denial of Service attacks by construct fake Capsule objects.
- CVSS base score
- 7.5
- Published
- 2021-12-17
- OWASP
- A06 Vulnerable and Outdated Components
- Orthogonal defect classification
- Function
- Code defect classification
- Incorrect Functionality
- Category
- Design Defects
- Subcategory
- Inadequate Error Handling
- Accessibility scope
- Remote
- Impact
- Denial of Service (DoS)
- Affected component
- cvxopt
- Fixed by upgrading
- Yes
Solution
Update cvxopt to version 1.2.7 or higher.
Vulnerable code sample
import cvxopt
def vulnerable_getfactor(capsule):
# Insecure comparison that could lead to vulnerabilities
if capsule != "expected_capsule":
raise ValueError("Invalid Capsule object.")
# Proceed with the operation
return cvxopt.cholmod.getfactor(capsule)
def vulnerable_solve(capsule, b):
# Insecure comparison that could lead to vulnerabilities
if capsule != "expected_capsule":
raise ValueError("Invalid Capsule object.")
# Proceed with the operation
return cvxopt.cholmod.solve(capsule, b)
def vulnerable_spsolve(capsule, b):
# Insecure comparison that could lead to vulnerabilities
if capsule != "expected_capsule":
raise ValueError("Invalid Capsule object.")
# Proceed with the operation
return cvxopt.cholmod.spsolve(capsule, b)
def vulnerable_diag(capsule):
# Insecure comparison that could lead to vulnerabilities
if capsule != "expected_capsule":
raise ValueError("Invalid Capsule object.")
# Proceed with the operation
return cvxopt.cholmod.diag(capsule)Patched code sample
import cvxopt
class SafeCapsule:
def __init__(self, data):
if not isinstance(data, (list, tuple)):
raise ValueError("Invalid data type for Capsule. Must be a list or tuple.")
self.data = data
def safe_getfactor(capsule):
if not isinstance(capsule, SafeCapsule):
raise ValueError("Invalid Capsule object.")
# Proceed with the operation safely
return cvxopt.cholmod.getfactor(capsule.data)
def safe_solve(capsule, b):
if not isinstance(capsule, SafeCapsule):
raise ValueError("Invalid Capsule object.")
# Proceed with the operation safely
return cvxopt.cholmod.solve(capsule.data, b)
def safe_spsolve(capsule, b):
if not isinstance(capsule, SafeCapsule):
raise ValueError("Invalid Capsule object.")
# Proceed with the operation safely
return cvxopt.cholmod.spsolve(capsule.data, b)
def safe_diag(capsule):
if not isinstance(capsule, SafeCapsule):
raise ValueError("Invalid Capsule object.")
# Proceed with the operation safely
return cvxopt.cholmod.diag(capsule.data)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.
- Update to 1.2.7 (#199) (cvxopt/cvxopt)
doc/source/conf.py
Cite this entry
@misc{vaitp:cve202141500,
title = {{String comparison vulnerability in cvxopt.org <= 1.2.6 allows DoS via fake Capsule objects}},
author = {Bogaerts, Fr\'ed\'eric and Ivaki, Naghmeh and Fonseca, Jos\'e},
year = {2021},
note = {VAITP Python Vulnerability Dataset, entry CVE-2021-41500},
howpublished = {\url{https://netpack.pt/vaitp/vulnerability/CVE-2021-41500/}}
}
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 ::
