# GHSA-mm7x-qfjj-5g2c: Incorrect handling of embedded SVG and MathML leads to mutation XSS after removal

> Attackers can execute arbitrary JavaScript via mutation XSS if the application explicitly allows SVG, MathML, and specific raw-text HTML tags.

- **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:** 21 Sep 2025
- **Also known as:** RUSTSEC-2025-0071

## What is GHSA-mm7x-qfjj-5g2c?

GHSA-mm7x-qfjj-5g2c is a cross-site scripting vulnerability in ammonia, published on 21 Sep 2025. 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

Affected versions of this crate did not correctly strip namespace-incompatible tags
in certain situations, causing it to incorrectly account for differences between HTML,
SVG, and MathML.

This vulnerability only has an effect when the `svg` or `math` tag is allowed,
because it relies on a tag being parsed as html during the cleaning process, but
serialized in a way that causes in to be parsed as xml by the browser.

Additionally, the application using this library must allow a tag that is parsed as raw text in HTML.
These [elements] are:

* title
* textarea
* xmp
* iframe
* noembed
* noframes
* plaintext
* noscript
* style
* script

Applications that do not explicitly allow any of these tags should not be affected, since none are allowed by default.

[elements]: https://github.com/servo/html5ever/blob/57eb334c0ffccc6f88d563419f0fbeef6ff5741c/html5ever/src/tree_builder/rules.rs

## Which versions are affected by GHSA-mm7x-qfjj-5g2c?

7 open source packages ship an affected version, including ammonia.


| Package | Ecosystem | Affected | Fixed in |
| --- | --- | --- | --- |
| `ammonia` | crates.io | All versions | 3.3.1 |
| `ammonia` | crates.io | All versions | 3.3.1 |
| `ammonia` | crates.io | From 0.0.0-0 | 3.3.1, 4.0.1, 4.1.2 |
| `ammonia` | crates.io | From 4.0.0 | 4.0.1 |
| `ammonia` | crates.io | From 4.0.0 | 4.0.1 |
| `ammonia` | crates.io | From 4.1.0 | 4.1.2 |
| `ammonia` | crates.io | From 4.1.0 | 4.1.2 |

## How do I fix GHSA-mm7x-qfjj-5g2c?

Upgrade ammonia to a fixed version for your release line: 3.3.1, 4.0.1 or 4.1.2.

## Is GHSA-mm7x-qfjj-5g2c being exploited?

There is no known exploitation of GHSA-mm7x-qfjj-5g2c in the wild and no public exploit code.

## Fix prompt for AI coding agents

```text
Check this codebase for GHSA-mm7x-qfjj-5g2c and fix it if it is affected.

What it is: GHSA-mm7x-qfjj-5g2c is a cross-site scripting vulnerability in ammonia, published on 21 Sep 2025. 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-mm7x-qfjj-5g2c in the wild and no public exploit code.

Affected packages and fixed versions:
- ammonia (crates.io): affected all versions; fixed in 3.3.1
- ammonia (crates.io): affected all versions; fixed in 3.3.1
- ammonia (crates.io): affected from 0.0.0-0; fixed in 3.3.1, 4.0.1, 4.1.2
- ammonia (crates.io): affected from 4.0.0; fixed in 4.0.1
- ammonia (crates.io): affected from 4.0.0; fixed in 4.0.1
- ammonia (crates.io): affected from 4.1.0; fixed in 4.1.2
- ammonia (crates.io): affected from 4.1.0; fixed in 4.1.2

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-mm7x-qfjj-5g2c/ (Markdown: https://insights.sbomify.com/GHSA-mm7x-qfjj-5g2c/index.md)
```

## Sources

- OSV: https://osv.dev/vulnerability/GHSA-mm7x-qfjj-5g2c

---
From sbomify Insights: https://insights.sbomify.com/GHSA-mm7x-qfjj-5g2c/
Summaries are generated and may contain mistakes; the official description above is the record.
