{"id":292,"cve":"CVE-2013-5106","cve_url":"https:\/\/www.cvedetails.com\/cve\/CVE-2013-5106","cwe":"CWE-20 Improper Input Validation","cwe_number":20,"cwe_url":"https:\/\/cwe.mitre.org\/data\/definitions\/20","cvss_score":8.8,"published":"2020-02-12","owasp":"A03 Injection","odc":"Function","cdc":"Incorrect Functionality","category":"Input Validation and Sanitization","subcategory":"Command Injection","scope":"Remote","impact":"Arbitrary Code Execution","summary":"PyPI package \"d8s-asns\" v0.1.0 had a code-execution backdoor (\"democritus-csv\") added by an unauthorized party","permalink":"https:\/\/netpack.pt\/vaitp\/vulnerability\/CVE-2013-5106\/","description":"A Code Execution vulnerability exists in select.py when using python-mode 2012-12-19.","solution":"Update python-mode to version 2013-01-06 or higher.","affected_component":"Python","fixed_by_upgrading":true,"vulnerable_code":"import os\n\ndef execute_command(command):\n    # Directly executing a command passed as a string\n    os.system(command)\n\n# Example usage\nuser_input = \"ls -l\"  # This could be any command, potentially harmful\nexecute_command(user_input)","patched_code":"import os\nimport subprocess\n\ndef safe_execute_command(command):\n    # Ensure that the command is a list and does not contain any dangerous elements\n    if isinstance(command, list) and all(isinstance(arg, str) for arg in command):\n        # Use subprocess to execute the command safely\n        result = subprocess.run(command, check=True, stdout=subprocess.PIPE, stderr=subprocess.PIPE)\n        return result.stdout.decode('utf-8')\n    else:\n        raise ValueError(\"Invalid command format.\")\n\n# Example usage\ntry:\n    output = safe_execute_command(['ls', '-l'])\n    print(output)\nexcept Exception as e:\n    print(f\"Error: {e}\")","payload_needed":false,"payload":null,"payload_status":"none","published_fix":[],"references":null}