CVE-2008-6539
Static code injection in DeStar 0.2.2-5 lets authenticated users add admins and inject Python code via a crafted "pin" parameter
- CVSS 6.5
- CWE-94 Improper Control of Generation of Code ('Code Injection')
- Input Validation and Sanitization
- Remote
Static code injection vulnerability in user/settings/ in DeStar 0.2.2-5 allows remote authenticated users to add arbitrary administrators and inject arbitrary Python code into destar_cfg.py via a crafted pin parameter.
- CVSS base score
- 6.5
- Published
- 2009-03-30
- 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
- Python
- Fixed by upgrading
- Yes
Solution
Update DeStar to version 0.2.6 or higher.
Vulnerable code sample
class UserSettings:
def __init__(self):
self.admins = set()
def add_admin(self, username, pin):
# Vulnerable code: directly executing the pin as code
exec(f"self.admins.add('{username}') if '{pin}' == '1234' else None")
# Example usage
settings = UserSettings()
settings.add_admin("new_admin", "1234") # Valid pin, adds admin
settings.add_admin("malicious_user", "__import__('os').system('rm -rf /')") # Arbitrary code executionPatched code sample
# Example fix for CVE-2008-6539: Preventing static code injection in the settings
class UserSettings:
def __init__(self):
self.admins = set()
def add_admin(self, username, pin):
# Validate the pin before processing
if self.validate_pin(pin):
self.admins.add(username)
print(f"User {username} added as admin.")
else:
print("Invalid pin. Admin not added.")
def validate_pin(self, pin):
# Ensure the pin is a numeric string of a specific length
return isinstance(pin, str) and pin.isdigit() and len(pin) == 4
# Example usage
settings = UserSettings()
settings.add_admin("new_admin", "1234") # Valid pin
settings.add_admin("malicious_user", "abcd") # Invalid pin, won't addCite this entry
@misc{vaitp:cve20086539,
title = {{Static code injection in DeStar 0.2.2-5 lets authenticated users add admins and inject Python code via a crafted "pin" parameter}},
author = {Bogaerts, Fr\'ed\'eric and Ivaki, Naghmeh and Fonseca, Jos\'e},
year = {2009},
note = {VAITP Python Vulnerability Dataset, entry CVE-2008-6539},
howpublished = {\url{https://netpack.pt/vaitp/vulnerability/CVE-2008-6539/}}
}
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 ::
