Vulnerabilities in pkg:pypi/OWSLib

PACKAGE
Advisory Identifier: GHSA-8h9c-r582-mggc
Advisory Summary

CVE-2023-27476 is a HIGH (CVSS 8.2) owslib vulnerable to xml external vulnerability (CWE-611: Improper Restriction of XML External Entity Reference) affecting OWSLib libraries in the PyPI ecosystem. The issue involves owslib vulnerable to xml external entity (xxe) injection. Remediation is available by upgrading affected packages to version 0.28.1.

1 Known Advisory Record(s)
Package Vulnerability Intelligence

pkg:pypi/OWSLib

1 Known Advisory Record(s)

Vulnerability advisories affecting package pkg:pypi/OWSLib. Select an advisory below to view technical details or fixes.

Advisory ID CVE / NVD Severity Summary
GHSA-8h9c-r582-mggc CVE-2023-27476 HIGH OWSLib vulnerable to XML External Entity (XXE) Injection

CVE-2023-27476 at a Glance

CVE Identifier CVE-2023-27476
GHSA Identifier GHSA-8h9c-r582-mggc
Severity HIGH
CVSS v3.1 Base Score 8.2
CWE Classification CWE-611: Improper Restriction of XML External Entity Reference
Affected Product OWSLib
Package Ecosystem PyPI
Published Date
Last Updated

Security Impact

CVSS: 8.2

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:N/A:L).

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 None (I:N)
Availability Low (A:L)

How to Fix CVE-2023-27476

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

OWSLib fixed: 0.28.1
pip install OWSLib>=0.28.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 OWSLib

How to Check if You Are Affected

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

pip show OWSLib

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

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

Technical Details

Vulnerability Mechanism & Technical Analysis

This vulnerability is classified under CWE-611: Improper Restriction of XML External Entity Reference, where the product processes an xml document that can contain xml entities with uris that resolve to documents outside of the intended sphere of control, causing the product to embed incorrect documents into its output. In OWSLib, 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 OWSLib's XML parser (which supports both `lxml` and `xml.etree`) does not disable entity resolution for `lxml`, and could lead to arbitrary file reads from an attacker-controlled XML payload. This affects all XML parsing in the codebase. ### Patches - Use only lxml for XML handling, adding `resolve_entities=False` to `lxml`'s parser: https://github.com/geopython/OWSLib/pull/863 ### Workarounds ```python patch_well_known_namespaces(etree) etree.set_default_parser( parser=etree.XMLParser(resolve_entities=False) ) ``` ### References - [`GHSL-2022-131`](https://securitylab.github.com/advisories/GHSL-2022-131_OWSLib/)

CVE-2023-27476 Affected OWSLib Versions

1 component(s)
Fixed Versions:
0.28.1
Product / Package Ecosystem Affected Versions Fixed Version
OWSLib
PyPI
< 0.28.1
0.28.1

References

Frequently Asked Questions

What is CVE-2023-27476?
CVE-2023-27476 is a security vulnerability in OWSLib involving OWSLib vulnerable to XML External Entity (XXE) Injection under CWE-611: Improper Restriction of XML External Entity Reference.
Which OWSLib versions are affected?
Affected versions include releases prior to 0.28.1 across affected packages: OWSLib.
What version fixes CVE-2023-27476?
Upgrading to 0.28.1 (or the latest patched release for your respective branch) resolves the vulnerability.
Is OWSLib affected?
Yes, OWSLib is affected in releases prior to 0.28.1. Upgrade your dependency to 0.28.1 or later.
What is the CVSS score of CVE-2023-27476?
CVE-2023-27476 has a CVSS v3.1 base score of 8.2 (HIGH) with vector string CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:H/I:N/A:L.
What CWE is associated with CVE-2023-27476?
CVE-2023-27476 is classified under CWE-611: Improper Restriction of XML External Entity Reference (The product processes an XML document that can contain XML entities with URIs that resolve to documents outside of the intended sphere of control, causing the product to embed incorrect documents into its output.).
How can I check PyPI dependencies for CVE-2023-27476?
Run the dependency tree command: 'pip show OWSLib'. 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-8h9c-r582-mggc",
  "modified" : "2024-10-07T21:17:55Z",
  "published" : "2023-03-07T20:41:36Z",
  "aliases" : [ "CVE-2023-27476" ],
  "summary" : "OWSLib vulnerable to XML External Entity (XXE) Injection",
  "details" : "### Impact\n\nOWSLib's XML parser (which supports both `lxml` and `xml.etree`) does not disable entity resolution for `lxml`, and could lead to arbitrary file reads from an attacker-controlled XML payload. This affects all XML parsing in the codebase.\n\n### Patches\n\n- Use only lxml for XML handling, adding `resolve_entities=False` to `lxml`'s parser: https://github.com/geopython/OWSLib/pull/863\n\n### Workarounds\n\n```python\npatch_well_known_namespaces(etree)\netree.set_default_parser(\n    parser=etree.XMLParser(resolve_entities=False)\n)\n```\n\n### References\n\n- [`GHSL-2022-131`](https://securitylab.github.com/advisories/GHSL-2022-131_OWSLib/)\n",
  "severity" : [ {
    "type" : "CVSS_V3",
    "score" : "CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:H/I:N/A:L"
  }, {
    "type" : "CVSS_V4",
    "score" : "CVSS:4.0/AV:N/AC:L/AT:N/PR:N/UI:N/VC:H/VI:N/VA:L/SC:N/SI:N/SA:N"
  } ],
  "affected" : [ {
    "package" : {
      "ecosystem" : "PyPI",
      "name" : "OWSLib"
    },
    "ranges" : [ {
      "type" : "ECOSYSTEM",
      "events" : [ {
        "introduced" : "0"
      }, {
        "fixed" : "0.28.1"
      } ]
    } ]
  } ],
  "references" : [ {
    "type" : "WEB",
    "url" : "https://github.com/geopython/OWSLib/security/advisories/GHSA-8h9c-r582-mggc"
  }, {
    "type" : "ADVISORY",
    "url" : "https://nvd.nist.gov/vuln/detail/CVE-2023-27476"
  }, {
    "type" : "WEB",
    "url" : "https://github.com/geopython/OWSLib/pull/863"
  }, {
    "type" : "WEB",
    "url" : "https://github.com/geopython/OWSLib/pull/863/commits/b92687702be9576c0681bb11cad21eb631b9122f"
  }, {
    "type" : "PACKAGE",
    "url" : "https://github.com/geopython/OWSLib"
  }, {
    "type" : "WEB",
    "url" : "https://github.com/geopython/OWSLib/releases/tag/0.28.1"
  }, {
    "type" : "WEB",
    "url" : "https://github.com/pypa/advisory-database/tree/main/vulns/owslib/PYSEC-2023-86.yaml"
  }, {
    "type" : "WEB",
    "url" : "https://lists.debian.org/debian-lts-announce/2023/06/msg00032.html"
  }, {
    "type" : "ADVISORY",
    "url" : "https://securitylab.github.com/advisories/GHSL-2022-131_owslib"
  }, {
    "type" : "WEB",
    "url" : "https://www.debian.org/security/2023/dsa-5426"
  } ],
  "database_specific" : {
    "cwe_ids" : [ "CWE-611" ],
    "severity" : "HIGH",
    "github_reviewed" : true,
    "github_reviewed_at" : "2023-03-07T20:41:36Z",
    "nvd_published_at" : "2023-03-08T00:15:00Z"
  }
}