{"id":1026,"cve":"CVE-2015-6938","cve_url":"https:\/\/www.cvedetails.com\/cve\/CVE-2015-6938","cwe":"CWE-79: Improper Neutralization of Input During Web Page Generation ('Cross-site Scripting')","cwe_number":79,"cwe_url":"https:\/\/cwe.mitre.org\/data\/definitions\/79","cvss_score":4.3,"published":"2015-09-02","owasp":"A03 Injection","odc":"Checking","cdc":"Incorrect Check","category":"Configuration Issues","subcategory":"Cross-Site Scripting (XSS)","scope":"Remote","impact":"Arbitrary Code Execution","summary":"IPython\/Jupyter Notebook 3.2.2 and 4.0.x File Browser XSS.","permalink":"https:\/\/netpack.pt\/vaitp\/vulnerability\/CVE-2015-6938\/","description":"Cross-site scripting (XSS) vulnerability in the file browser in notebook\/notebookapp.py in IPython Notebook before 3.2.2 and Jupyter Notebook 4.0.x before 4.0.5 allows remote attackers to inject arbitrary web script or HTML via a folder name.  NOTE: this was originally reported as a cross-site request forgery (CSRF) vulnerability, but this may be inaccurate.","solution":"Update to Jupyter Notebook version 4.0.5 or higher","affected_component":"IPython Notebook","fixed_by_upgrading":true,"vulnerable_code":"def create_folder(folder_name):\n    \"\"\"Vulnerable function that demonstrates the security issue.\"\"\"\n    folder_path = '\/path\/to\/folders\/' + folder_name\n\n\ncreate_folder(\"<script>alert('XSS');<\/script>\")","patched_code":"import urllib.parse\nfrom notebook.utils import url_path_join\n\ndef function_folder_name(folder_name):\n    \"\"\"Secure function that fixes the vulnerability.\"\"\"\n    return urllib.parse.quote(folder_name, safe='')\n\ndef create_folder(folder_name):\n    \"\"\"Secure function that fixes the vulnerability.\"\"\"\n    modified_name = function_folder_name(folder_name)\n    if not modified_name.isalnum() and not modified_name.replace('-', '').replace('_', '').isalnum():\n        print(\"Invalid folder name.\")\n        return\n    folder_path = url_path_join('\/path\/to\/folders', modified_name)\n\ncreate_folder(\"<script>alert('XSS');<\/script>\")\n","payload_needed":false,"payload":null,"payload_status":"none","published_fix":[{"repository":"ipython\/ipython","commit_url":"https:\/\/github.com\/ipython\/ipython\/commit\/3ab41641cf6fce3860c73d5cf4645aa12e1e5892","commit_subject":"Fix XSS reported on Security list","units":[{"file":"IPython\/html\/notebookapp.py","function":"NotebookWebApplication.init_settings"}]},{"repository":"jupyter\/notebook","commit_url":"https:\/\/github.com\/jupyter\/notebook\/commit\/35f32dd2da804d108a3a3585b69ec3295b2677ed","commit_subject":"Fix XSS reported on Security list","units":[{"file":"notebook\/notebookapp.py","function":"NotebookWebApplication.init_settings"}]},{"repository":"jupyter\/notebook","commit_url":"https:\/\/github.com\/jupyter\/notebook\/commit\/dd9876381f0ef09873d8c5f6f2063269172331e3","commit_subject":"Fix XSS reported on Security list","units":[{"file":"notebook\/notebookapp.py","function":"NotebookWebApplication.init_settings"}]}],"references":null}