CVE-2021-32798: Notebook Special Element Injection Vulnerability

HIGH
Advisory Identifier: GHSA-hwvq-6gjx-j797
CVSS 10.0
CWE-80 CWE-79 CWE-75
Published
Advisory Summary

CVE-2021-32798 is a HIGH (CVSS 10.0) special element injection vulnerability (CWE-80: Improper Neutralization of Script-Related HTML Tags in a Web Page (Basic XSS)) affecting Notebook libraries in the PyPI ecosystem. The issue involves special element injection in notebook. Remediation is available by upgrading affected packages to version 5.7.11, 6.4.1.

CVE-2021-32798 at a Glance

CVE Identifier CVE-2021-32798
GHSA Identifier GHSA-hwvq-6gjx-j797
Severity HIGH
CVSS v3.1 Base Score 10.0
CWE Classification CWE-80: Improper Neutralization of Script-Related HTML Tags in a Web Page (Basic XSS)
Affected Product Notebook
Package Ecosystem PyPI
Published Date
Last Updated

Security Impact

CVSS: 10.0

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:N/S:C/C:H/I:H/A:N).

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

How to Fix CVE-2021-32798

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

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 notebook

How to Check if You Are Affected

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

pip show notebook

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

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

Technical Details

Vulnerability Mechanism & Technical Analysis

This vulnerability is classified under CWE-80: Improper Neutralization of Script-Related HTML Tags in a Web Page (Basic XSS), where the product receives input from an upstream component, but it does not neutralize or incorrectly neutralizes special characters such as "<", ">", and "&" that could be interpreted as web-scripting elements when they are sent to a downstream component that processes web pages. In Notebook, 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 5.7.11, 6.4.1 ### References [OWASP Page on Injection Prevention](https://cheatsheetseries.owasp.org/cheatsheets/Injection_Prevention_Cheat_Sheet.html#injection-prevention-rules) ### 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 ### Example: A notebook with the following content in a cell and it would display an alert when opened for the first time in Notebook (in an untrusted state): ``` { "cell_type": "code", "execution_count": 0, "metadata": {}, "outputs": [ { "data": { "text/html": [ "<select><iframe></select><img src=x: onerror=alert('xss')>\n"], "text/plain": [] }, "metadata": {}, "output_type": "display_data" } ], "source": [ "" ] } ````

CVE-2021-32798 Affected Notebook Versions

2 component(s)
Fixed Versions:
5.7.116.4.1
Product / Package Ecosystem Affected Versions Fixed Version
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-32798?
CVE-2021-32798 is a security vulnerability in Notebook involving Special Element Injection in notebook under CWE-80: Improper Neutralization of Script-Related HTML Tags in a Web Page (Basic XSS).
Which Notebook versions are affected?
Affected versions include releases prior to 5.7.11, 6.4.1 across affected packages: notebook.
What version fixes CVE-2021-32798?
Upgrading to 5.7.11, 6.4.1 (or the latest patched release for your respective branch) resolves the vulnerability.
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-32798?
CVE-2021-32798 has a CVSS v3.1 base score of 10.0 (HIGH) with vector string CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:C/C:H/I:H/A:N.
What CWE is associated with CVE-2021-32798?
CVE-2021-32798 is classified under CWE-80: Improper Neutralization of Script-Related HTML Tags in a Web Page (Basic XSS) (The product receives input from an upstream component, but it does not neutralize or incorrectly neutralizes special characters such as "<", ">", and "&" that could be interpreted as web-scripting elements when they are sent to a downstream component that processes web pages.).
How can I check PyPI dependencies for CVE-2021-32798?
Run the dependency tree command: 'pip show notebook'. 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-hwvq-6gjx-j797",
  "modified" : "2024-10-01T21:17:37Z",
  "published" : "2021-08-23T19:40:38Z",
  "aliases" : [ "CVE-2021-32798" ],
  "summary" : "Special Element Injection in notebook",
  "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\n5.7.11, 6.4.1\n\n### References\n\n[OWASP Page on Injection Prevention](https://cheatsheetseries.owasp.org/cheatsheets/Injection_Prevention_Cheat_Sheet.html#injection-prevention-rules)\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\n\n### Example:\n\nA notebook with the following content in a cell and it would display an alert when opened for the first time in Notebook (in an untrusted state):\n\n```\n{ \"cell_type\": \"code\", \"execution_count\": 0, \"metadata\": {}, \"outputs\": [ { \"data\": { \"text/html\": [ \"<select><iframe></select><img src=x: onerror=alert('xss')>\\n\"], \"text/plain\": [] }, \"metadata\": {}, \"output_type\": \"display_data\" } ], \"source\": [ \"\" ] }\n````",
  "severity" : [ {
    "type" : "CVSS_V3",
    "score" : "CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:C/C:H/I:H/A:N"
  }, {
    "type" : "CVSS_V4",
    "score" : "CVSS:4.0/AV:N/AC:L/AT:N/PR:N/UI:N/VC:N/VI:N/VA:N/SC:H/SI:H/SA:N"
  } ],
  "affected" : [ {
    "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/jupyter/notebook/security/advisories/GHSA-hwvq-6gjx-j797"
  }, {
    "type" : "ADVISORY",
    "url" : "https://nvd.nist.gov/vuln/detail/CVE-2021-32798"
  }, {
    "type" : "WEB",
    "url" : "https://github.com/jupyter/notebook/commit/79fc76e890a8ec42f73a3d009e44ef84c14ef0d5"
  }, {
    "type" : "PACKAGE",
    "url" : "https://github.com/jupyter/notebook"
  }, {
    "type" : "WEB",
    "url" : "https://github.com/pypa/advisory-database/tree/main/vulns/notebook/PYSEC-2021-118.yaml"
  } ],
  "database_specific" : {
    "cwe_ids" : [ "CWE-75", "CWE-79", "CWE-80" ],
    "severity" : "HIGH",
    "github_reviewed" : true,
    "github_reviewed_at" : "2021-08-23T16:44:43Z",
    "nvd_published_at" : "2021-08-09T21:15:00Z"
  }
}