# GHSA-432c-wxpg-m4q3: xml2rfc has file inclusion irregularities

> Attackers can read arbitrary files within the source directory via artwork or sourcecode elements, bypassing local file access restrictions.

- **Severity:** Not scored
- **Exploited in the wild:** Not known
- **Login needed:** Not needed
- **Attackable:** Over the internet
- **Victim action needed:** Not needed
- **Fix available:** Yes
- **Published:** 7 Feb 2025

## What is GHSA-432c-wxpg-m4q3?

GHSA-432c-wxpg-m4q3 is a path traversal vulnerability in xml2rfc, published on 7 Feb 2025. An attacker can exploit it over the internet without logging in, with no action from the victim.

### Official description

Version [3.12.0](https://github.com/ietf-tools/xml2rfc/blob/main/CHANGELOG.md#3120---2021-12-08) changed `xml2rfc` so that it would not access local files without the presence of its new `--allow-local-file-access` flag.
This prevented XML External Entity (XXE) injection attacks with `xinclude` and XML entity references.

It was discovered that `xml2rfc` does not respect `--allow-local-file-access` when a local file is specified as `src` in `artwork` or `sourcecode` elements. Furthermore, XML entity references can include any file inside the source dir and below without using the `--allow-local-file-access` flag. 

The `xml2rfc <= 3.26.0` behaviour:

|  | `xinclude` | XML entity reference | `artwork src=` | `sourcecode src=` |
|---|---|---|---|---|
| without `--allow-local-file-access` flag | No filesystem access | Any file in xml2rfc templates dir and below, any file in source directory and below | Access source directory and below | Access source directory and below |
| with `--allow-local-file-access` flag | Access any file on filesystem[^1] | Access any file on filesystem[^1] | Access source directory and below | Access source directory and below | Access source directory and below |

  [^1]: Access any file of the filesystem with the permissions of the user running `xml2rfc` can access.

### Impact

Anyone running `xml2rfc` as a service that accepts input from external users is impacted by this issue.
Specifying a file in `src` attribute in `artwork` or `sourcecode` elements will cause the contents of that file to appear in xml2rfc’s output results.
But that file has to be inside the same directory as the XML input source file.
For `artwork` and `sourcecode`, `xml2rfc` will not look above the source file directory.

### The proposed new behaviour
- Generalize file access checks.
- Only allow access to files within src dir and below. (xml entity include can access templates dir).
- Always allow access to `templates_dir` for XML entity includes.

New behaviour:

|  | `xinclude` | XML entity reference | `artwork src=` | `sourcecode src=` |
|---|---|---|---|---|
| without `--allow-local-file-access` flag | No filesystem access | No filesystem access _(except for `templates_dir`)_ | No filesystem access | No filesystem access |
| with `--allow-local-file-access` flag | Access source directory and below | Access source directory and below _(Can access`templates_dir`)._ | Access source directory and below | Access source directory and below |

### Workarounds

Use a secure temporary directory to process un-trusted XML files, and do not reuse it for processing other XML documents.

## Which versions are affected by GHSA-432c-wxpg-m4q3?

2 open source packages ship an affected version, including xml2rfc.


| Package | Ecosystem | Affected | Fixed in |
| --- | --- | --- | --- |
| `xml2rfc` | PyPI | From 3.12.0 | 3.27.0 |
| `xml2rfc` | PyPI | From 3.12.0 | 3.27.0 |

## How do I fix GHSA-432c-wxpg-m4q3?

Upgrade xml2rfc to 3.27.0 or later.

## Is GHSA-432c-wxpg-m4q3 being exploited?

There is no known exploitation of GHSA-432c-wxpg-m4q3 in the wild and no public exploit code.

## Fix prompt for AI coding agents

```text
Check this codebase for GHSA-432c-wxpg-m4q3 and fix it if it is affected.

What it is: GHSA-432c-wxpg-m4q3 is a path traversal vulnerability in xml2rfc, published on 7 Feb 2025. An attacker can exploit it over the internet without logging in, with no action from the victim.
Exploitation: There is no known exploitation of GHSA-432c-wxpg-m4q3 in the wild and no public exploit code.

Affected packages and fixed versions:
- xml2rfc (PyPI): affected from 3.12.0; fixed in 3.27.0
- xml2rfc (PyPI): affected from 3.12.0; fixed in 3.27.0

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/GHSA-432c-wxpg-m4q3/ (Markdown: https://insights.sbomify.com/GHSA-432c-wxpg-m4q3/index.md)
```

## Sources

- OSV: https://osv.dev/vulnerability/GHSA-432c-wxpg-m4q3

---
From sbomify Insights: https://insights.sbomify.com/GHSA-432c-wxpg-m4q3/
Summaries are generated and may contain mistakes; the official description above is the record.
