CVE-2021-42576: Pybluemonday Remote Code Execution Vulnerability

HIGH
Advisory Identifier: GHSA-x95h-979x-cf3j
CVSS 9.8
CWE-20
Published
Advisory Summary

CVE-2021-42576 is a HIGH (CVSS 9.8) remote code execution vulnerability (CWE-20: Improper Input Validation) affecting Pybluemonday libraries in the PyPI ecosystem. The issue involves policies not properly enforced in bluemonday. Remediation is available by upgrading affected packages to version 0.0.8, 1.0.16.

CVE-2021-42576 at a Glance

CVE Identifier CVE-2021-42576
GHSA Identifier GHSA-x95h-979x-cf3j
Severity HIGH
CVSS v3.1 Base Score 9.8
CWE Classification CWE-20: Improper Input Validation
Affected Product Pybluemonday
Package Ecosystem PyPI
Published Date
Last Updated

Security Impact

CVSS: 9.8

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

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

How to Fix CVE-2021-42576

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

pybluemonday fixed: 0.0.8
pip install pybluemonday>=0.0.8
github.com/microcosm-cc/bluemonday fixed: 1.0.16
Upgrade github.com/microcosm-cc/bluemonday to 1.0.16
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 pybluemonday

How to Check if You Are Affected

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

pip show pybluemonday

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

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

Technical Details

Vulnerability Mechanism & Technical Analysis

This vulnerability is classified under CWE-20: Improper Input Validation, where the product receives input or data, but it does not validate or incorrectly validates that the input has the properties that are required to process the data safely and correctly. In Pybluemonday, 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

The bluemonday sanitizer before 1.0.16 for Go, and before 0.0.8 for Python (in pybluemonday), does not properly enforce policies associated with the SELECT, STYLE, and OPTION elements.

CVE-2021-42576 Affected Pybluemonday Versions

2 component(s)
Fixed Versions:
0.0.81.0.16
Product / Package Ecosystem Affected Versions Fixed Version
pybluemonday
PyPI
< 0.0.8
0.0.8
github.com/microcosm-cc/bluemonday
Go
< 1.0.16
1.0.16

References

Frequently Asked Questions

What is CVE-2021-42576?
CVE-2021-42576 is a security vulnerability in Pybluemonday involving Policies not properly enforced in bluemonday under CWE-20: Improper Input Validation.
Which Pybluemonday versions are affected?
Affected versions include releases prior to 0.0.8, 1.0.16 across affected packages: pybluemonday, github.com/microcosm-cc/bluemonday.
What version fixes CVE-2021-42576?
Upgrading to 0.0.8, 1.0.16 (or the latest patched release for your respective branch) resolves the vulnerability.
Is pybluemonday affected?
Yes, pybluemonday is affected in releases prior to 0.0.8. Upgrade your dependency to 0.0.8 or later.
Is github.com/microcosm-cc/bluemonday affected?
Yes, github.com/microcosm-cc/bluemonday is affected in releases prior to 1.0.16. Upgrade your dependency to 1.0.16 or later.
What is the CVSS score of CVE-2021-42576?
CVE-2021-42576 has a CVSS v3.1 base score of 9.8 (HIGH) with vector string CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:H/I:H/A:H.
What CWE is associated with CVE-2021-42576?
CVE-2021-42576 is classified under CWE-20: Improper Input Validation (The product receives input or data, but it does not validate or incorrectly validates that the input has the properties that are required to process the data safely and correctly.).
How can I check PyPI dependencies for CVE-2021-42576?
Run the dependency tree command: 'pip show pybluemonday'. 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-x95h-979x-cf3j",
  "modified" : "2024-10-21T20:18:42Z",
  "published" : "2021-10-19T20:15:30Z",
  "aliases" : [ "CVE-2021-42576" ],
  "summary" : "Policies not properly enforced in bluemonday",
  "details" : "The bluemonday sanitizer before 1.0.16 for Go, and before 0.0.8 for Python (in pybluemonday), does not properly enforce policies associated with the SELECT, STYLE, and OPTION elements.",
  "severity" : [ {
    "type" : "CVSS_V3",
    "score" : "CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:H/I:H/A:H"
  }, {
    "type" : "CVSS_V4",
    "score" : "CVSS:4.0/AV:N/AC:L/AT:N/PR:N/UI:N/VC:H/VI:H/VA:H/SC:N/SI:N/SA:N/E:U"
  } ],
  "affected" : [ {
    "package" : {
      "ecosystem" : "PyPI",
      "name" : "pybluemonday"
    },
    "ranges" : [ {
      "type" : "ECOSYSTEM",
      "events" : [ {
        "introduced" : "0"
      }, {
        "fixed" : "0.0.8"
      } ]
    } ]
  }, {
    "package" : {
      "ecosystem" : "Go",
      "name" : "github.com/microcosm-cc/bluemonday"
    },
    "ranges" : [ {
      "type" : "ECOSYSTEM",
      "events" : [ {
        "introduced" : "0"
      }, {
        "fixed" : "1.0.16"
      } ]
    } ]
  } ],
  "references" : [ {
    "type" : "ADVISORY",
    "url" : "https://nvd.nist.gov/vuln/detail/CVE-2021-42576"
  }, {
    "type" : "WEB",
    "url" : "https://github.com/microcosm-cc/bluemonday/commit/c788a2a4d42e081ad54a31368478820bb4a42fb4"
  }, {
    "type" : "WEB",
    "url" : "https://docs.google.com/document/d/11SoX296sMS0XoQiQbpxc5pNxSdbJKDJkm5BDv0zrX50"
  }, {
    "type" : "ADVISORY",
    "url" : "https://github.com/advisories/GHSA-x95h-979x-cf3j"
  }, {
    "type" : "PACKAGE",
    "url" : "https://github.com/microcosm-cc/bluemonday"
  }, {
    "type" : "WEB",
    "url" : "https://github.com/pypa/advisory-database/tree/main/vulns/pybluemonday/PYSEC-2021-849.yaml"
  }, {
    "type" : "WEB",
    "url" : "https://pkg.go.dev/vuln/GO-2022-0588"
  }, {
    "type" : "WEB",
    "url" : "https://pypi.org/project/pybluemonday"
  } ],
  "database_specific" : {
    "cwe_ids" : [ "CWE-20" ],
    "severity" : "HIGH",
    "github_reviewed" : true,
    "github_reviewed_at" : "2021-10-19T16:10:19Z",
    "nvd_published_at" : "2021-10-18T15:15:00Z"
  }
}