CVE-2020-29396
Sandboxing flaw in Odoo 11.0-13.0 enables remote authenticated users to execute arbitrary code for privilege escalation
- CVSS 8.8
- CWE-267 Privilege Defined With Unsafe Actions
- Authentication, Authorization, and Session Management
- Remote
A sandboxing issue in Odoo Community 11.0 through 13.0 and Odoo Enterprise 11.0 through 13.0, when running with Python 3.6 or later, allows remote authenticated users to execute arbitrary code, leading to privilege escalation.
- CVSS base score
- 8.8
- Published
- 2020-12-22
- OWASP
- A08 Software and Data Integrity Failures
- Orthogonal defect classification
- Function
- Code defect classification
- Incorrect Functionality
- Category
- Authentication, Authorization, and Session Management
- Subcategory
- Privilege Escalation
- Accessibility scope
- Remote
- Impact
- Arbitrary Code Execution
- Affected component
- Python
- Fixed by upgrading
- Yes
Solution
Update Odoo to a version higher than 13.0.
Vulnerable code sample
# Example of vulnerable code that allows arbitrary code execution
def execute_user_code(code):
# Directly executing user-provided code without any restrictions
exec(code)
# Example usage
user_code = "__import__('os').system('whoami')" # This is user-provided code
execute_user_code(user_code)Patched code sample
# Example of fixing the sandboxing issue in Odoo
import ast
import logging
# Create a safe environment for the code execution
def safe_exec(code, globals=None, locals=None):
# Restrict the available built-ins and functions
safe_builtins = {
'print': print,
# Add other safe built-ins as needed
}
# Create a restricted environment
if globals is None:
globals = {}
if locals is None:
locals = {}
# Use ast.literal_eval to safely evaluate expressions
try:
# Only allow safe expressions to be executed
code_ast = ast.parse(code, mode='exec')
for node in ast.walk(code_ast):
if isinstance(node, (ast.Import, ast.ImportFrom)):
raise ValueError("Imports are not allowed.")
if isinstance(node, ast.Call) and not isinstance(node.func, ast.Name) or node.func.id not in safe_builtins:
raise ValueError("Unsafe function call detected.")
exec(compile(code_ast, filename="<ast>", mode="exec"), {**globals, **safe_builtins}, locals)
except Exception as e:
logging.error(f"Error executing code: {e}")
# Example usage
user_code = "print('Hello, World!')" # This is user-provided code
safe_exec(user_code)Cite this entry
@misc{vaitp:cve202029396,
title = {{Sandboxing flaw in Odoo 11.0-13.0 enables remote authenticated users to execute arbitrary code for privilege escalation}},
author = {Bogaerts, Fr\'ed\'eric and Ivaki, Naghmeh and Fonseca, Jos\'e},
year = {2020},
note = {VAITP Python Vulnerability Dataset, entry CVE-2020-29396},
howpublished = {\url{https://netpack.pt/vaitp/vulnerability/CVE-2020-29396/}}
}
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 ::
