{"id":893,"cve":"CVE-2017-6900","cve_url":"https:\/\/www.cvedetails.com\/cve\/CVE-2017-6900","cwe":"CWE-255","cwe_number":255,"cwe_url":"https:\/\/cwe.mitre.org\/data\/definitions\/255","cvss_score":9.8,"published":"2019-07-03","owasp":"A07 Identification and Authentication Failures","odc":"Function","cdc":"Incorrect Functionality","category":"Input Validation and Sanitization","subcategory":"Command Injection","scope":"Remote","impact":"Unauthorized Access","summary":"Bash command injection in Riello NetMan 204 14-2 and 15-2 login script","permalink":"https:\/\/netpack.pt\/vaitp\/vulnerability\/CVE-2017-6900\/","description":"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.","solution":"Secure the login.cgi script to prevent login via GET parameters.","affected_component":"Python","fixed_by_upgrading":false,"vulnerable_code":"#Proprietary, no code available","patched_code":"import re\n\ndef sanitize_input(username):\n    # Sanitize the username to prevent malicious characters\n    if re.search(r'[^a-zA-Z0-9_\\-]', username):\n        raise ValueError(\"Invalid username: contains malicious characters.\")\n    return username\n\ndef login(username):\n    # Sanitize the username before using it\n    sanitized_username = sanitize_input(username)\n\n    # Properly quote the variables to prevent command injection\n    command = f\"wrongpass '{sanitized_username}'\"\n    \n    # Execute the command safely (using subprocess, for example)\n    import subprocess\n    result = subprocess.run(command, shell=True, capture_output=True, text=True)\n\n    # Check the result of the command execution\n    if result.returncode == 0:\n        print(\"Login successful.\")\n    else:\n        print(\"Login failed.\")\n\n# Example usage\ntry:\n    login('- a')  # This input should be sanitized and rejected\nexcept ValueError as e:\n    print(e)","payload_needed":false,"payload":null,"payload_status":"none","published_fix":[],"references":null}