VAITP Dataset

← Back to the dataset

CVE-2019-17526

SageMath Sage Cell Server through 2019-10-05 allowed Python code injection for arbitrary OS command execution

  • CVSS 9.8
  • CWE-78 Improper Neutralization of Special Elements used in an OS Command ('OS Command Injection')
  • Input Validation and Sanitization
  • Remote

** DISPUTED ** An issue was discovered in SageMath Sage Cell Server through 2019-10-05. Python Code Injection can occur in the context of an internet facing web application. Malicious actors can execute arbitrary commands on the underlying operating system, as demonstrated by an __import__('os').popen('whoami').read() line. NOTE: the vendor's position is that the product is "vulnerable by design" and the current behavior will be retained.

CVSS base score
9.8
Published
2019-10-18
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
SageMath

Solution

No available solution.

Vulnerable code sample

import os

# An attacker-controlled string that simulates the malicious input
malicious_input = "__import__('os').popen('whoami').read()"

# The vulnerable part where the attacker's input is executed without sanitation
result = eval(malicious_input)

print(result)

Patched code sample

import os

# An attacker-controlled string that simulates the malicious input
malicious_input = "__import__('os').popen('whoami').read()"

# Instead of executing the input, just print a message or handle it safely
print("Received input:", malicious_input)

# Or, if you need to execute commands, ensure they are predefined and controlled
allowed_commands = {'whoami': 'whoami'}
command = malicious_input.split('\'')[1]  # This is a simplistic parser and not secure in real applications

if command in allowed_commands:
    result = os.popen(allowed_commands[command]).read()
    print(result)
else:
    print("Command not allowed.")

Cite this entry

@misc{vaitp:cve201917526,
  title        = {{SageMath Sage Cell Server through 2019-10-05 allowed Python code injection for arbitrary OS command execution}},
  author       = {Bogaerts, Fr\'ed\'eric and Ivaki, Naghmeh and Fonseca, Jos\'e},
  year         = {2019},
  note         = {VAITP Python Vulnerability Dataset, entry CVE-2019-17526},
  howpublished = {\url{https://netpack.pt/vaitp/vulnerability/CVE-2019-17526/}}
}

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.