CVE-2020-13144
Arbitrary code execution in Open edX Ironwood 2.5 without CodeJail: Critical security flaw
- CVSS 8.8
- CWE-94 Improper Control of Generation of Code ('Code Injection')
- Input Validation and Sanitization
- Remote
Studio in Open edX Ironwood 2.5, when CodeJail is not used, allows a user to go to the "Create New course>New section>New subsection>New unit>Add new component>Problem button>Advanced tab>Custom Python evaluated code" screen, edit the problem, and execute Python code. This leads to arbitrary code execution.
- CVSS base score
- 8.8
- Published
- 2020-05-18
- 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
- Open edX
- Fixed by upgrading
- Yes
Solution
Update Open edX to a version that fixes the vulnerability.
Vulnerable code sample
def execute_user_code(user_code):
# This function demonstrates the vulnerability by executing arbitrary user-provided code
# without any restrictions, leading to potential arbitrary code execution.
exec(user_code) # Dangerous: executes any code passed to it
# Example usage
user_code = "import os; os.system('echo Vulnerable!')" # This could execute arbitrary commands
execute_user_code(user_code)Patched code sample
import os
import subprocess
def execute_user_code(user_code):
# This function is designed to prevent arbitrary code execution by
# restricting the execution environment and not allowing arbitrary code.
# Using CodeJail or a similar sandboxing solution is recommended.
# Example of a secure execution environment using subprocess with limited capabilities
try:
# Create a restricted environment
restricted_env = {
'PATH': '/usr/bin', # Limit the PATH to only necessary binaries
'PYTHONUNBUFFERED': '1', # Ensure output is flushed
}
# Execute the user code in a restricted environment
# Here we would typically use a sandboxing library like CodeJail
# For demonstration, we'll just show how to call a subprocess safely
result = subprocess.run(
['python3', '-c', user_code],
env=restricted_env,
capture_output=True,
text=True,
timeout=5 # Limit execution time to prevent infinite loops
)
if result.returncode == 0:
return result.stdout # Return the output if execution was successful
else:
return f"Error: {result.stderr}" # Return the error if execution failed
except Exception as e:
return f"Execution failed: {str(e)}"
# Example usage
user_code = "print('Hello, World!')" # This should be sanitized and validatedCite this entry
@misc{vaitp:cve202013144,
title = {{Arbitrary code execution in Open edX Ironwood 2.5 without CodeJail: Critical security flaw}},
author = {Bogaerts, Fr\'ed\'eric and Ivaki, Naghmeh and Fonseca, Jos\'e},
year = {2020},
note = {VAITP Python Vulnerability Dataset, entry CVE-2020-13144},
howpublished = {\url{https://netpack.pt/vaitp/vulnerability/CVE-2020-13144/}}
}
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 ::
