CVE-2014-3593
Luci 0.26.0: Eval injection vulnerability, remote authenticated users execute Python code via crafted cluster config
- CVSS 6.0
- CWE-94 Improper Control of Generation of Code ('Code Injection')
- Input Validation and Sanitization
- Remote
Eval injection vulnerability in luci 0.26.0 allows remote authenticated users with certain permissions to execute arbitrary Python code via a crafted cluster configuration.
- CVSS base score
- 6.0
- Published
- 2014-10-15
- OWASP
- A03 Injection
- Orthogonal defect classification
- Function
- Code defect classification
- Incorrect Functionality
- Category
- Input Validation and Sanitization
- Subcategory
- Insecure Parsing or Deserialization
- Accessibility scope
- Remote
- Impact
- Arbitrary Code Execution
- Affected component
- Python
- Fixed by upgrading
- Yes
Solution
Update luci to version 0.26.1 or higher.
Vulnerable code sample
# Example of code before the fix for CVE-2014-3593, demonstrating eval vulnerability
def execute_user_code(user_input):
# Directly using eval on user input, which is vulnerable
try:
result = eval(user_input)
return result
except Exception as e:
return str(e)
# Example usage
user_input_safe = "2 + 2" # Safe input
print(execute_user_code(user_input_safe))
user_input_unsafe = "__import__('os').system('ls')" # Unsafe input
print(execute_user_code(user_input_unsafe)) # This could execute arbitrary codePatched code sample
# Example of a fix for CVE-2014-3593 by sanitizing input before evaluation
import ast
def safe_eval(user_input):
# Only allow certain nodes in the AST
allowed_nodes = {
ast.Expression,
ast.Num,
ast.Str,
ast.List,
ast.Tuple,
ast.Dict,
ast.NameConstant,
ast.UnaryOp,
ast.BinOp,
ast.Compare,
ast.BoolOp,
ast.IfExp,
ast.Call,
ast.Attribute,
ast.Subscript,
}
# Parse the input into an AST
tree = ast.parse(user_input, mode='eval')
# Check if all nodes in the AST are allowed
for node in ast.walk(tree):
if type(node) not in allowed_nodes:
raise ValueError("Unsafe expression")
# Safely evaluate the sanitized AST
return eval(compile(tree, filename='', mode='eval'))
# Example usage
try:
result = safe_eval("2 + 2") # Safe input
print(result)
except ValueError as e:
print(e)
try:
result = safe_eval("__import__('os').system('ls')") # Unsafe input
print(result)
except ValueError as e:
print(e)Cite this entry
@misc{vaitp:cve20143593,
title = {{Luci 0.26.0: Eval injection vulnerability, remote authenticated users execute Python code via crafted cluster config}},
author = {Bogaerts, Fr\'ed\'eric and Ivaki, Naghmeh and Fonseca, Jos\'e},
year = {2014},
note = {VAITP Python Vulnerability Dataset, entry CVE-2014-3593},
howpublished = {\url{https://netpack.pt/vaitp/vulnerability/CVE-2014-3593/}}
}
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 ::
