VAITP Dataset

← Back to the dataset

CVE-2017-6900

Bash command injection in Riello NetMan 204 14-2 and 15-2 login script

  • CVSS 9.8
  • CWE-255
  • Input Validation and Sanitization
  • Remote

An issue was discovered in Riello NetMan 204 14-2 and 15-2. The issue is with the login script and wrongpass Python script used for authentication. When calling wrongpass, the variables $VAL0 and $VAL1 should be enclosed in quotes to prevent the potential for Bash command injection. Further to this, VAL0 and VAL1 should be sanitised to ensure they do not contain malicious characters. Passing it the username of '-' will cause it to time out and log the user in because of poor error handling. This will log the attacker in as an administrator where the telnet / ssh services can be enabled, and the credentials for local users can be reset. Also, login.cgi accepts the username as a GET parameter, so login can be achieved by browsing to the /cgi-bin/login.cgi?username=-%20a URI.

CVSS base score
9.8
Published
2019-07-03
OWASP
A07 Identification and Authentication Failures
Orthogonal defect classification
Function
Code defect classification
Incorrect Functionality
Category
Input Validation and Sanitization
Subcategory
Command Injection
Accessibility scope
Remote
Impact
Unauthorized Access

Solution

Secure the login.cgi script to prevent login via GET parameters.

Vulnerable code sample

#Proprietary, no code available

Patched code sample

import re

def sanitize_input(username):
    # Sanitize the username to prevent malicious characters
    if re.search(r'[^a-zA-Z0-9_\-]', username):
        raise ValueError("Invalid username: contains malicious characters.")
    return username

def login(username):
    # Sanitize the username before using it
    sanitized_username = sanitize_input(username)

    # Properly quote the variables to prevent command injection
    command = f"wrongpass '{sanitized_username}'"
    
    # Execute the command safely (using subprocess, for example)
    import subprocess
    result = subprocess.run(command, shell=True, capture_output=True, text=True)

    # Check the result of the command execution
    if result.returncode == 0:
        print("Login successful.")
    else:
        print("Login failed.")

# Example usage
try:
    login('- a')  # This input should be sanitized and rejected
except ValueError as e:
    print(e)

Cite this entry

@misc{vaitp:cve20176900,
  title        = {{Bash command injection in Riello NetMan 204 14-2 and 15-2 login script}},
  author       = {Bogaerts, Fr\'ed\'eric and Ivaki, Naghmeh and Fonseca, Jos\'e},
  year         = {2019},
  note         = {VAITP Python Vulnerability Dataset, entry CVE-2017-6900},
  howpublished = {\url{https://netpack.pt/vaitp/vulnerability/CVE-2017-6900/}}
}
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 ::