CVE-2021-32797: JupyterLab Cross-Site Scripting Vulnerability

MODERATE
Advisory Identifier: GHSA-4952-p58q-6crx
CVSS 7.4
CWE-87 CWE-79 CWE-75
Published
Advisory Summary

CVE-2021-32797 is a MODERATE (CVSS 7.4) cross-site scripting vulnerability (CWE-87: Improper Neutralization of Alternate XSS Syntax) affecting JupyterLab libraries in the PyPI ecosystem. The issue involves xss due to lack of sanitization of the action attribute of an html <form>. Remediation is available by upgrading affected packages to version 1.2.21, 2.2.10, 2.3.2, 3.0.17, 3.1.4, 5.7.11, 6.4.1.

CVE-2021-32797 at a Glance

CVE Identifier CVE-2021-32797
GHSA Identifier GHSA-4952-p58q-6crx
Severity MODERATE
CVSS v3.1 Base Score 7.4
CWE Classification CWE-87: Improper Neutralization of Alternate XSS Syntax
Affected Product JupyterLab
Package Ecosystem PyPI
Published Date
Last Updated

Security Impact

CVSS: 7.4

The security impact metrics below are parsed directly from the CVSS v3.1 vector string (CVSS:3.1/AV:N/AC:L/PR:N/UI:R/S:C/C:H/I:N/A:N).

Attack Vector Network (AV:N)
Attack Complexity Low (AC:L)
Privileges Required None (PR:N)
User Interaction Required (UI:R)
Scope Changed (S:C)
Confidentiality High (C:H)
Integrity None (I:N)
Availability None (A:N)

How to Fix CVE-2021-32797

To remediate this vulnerability, upgrade all affected JupyterLab dependencies to a patched release. Both direct and transitive dependencies should be checked, as frameworks or security libraries may pull in vulnerable versions transitively.

jupyterlab fixed: 1.2.21
pip install jupyterlab>=1.2.21
jupyterlab fixed: 2.2.10
pip install jupyterlab>=2.2.10
jupyterlab fixed: 2.3.2
pip install jupyterlab>=2.3.2
jupyterlab fixed: 3.0.17
pip install jupyterlab>=3.0.17
jupyterlab fixed: 3.1.4
pip install jupyterlab>=3.1.4
notebook fixed: 5.7.11
pip install notebook>=5.7.11
notebook fixed: 6.4.1
pip install notebook>=6.4.1
Verify Direct and Transitive Dependencies

Run the following command in your project directory to verify that all resolved dependencies use the patched release:

pip show jupyterlab

How to Check if You Are Affected

To determine whether your Python environment is affected by CVE-2021-32797, inspect your installed packages using pip:

pip show jupyterlab

Analyze the terminal output to locate any version of JupyterLab in your dependency tree. If any resolved version matches the vulnerable ranges listed in the table below (for example, versions earlier than 1.2.21), your application is affected.

Note: The pip show jupyterlab command checks currently installed packages in your active Python environment.

Technical Details

Vulnerability Mechanism & Technical Analysis

This vulnerability is classified under CWE-87: Improper Neutralization of Alternate XSS Syntax, where the product does not neutralize or incorrectly neutralizes user-controlled input for alternate script syntax. In JupyterLab, software state validation or input boundaries are circumvented during processing. Review the official source advisory statement below for specific affected components, classes, and reproduction details.

Source Advisory Statement

### Impact Untrusted notebook can execute code on load. This is a remote code execution, but requires user action to open a notebook. ### Patches Patched in the following versions: 3.1.4, 3.0.17, 2.3.2, 2.2.10, 1.2.21. ### References [OWASP Page on Restricting Form Submissions](https://cheatsheetseries.owasp.org/cheatsheets/Content_Security_Policy_Cheat_Sheet.html) ### For more information If you have any questions or comments about this advisory, or vulnerabilities to report, please email our security list security@ipython.org. Credit: Guillaume Jeanne from Google

CVE-2021-32797 Affected JupyterLab Versions

7 component(s)
Fixed Versions:
1.2.212.2.102.3.23.0.173.1.45.7.116.4.1
Product / Package Ecosystem Affected Versions Fixed Version
jupyterlab
PyPI
< 1.2.21
1.2.21
jupyterlab
PyPI
≥ 2.0.0a0
< 2.2.10
2.2.10
jupyterlab
PyPI
≥ 2.3.0a0
< 2.3.2
2.3.2
jupyterlab
PyPI
≥ 3.0.0a0
< 3.0.17
3.0.17
jupyterlab
PyPI
≥ 3.1.0a0
< 3.1.4
3.1.4
notebook
PyPI
< 5.7.11
5.7.11
notebook
PyPI
≥ 6.0.0
< 6.4.1
6.4.1

References

Frequently Asked Questions

What is CVE-2021-32797?
CVE-2021-32797 is a security vulnerability in JupyterLab involving XSS due to lack of sanitization of the action attribute of an html <form> under CWE-87: Improper Neutralization of Alternate XSS Syntax.
Which JupyterLab versions are affected?
Affected versions include releases prior to 1.2.21, 2.2.10, 2.3.2, 3.0.17, 3.1.4, 5.7.11, 6.4.1 across affected packages: jupyterlab, notebook.
What version fixes CVE-2021-32797?
Upgrading to 1.2.21, 2.2.10, 2.3.2, 3.0.17, 3.1.4, 5.7.11, 6.4.1 (or the latest patched release for your respective branch) resolves the vulnerability.
Is jupyterlab affected?
Yes, jupyterlab is affected in releases prior to 1.2.21, 2.2.10, 2.3.2, 3.0.17, 3.1.4. Upgrade your dependency to 1.2.21, 2.2.10, 2.3.2, 3.0.17, 3.1.4 or later.
Is notebook affected?
Yes, notebook is affected in releases prior to 5.7.11, 6.4.1. Upgrade your dependency to 5.7.11, 6.4.1 or later.
What is the CVSS score of CVE-2021-32797?
CVE-2021-32797 has a CVSS v3.1 base score of 7.4 (MODERATE) with vector string CVSS:3.1/AV:N/AC:L/PR:N/UI:R/S:C/C:H/I:N/A:N.
What CWE is associated with CVE-2021-32797?
CVE-2021-32797 is classified under CWE-87: Improper Neutralization of Alternate XSS Syntax (The product does not neutralize or incorrectly neutralizes user-controlled input for alternate script syntax.).
How can I check PyPI dependencies for CVE-2021-32797?
Run the dependency tree command: 'pip show jupyterlab'. This command lists direct and transitive dependencies in your build configuration so you can verify if a vulnerable version is resolved.
Machine-readable OSV JSON OSV v1.5 Schema
Normalized schema output
{
  "schema_version" : "1.4.0",
  "id" : "GHSA-4952-p58q-6crx",
  "modified" : "2024-11-18T16:26:15Z",
  "published" : "2021-08-23T19:40:22Z",
  "aliases" : [ "CVE-2021-32797" ],
  "summary" : "JupyterLab: XSS due to lack of sanitization of the action attribute of an html <form>",
  "details" : "### Impact\n\nUntrusted notebook can execute code on load. This is a remote code execution, but requires user action to open a notebook.\n\n### Patches\n\nPatched in the following versions: 3.1.4, 3.0.17, 2.3.2, 2.2.10, 1.2.21.\n\n### References\n\n[OWASP Page on Restricting Form Submissions](https://cheatsheetseries.owasp.org/cheatsheets/Content_Security_Policy_Cheat_Sheet.html)\n\n### For more information\n\nIf you have any questions or comments about this advisory, or vulnerabilities to report, please email our security list security@ipython.org.\n\nCredit: Guillaume Jeanne from Google\n",
  "severity" : [ {
    "type" : "CVSS_V3",
    "score" : "CVSS:3.1/AV:N/AC:L/PR:N/UI:R/S:C/C:H/I:N/A:N"
  }, {
    "type" : "CVSS_V4",
    "score" : "CVSS:4.0/AV:N/AC:L/AT:N/PR:N/UI:P/VC:N/VI:N/VA:N/SC:H/SI:N/SA:N"
  } ],
  "affected" : [ {
    "package" : {
      "ecosystem" : "PyPI",
      "name" : "jupyterlab"
    },
    "ranges" : [ {
      "type" : "ECOSYSTEM",
      "events" : [ {
        "introduced" : "0"
      }, {
        "fixed" : "1.2.21"
      } ]
    } ]
  }, {
    "package" : {
      "ecosystem" : "PyPI",
      "name" : "jupyterlab"
    },
    "ranges" : [ {
      "type" : "ECOSYSTEM",
      "events" : [ {
        "introduced" : "2.0.0a0"
      }, {
        "fixed" : "2.2.10"
      } ]
    } ]
  }, {
    "package" : {
      "ecosystem" : "PyPI",
      "name" : "jupyterlab"
    },
    "ranges" : [ {
      "type" : "ECOSYSTEM",
      "events" : [ {
        "introduced" : "2.3.0a0"
      }, {
        "fixed" : "2.3.2"
      } ]
    } ]
  }, {
    "package" : {
      "ecosystem" : "PyPI",
      "name" : "jupyterlab"
    },
    "ranges" : [ {
      "type" : "ECOSYSTEM",
      "events" : [ {
        "introduced" : "3.0.0a0"
      }, {
        "fixed" : "3.0.17"
      } ]
    } ]
  }, {
    "package" : {
      "ecosystem" : "PyPI",
      "name" : "jupyterlab"
    },
    "ranges" : [ {
      "type" : "ECOSYSTEM",
      "events" : [ {
        "introduced" : "3.1.0a0"
      }, {
        "fixed" : "3.1.4"
      } ]
    } ]
  }, {
    "package" : {
      "ecosystem" : "PyPI",
      "name" : "notebook"
    },
    "ranges" : [ {
      "type" : "ECOSYSTEM",
      "events" : [ {
        "introduced" : "0"
      }, {
        "fixed" : "5.7.11"
      } ]
    } ]
  }, {
    "package" : {
      "ecosystem" : "PyPI",
      "name" : "notebook"
    },
    "ranges" : [ {
      "type" : "ECOSYSTEM",
      "events" : [ {
        "introduced" : "6.0.0"
      }, {
        "fixed" : "6.4.1"
      } ]
    } ]
  } ],
  "references" : [ {
    "type" : "WEB",
    "url" : "https://github.com/google/security-research/security/advisories/GHSA-c469-p3jp-2vhx"
  }, {
    "type" : "WEB",
    "url" : "https://github.com/jupyterlab/jupyterlab/security/advisories/GHSA-4952-p58q-6crx"
  }, {
    "type" : "ADVISORY",
    "url" : "https://nvd.nist.gov/vuln/detail/CVE-2021-32797"
  }, {
    "type" : "WEB",
    "url" : "https://github.com/jupyterlab/jupyterlab/commit/504825938c0abfa2fb8ff8d529308830a5ae42ed"
  }, {
    "type" : "WEB",
    "url" : "https://github.com/pypa/advisory-database/tree/main/vulns/jupyterlab/PYSEC-2021-130.yaml"
  } ],
  "database_specific" : {
    "cwe_ids" : [ "CWE-75", "CWE-79", "CWE-87" ],
    "severity" : "MODERATE",
    "github_reviewed" : true,
    "github_reviewed_at" : "2021-08-23T16:41:37Z",
    "nvd_published_at" : "2021-08-09T21:15:00Z"
  }
}