VAITP Dataset

← Back to the dataset

CVE-2021-26551

SmartFoxServer 2.17.0 allows attackers to execute Python code via file manipulation

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

An issue was discovered in SmartFoxServer 2.17.0. An attacker can execute arbitrary Python code, and bypass the javashell.py protection mechanism, by creating /config/ConsoleModuleUnlock.txt and editing /config/admin/admintool.xml to enable the Console module.

CVSS base score
8.8
Published
2021-02-09
OWASP
A05 Security Misconfiguration
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
SmartFoxServer
Fixed by upgrading
Yes

Solution

Update SmartFoxServer to version 2.17.1 or higher.

Vulnerable code sample

import os

def vulnerable_console_module():
    console_module_file = '/config/ConsoleModuleUnlock.txt'
    admin_tool_file = '/config/admin/admintool.xml'

    # Check if the Console module unlock file exists (vulnerability)
    if os.path.exists(console_module_file):
        print("Console module unlocked. Executing arbitrary code is allowed.")

    # Read admin tool file to check if Console module is enabled
    with open(admin_tool_file, 'r') as file:
        content = file.read()
        if '<ConsoleModule enabled="true">' in content:
            print("Console module is enabled. Arbitrary code execution can occur.")

# Call the function to demonstrate the vulnerability
vulnerable_console_module()

Patched code sample

import os

def secure_console_module():
    console_module_file = '/config/ConsoleModuleUnlock.txt'
    admin_tool_file = '/config/admin/admintool.xml'

    # Check if the Console module unlock file exists
    if os.path.exists(console_module_file):
        raise PermissionError("Access to Console module is restricted. Please remove ConsoleModuleUnlock.txt.")

    # Check if the admin tool file has been tampered with
    with open(admin_tool_file, 'r') as file:
        content = file.read()
        if '<ConsoleModule enabled="true">' in content:
            raise PermissionError("Console module is disabled. Please fix admintool.xml.")

# Call the function to enforce security checks
secure_console_module()

Cite this entry

@misc{vaitp:cve202126551,
  title        = {{SmartFoxServer 2.17.0 allows attackers to execute Python code via file manipulation}},
  author       = {Bogaerts, Fr\'ed\'eric and Ivaki, Naghmeh and Fonseca, Jos\'e},
  year         = {2021},
  note         = {VAITP Python Vulnerability Dataset, entry CVE-2021-26551},
  howpublished = {\url{https://netpack.pt/vaitp/vulnerability/CVE-2021-26551/}}
}

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.