CVE-2024-34062
Arbitrary code execution via non-boolean CLI arguments in tqdm.
- CVSS 4.8
- CWE-74
- Input Validation and Sanitization
- Local
tqdm is an open source progress bar for Python and CLI. Any optional non-boolean CLI arguments (e.g. `–delim`, `–buf-size`, `–manpath`) are passed through python's `eval`, allowing arbitrary code execution. This issue is only locally exploitable and had been addressed in release version 4.66.3. All users are advised to upgrade. There are no known workarounds for this vulnerability.
- CWE
- CWE-74
- CVSS base score
- 4.8
- Published
- 2024-05-03
- OWASP
- A01 Broken Access Control
- Orthogonal defect classification
- Function
- Code defect classification
- Incorrect Functionality
- Category
- Input Validation and Sanitization
- Subcategory
- Command Injection
- Accessibility scope
- Local
- Impact
- Arbitrary Code Execution
- Affected component
- tqdm
- Fixed by upgrading
- Yes
Solution
Upgrade to version 4.66.3 or later.
Vulnerable code sample
import sys
from tqdm import tqdm as original_tqdm
def tqdm(iterable, **kwargs):
"""Vulnerable function that demonstrates the security issue."""
for key, value in kwargs.items():
if key in ['--delim', '--buf-size', '--manpath']:
eval(value)
return original_tqdm(iterable, **kwargs)
if __name__ == "__main__":
for i in tqdm(range(10), desc="Processing", total=10, buf_size="os.system('echo Vulnerable!')"):
passPatched code sample
from tqdm import tqdm as original_tqdm
ALLOWED_KEYS = {'desc', 'total', 'ncols', 'mininterval', 'maxinterval'}
def tqdm(iterable, **kwargs):
"""Secure function that fixes the vulnerability."""
# SECURE: This version prevents command injection
kwargs = {k: v for k, v in kwargs.items() if k in ALLOWED_KEYS}
return original_tqdm(iterable, **kwargs)
if __name__ == "__main__":
for i in tqdm(range(10), desc="Processing", total=10, buf_size="os.system('echo Vulnerable!')"):
passPayload
"os.system('echo Vulnerable!')"
Cite this entry
@misc{vaitp:cve202434062,
title = {{Arbitrary code execution via non-boolean CLI arguments in tqdm.}},
author = {Bogaerts, Fr\'ed\'eric and Ivaki, Naghmeh and Fonseca, Jos\'e},
year = {2024},
note = {VAITP Python Vulnerability Dataset, entry CVE-2024-34062},
howpublished = {\url{https://netpack.pt/vaitp/vulnerability/CVE-2024-34062/}}
}
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 ::
