# GHSA-cf4q-4cqr-7g7w: SVG with embedded scripts can lead to cross-site scripting attacks in xml2rfc

> Attackers can inject malicious scripts via SVG elements in xml2rfc, leading to cross-site scripting attacks on published HTML documents.

- **Severity:** Not scored
- **Exploited in the wild:** Not known
- **Login needed:** Not needed
- **Attackable:** Over the internet
- **Victim action needed:** A user has to click or open something
- **Fix available:** Yes
- **Published:** 22 Apr 2022

## What is GHSA-cf4q-4cqr-7g7w?

GHSA-cf4q-4cqr-7g7w is a cross-site scripting vulnerability in xml2rfc, published on 22 Apr 2022. An attacker can exploit it over the internet without logging in, and only if a user opens a file or follows a link.

### Official description

xml2rfc allows `script` elements in SVG sources.
In HTML output having these script elements can lead to XSS attacks.

Sample XML snippet:
```
<artwork type="svg" src="data:image/svg+xml,%3Csvg viewBox='0 0 10 10' xmlns='http://www.w3.org/2000/svg'%3E%3Cscript%3E window.alert('Test Alert'); %3C/script%3E%3C/svg%3E">
</artwork>
```

### Impact
This vulnerability impacts website that publish HTML drafts and RFCs.

### Patches
This has been fixed in version [3.12.4](https://github.com/ietf-tools/xml2rfc/releases/tag/v3.12.4).

### Workarounds
If SVG source is self-contained within the XML, scraping `script` elements from SVG files.

### References
* https://developer.mozilla.org/en-US/docs/Web/SVG/Element/script

### For more information
If you have any questions or comments about this advisory:
* Open an issue in [xml2rfc](https://github.com/ietf-tools/xml2rfc/)
* Email us at [operational-vulnerability@ietf.org](mailto:operational-vulnerability@ietf.org)
* [Infrastructure and Services Vulnerability Disclosure](https://www.ietf.org/about/administration/policies-procedures/vulnerability-disclosure/)

## Which versions are affected by GHSA-cf4q-4cqr-7g7w?

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


| Package | Ecosystem | Affected | Fixed in |
| --- | --- | --- | --- |
| `xml2rfc` | PyPI | All versions | 3.12.4 |
| `xml2rfc` | PyPI | All versions | 3.12.4 |

## How do I fix GHSA-cf4q-4cqr-7g7w?

Upgrade xml2rfc to 3.12.4 or later.

## Is GHSA-cf4q-4cqr-7g7w being exploited?

There is no known exploitation of GHSA-cf4q-4cqr-7g7w in the wild and no public exploit code.

## Fix prompt for AI coding agents

```text
Check this codebase for GHSA-cf4q-4cqr-7g7w and fix it if it is affected.

What it is: GHSA-cf4q-4cqr-7g7w is a cross-site scripting vulnerability in xml2rfc, published on 22 Apr 2022. An attacker can exploit it over the internet without logging in, and only if a user opens a file or follows a link.
Exploitation: There is no known exploitation of GHSA-cf4q-4cqr-7g7w in the wild and no public exploit code.

Affected packages and fixed versions:
- xml2rfc (PyPI): affected all versions; fixed in 3.12.4
- xml2rfc (PyPI): affected all versions; fixed in 3.12.4

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-cf4q-4cqr-7g7w/ (Markdown: https://insights.sbomify.com/GHSA-cf4q-4cqr-7g7w/index.md)
```

## Sources

- OSV: https://osv.dev/vulnerability/GHSA-cf4q-4cqr-7g7w

---
From sbomify Insights: https://insights.sbomify.com/GHSA-cf4q-4cqr-7g7w/
Summaries are generated and may contain mistakes; the official description above is the record.
