{"id":477,"cve":"CVE-2020-12878","cve_url":"https:\/\/www.cvedetails.com\/cve\/CVE-2020-12878","cwe":"CWE-59 Improper Link Resolution Before File Access ('Link Following')","cwe_number":59,"cwe_url":"https:\/\/cwe.mitre.org\/data\/definitions\/59","cvss_score":7.8,"published":"2021-02-18","owasp":"A05 Security Misconfiguration","odc":"Function","cdc":"Incorrect Functionality","category":"Authentication, Authorization, and Session Management","subcategory":"Privilege Escalation","scope":"Local","impact":"Privilege Escalation","summary":"Digi ConnectPort X2e < 3.2.30.6 symlink privilege escalation via \/etc\/init.d\/S50dropbear.sh and \/WEB\/python\/.ssh","permalink":"https:\/\/netpack.pt\/vaitp\/vulnerability\/CVE-2020-12878\/","description":"Digi ConnectPort X2e before 3.2.30.6 allows an attacker to escalate privileges from the python user to root via a symlink attack that uses chown, related to \/etc\/init.d\/S50dropbear.sh and the \/WEB\/python\/.ssh directory.","solution":"Update Digi ConnectPort X2e to version 3.2.30.6 or higher.","affected_component":"Python","fixed_by_upgrading":true,"vulnerable_code":"import os\n\ndef ssh_directory():\n    ssh_dir = '\/WEB\/python\/.ssh'\n    \n    os.makedirs(ssh_dir, exist_ok=True)\n\n    os.symlink('\/etc\/passwd', os.path.join(ssh_dir, 'authorized_keys'))\n\n    os.system('chown root:root ' + ssh_dir)\n\nssh_directory()","patched_code":"import os\nimport stat\n\ndef ssh_directory():\n    ssh_dir = '\/WEB\/python\/.ssh'\n    \n    if not os.path.exists(ssh_dir):\n        os.makedirs(ssh_dir)\n    \n    os.chmod(ssh_dir, stat.S_IRUSR | stat.S_IWUSR | stat.S_IXUSR)\n\n    authorized_keys_path = os.path.join(ssh_dir, 'authorized_keys')\n    \n    if not os.path.exists(authorized_keys_path):\n        with open(authorized_keys_path, 'w') as f:\n            f.write('')\n\n    os.chmod(authorized_keys_path, stat.S_IRUSR | stat.S_IWUSR)\n\nssh_directory()","payload_needed":false,"payload":null,"payload_status":"none","published_fix":[],"references":null}