CVE-2021-25951: XML2Dict XML2Dict XML Entity Expansion Vulnerability Vulnerability

HIGH
Advisory Identifier: GHSA-gp6m-vqhm-5cm5
CVSS 7.5
CWE-776 CWE-611
Published
Advisory Summary

CVE-2021-25951 is a HIGH (CVSS 7.5) xml2dict xml entity expansion vulnerability vulnerability (CWE-776: Improper Restriction of Recursive Entity References in DTDs ('XML Entity Expansion')) affecting XML2Dict libraries in the PyPI ecosystem. The issue involves xml2dict xml entity expansion vulnerability. Remediation is available in the latest vendor maintenance releases.

CVE-2021-25951 at a Glance

CVE Identifier CVE-2021-25951
GHSA Identifier GHSA-gp6m-vqhm-5cm5
Severity HIGH
CVSS v3.1 Base Score 7.5
CWE Classification CWE-776: Improper Restriction of Recursive Entity References in DTDs ('XML Entity Expansion')
Affected Product XML2Dict
Package Ecosystem PyPI
Published Date
Last Updated

Security Impact

CVSS: 7.5

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:N/I:N/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 None (C:N)
Integrity None (I:N)
Availability High (A:H)

How to Fix CVE-2021-25951

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

XML2Dict fixed: Latest secure release
pip install XML2Dict>=Latest secure release
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 XML2Dict

How to Check if You Are Affected

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

pip show XML2Dict

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

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

Technical Details

Vulnerability Mechanism & Technical Analysis

This vulnerability is classified under CWE-776: Improper Restriction of Recursive Entity References in DTDs ('XML Entity Expansion'), where the product uses xml documents and allows their structure to be defined with a document type definition (dtd), but it does not properly control the number of recursive definitions of entities. In XML2Dict, 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

XXE vulnerability in 'XML2Dict' version 0.2.2 allows an attacker to cause a denial of service. The parse function does not properly restrict recursive entity references.

CVE-2021-25951 Affected XML2Dict Versions

1 component(s)
Product / Package Ecosystem Affected Versions Fixed Version
XML2Dict
PyPI
≤ 0.2.2

References

Frequently Asked Questions

What is CVE-2021-25951?
CVE-2021-25951 is a security vulnerability in XML2Dict involving XML2Dict XML Entity Expansion Vulnerability under CWE-776: Improper Restriction of Recursive Entity References in DTDs ('XML Entity Expansion').
Which XML2Dict versions are affected?
Affected versions include releases prior to current release patches across affected packages: XML2Dict.
What version fixes CVE-2021-25951?
Upgrading to current release patches (or the latest patched release for your respective branch) resolves the vulnerability.
Is XML2Dict affected?
Yes, XML2Dict is affected in releases prior to Latest secure release. Upgrade your dependency to Latest secure release or later.
What is the CVSS score of CVE-2021-25951?
CVE-2021-25951 has a CVSS v3.1 base score of 7.5 (HIGH) with vector string CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:N/I:N/A:H.
What CWE is associated with CVE-2021-25951?
CVE-2021-25951 is classified under CWE-776: Improper Restriction of Recursive Entity References in DTDs ('XML Entity Expansion') (The product uses XML documents and allows their structure to be defined with a Document Type Definition (DTD), but it does not properly control the number of recursive definitions of entities.).
How can I check PyPI dependencies for CVE-2021-25951?
Run the dependency tree command: 'pip show XML2Dict'. 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-gp6m-vqhm-5cm5",
  "modified" : "2024-11-19T18:24:52Z",
  "published" : "2021-07-02T18:37:31Z",
  "aliases" : [ "CVE-2021-25951" ],
  "summary" : "XML2Dict XML Entity Expansion Vulnerability",
  "details" : "XXE vulnerability in 'XML2Dict' version 0.2.2 allows an attacker to cause a denial of service. The parse function does not properly restrict recursive entity references.",
  "severity" : [ {
    "type" : "CVSS_V3",
    "score" : "CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:N/I:N/A:H"
  }, {
    "type" : "CVSS_V4",
    "score" : "CVSS:4.0/AV:N/AC:L/AT:N/PR:N/UI:N/VC:N/VI:N/VA:H/SC:N/SI:N/SA:N"
  } ],
  "affected" : [ {
    "package" : {
      "ecosystem" : "PyPI",
      "name" : "XML2Dict"
    },
    "ranges" : [ {
      "type" : "ECOSYSTEM",
      "events" : [ {
        "introduced" : "0"
      }, {
        "last_affected" : "0.2.2"
      } ]
    } ]
  } ],
  "references" : [ {
    "type" : "ADVISORY",
    "url" : "https://nvd.nist.gov/vuln/detail/CVE-2021-25951"
  }, {
    "type" : "WEB",
    "url" : "https://github.com/mcspring/XML2Dict/tree/master"
  }, {
    "type" : "PACKAGE",
    "url" : "https://github.com/mcspring/xml2dict"
  }, {
    "type" : "WEB",
    "url" : "https://github.com/pypa/advisory-database/tree/main/vulns/xml2dict/PYSEC-2021-349.yaml"
  }, {
    "type" : "WEB",
    "url" : "https://pypi.org/project/XML2Dict"
  }, {
    "type" : "WEB",
    "url" : "https://www.whitesourcesoftware.com/vulnerability-database/CVE-2021-25951"
  } ],
  "database_specific" : {
    "cwe_ids" : [ "CWE-611", "CWE-776" ],
    "severity" : "HIGH",
    "github_reviewed" : true,
    "github_reviewed_at" : "2021-07-01T21:42:31Z",
    "nvd_published_at" : "2021-06-30T12:15:00Z"
  }
}