# CVE-2023-27476: XML External Entity (XXE) Injection in OWSLib

> An attacker can read arbitrary files via XML External Entity injection in OWSLib's XML parser, affecting users of this Python library.

- **Severity:** High 8.2 (`CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:H/I:N/A:L`)
- **Exploited in the wild:** Not known
- **Login needed:** Not needed
- **Attackable:** Over the internet
- **Victim action needed:** Not needed
- **Fix available:** Yes
- **Published:** 7 Mar 2023
- **Updated:** 25 Feb 2025
- **Also known as:** DEBIAN-CVE-2023-27476, DLA-3470-1, DSA-5426-1, GHSA-8h9c-r582-mggc, MGASA-2023-0112, PYSEC-2023-86, UBUNTU-CVE-2023-27476

## What is CVE-2023-27476?

CVE-2023-27476 is a high-severity vulnerability in geopython OWSLib, published on 7 Mar 2023. An attacker can exploit it over the internet without logging in, with no action from the victim.

### Official description

OWSLib is a Python package for client programming with Open Geospatial Consortium (OGC) web service interface standards, and their related content models. OWSLib's XML parser (which supports both `lxml` and `xml.etree`) does not disable entity resolution, and could lead to arbitrary file reads from an attacker-controlled XML payload. This affects all XML parsing in the codebase. This issue has been addressed in version 0.28.1. All users are advised to upgrade. The only known workaround is to patch the library manually. See `GHSA-8h9c-r582-mggc` for details.

Weakness: CWE-611 (Improper Restriction of XML External Entity Reference)

## Which versions are affected by CVE-2023-27476?

3 open source packages ship an affected version, including owslib and OWSLib. It affects 1 product.


| Package | Ecosystem | Affected | Fixed in |
| --- | --- | --- | --- |
| `owslib` | PyPI | All versions | 0.28.1 |
| `owslib` | PyPI | All versions | 0.28.1 |
| `OWSLib` | PyPI | All versions | 0.28.1 |

Products: Osgeo Owslib.

## How do I fix CVE-2023-27476?

Upgrade owslib to 0.28.1 or later.

## Is CVE-2023-27476 being exploited?

There is no known exploitation of CVE-2023-27476 in the wild and no public exploit code.

## Fix prompt for AI coding agents

```text
Check this codebase for CVE-2023-27476 and fix it if it is affected.

What it is: CVE-2023-27476 is a high-severity vulnerability in geopython OWSLib, published on 7 Mar 2023. An attacker can exploit it over the internet without logging in, with no action from the victim.
Exploitation: There is no known exploitation of CVE-2023-27476 in the wild and no public exploit code.

Affected packages and fixed versions:
- owslib (PyPI): affected all versions; fixed in 0.28.1
- owslib (PyPI): affected all versions; fixed in 0.28.1
- OWSLib (PyPI): affected all versions; fixed in 0.28.1

Task:
1. Search the dependency manifests and lockfiles (for example package.json, package-lock.json, requirements.txt, poetry.lock, uv.lock, pom.xml, build.gradle, go.mod, Cargo.lock, Gemfile.lock) and any Dockerfiles for the affected packages, including transitive dependencies.
2. If an affected version is in use, upgrade it to the fixed version for its release line with the project's package manager, so the lockfile is regenerated. Prefer the smallest upgrade that fixes it.
3. If there is no fix, or the upgrade would break the build, do not guess: explain the risk and the safest workaround instead.
4. Run the tests and summarise what changed and why.
5. If nothing in the project is affected, say so and change nothing.

Reference: https://insights.sbomify.com/CVE-2023-27476/ (Markdown: https://insights.sbomify.com/CVE-2023-27476/index.md)
```

## Sources

- CVE record: https://www.cve.org/CVERecord?id=CVE-2023-27476
- NVD: https://nvd.nist.gov/vuln/detail/CVE-2023-27476
- OSV: https://osv.dev/vulnerability/CVE-2023-27476

---
From sbomify Insights: https://insights.sbomify.com/CVE-2023-27476/
Summaries are generated and may contain mistakes; the official description above is the record.
