CVE-2008-6954
Remote code execution via Cheetah kickstart template in Cobbler < 1.2.9
- CVSS 9.0
- CWE-264
- Input Validation and Sanitization
- Remote
The web interface (CobblerWeb) in Cobbler before 1.2.9 allows remote authenticated users to execute arbitrary Python code in cobblerd by editing a Cheetah kickstart template to import arbitrary Python modules.
- CWE
- CWE-264
- CVSS base score
- 9.0
- Published
- 2009-08-12
- OWASP
- A03 Injection
- Orthogonal defect classification
- Function
- Code defect classification
- Incorrect Functionality
- Category
- Input Validation and Sanitization
- Subcategory
- Command Injection
- Accessibility scope
- Remote
- Impact
- Arbitrary Code Execution
- Affected component
- Cobbler
- Fixed by upgrading
- Yes
Solution
Update Cobbler to version 1.2.9 or higher.
Vulnerable code sample
from Cheetah.Template import Template
class VulnerableTemplate(Template):
def execute(self):
# Arbitrary code execution through user-defined templates
user_code = self.user_code # Assume this comes from user input
exec(user_code) # Vulnerable to arbitrary code execution
# Usage example
template = VulnerableTemplate("your_template_string_here")
template.user_code = "import os; os.system('echo Vulnerable!')" # Example of user input
template.execute()Patched code sample
import os
import sys
from Cheetah.Template import Template
class SecureTemplate(Template):
def __init__(self, *args, **kwargs):
super(SecureTemplate, self).__init__(*args, **kwargs)
# Restrict the available Python modules
self.allowed_modules = ['os', 'sys', 'datetime'] # Example allowed modules
def safe_import(self, module_name):
if module_name in self.allowed_modules:
return __import__(module_name)
else:
raise ImportError(f"Importing module '{module_name}' is not allowed.")
def execute(self):
# Override the execute method to prevent arbitrary code execution
try:
# Example of using safe_import instead of __import__
os_module = self.safe_import('os')
# Continue with template rendering using allowed modules
# ...
except ImportError as e:
print(f"Error: {e}", file=sys.stderr)
# Usage example
template = SecureTemplate("your_template_string_here")
template.execute()Cite this entry
@misc{vaitp:cve20086954,
title = {{Remote code execution via Cheetah kickstart template in Cobbler < 1.2.9}},
author = {Bogaerts, Fr\'ed\'eric and Ivaki, Naghmeh and Fonseca, Jos\'e},
year = {2009},
note = {VAITP Python Vulnerability Dataset, entry CVE-2008-6954},
howpublished = {\url{https://netpack.pt/vaitp/vulnerability/CVE-2008-6954/}}
}
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 ::
