VAITP Dataset

← Back to the dataset

CVE-2012-5493

Remote authenticated user bypasses Python sandbox to execute arbitrary code in Plone < 4.2.3 and < 4.3 beta 1

  • CVSS 8.5
  • CWE-94 Improper Control of Generation of Code ('Code Injection')
  • Input Validation and Sanitization
  • Remote

gtbn.py in Plone before 4.2.3 and 4.3 before beta 1 allows remote authenticated users with certain permissions to bypass the Python sandbox and execute arbitrary Python code via unspecified vectors.

CVSS base score
8.5
Published
2014-09-30
OWASP
A08 Software and Data Integrity Failures
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
Plone
Fixed by upgrading
Yes

Solution

Update Plone to version 4.2.3 or 4.3 beta 1 or higher.

Vulnerable code sample

# Example of code that represents the vulnerability in CVE-2012-5493

def execute_user_code(code):
    # No permission checks, allowing any authenticated user to execute arbitrary code
    exec(code)  # Dangerous: executes user-provided code without restrictions

# Example usage
user_code = "import os; os.system('echo Vulnerable!')"  # User-provided code
execute_user_code(user_code)  # This can execute arbitrary commands

Patched code sample

# Example of fixing the CVE-2012-5493 vulnerability by restricting execution context

from AccessControl import getSecurityManager
from AccessControl import Unauthorized

def safe_execute(code):
    # Check if the user has the appropriate permissions
    if not getSecurityManager().checkPermission('Execute Python Code', self):
        raise Unauthorized("You do not have permission to execute Python code.")
    
    # Create a restricted execution environment
    restricted_globals = {
        '__builtins__': None,  # Disable built-in functions
    }
    
    # Execute the code in a restricted context
    exec(code, restricted_globals)

# Example usage
try:
    user_code = "print('Hello, World!')"  # User-provided code
    safe_execute(user_code)
except Unauthorized as e:
    print(e)
except Exception as e:
    print("Error executing code:", e)

Cite this entry

@misc{vaitp:cve20125493,
  title        = {{Remote authenticated user bypasses Python sandbox to execute arbitrary code in Plone < 4.2.3 and < 4.3 beta 1}},
  author       = {Bogaerts, Fr\'ed\'eric and Ivaki, Naghmeh and Fonseca, Jos\'e},
  year         = {2014},
  note         = {VAITP Python Vulnerability Dataset, entry CVE-2012-5493},
  howpublished = {\url{https://netpack.pt/vaitp/vulnerability/CVE-2012-5493/}}
}

Download this entry as JSON Download the whole dataset

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 ::

Before you use the VAITP AI models

Please read and accept the following disclaimer:

By choosing "I understand and accept", you acknowledge that you understand and agree to these terms.