CVE-2019-7653
Debian python-rdflib-tools 4.2.2-1 allows code injection via CLI due to directory search vulnerability
- CVSS 9.8
- CWE-427 Uncontrolled Search Path Element
- Input Validation and Sanitization
- Local
The Debian python-rdflib-tools 4.2.2-1 package for RDFLib 4.2.2 has CLI tools that can load Python modules from the current working directory, allowing code injection, because "python -m" looks in this directory, as demonstrated by rdf2dot. This issue is specific to use of the debian/scripts directory.
- CVSS base score
- 9.8
- Published
- 2019-02-09
- OWASP
- A03 Injection
- 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
- Python
- Fixed by upgrading
- Yes
Solution
Update python-rdflib-tools to version 4.2.3 or higher.
Vulnerable code sample
import os
import sys
# This represents a vulnerable implementation that loads modules from the current working directory
def run_rdf_tool():
# The current working directory is included in the module search path
# This allows potential code injection from untrusted files in the current directory
from rdflib.tools.rdf2dot import main as rdf2dot_main
# Run the tool
rdf2dot_main()
if __name__ == "__main__":
run_rdf_tool()Patched code sample
import os
import sys
# Define a secure function to run the RDFLib tool
def run_rdf_tool():
# Ensure that the current working directory is not included in the module search path
original_cwd = os.getcwd()
try:
# Change to a safe directory
os.chdir('/safe/directory')
# Import the rdf2dot module securely
from rdflib.tools.rdf2dot import main as rdf2dot_main
# Run the tool
rdf2dot_main()
finally:
# Change back to the original working directory
os.chdir(original_cwd)
if __name__ == "__main__":
run_rdf_tool()Cite this entry
@misc{vaitp:cve20197653,
title = {{Debian python-rdflib-tools 4.2.2-1 allows code injection via CLI due to directory search vulnerability}},
author = {Bogaerts, Fr\'ed\'eric and Ivaki, Naghmeh and Fonseca, Jos\'e},
year = {2019},
note = {VAITP Python Vulnerability Dataset, entry CVE-2019-7653},
howpublished = {\url{https://netpack.pt/vaitp/vulnerability/CVE-2019-7653/}}
}
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 ::
