Incorrect handling of embedded SVG and MathML leads to mutation XSS
- GHSA-934p-vp7m-gx3c
- RUSTSEC-2026-0533
Description
The MathML text integration points (`mi`, `mo`, `mn`, `ms`, `mtext`) and SVG `foreignObject` can be made to contain a tag in the other one's namespace (a MathML integration point with a child in the SVG namespace, or vice versa) without the root tag that switches out of the HTML namespace. If the attacker can construct input that parses differently in as HTML than as foreign XML, they can inject arbitrary JavaScript code into the user's browser. For example: - The user writes `<math><mi><svg><gadget></svg></mi></math>`. - The application enables `math`, `mi`, and the gadget, but not `svg`. - Ammonia filters the input to `<math><mi><gadget></mi></math>`. - Because svg is now gone, the gadget switches from being parsed as SVG to being parsed as HTML. - The gadget is written in such a way that it exploits the parsing differences between HTML and MathML. As far as we know, the gadget can only be written using 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/a027c2835472d518893c906dc29c42200af3c960/html5ever/src/tree_builder/rules.rs --- This vulnerability was reported by Roger Meyer.
Text from the OSV record.
Recommendation
ammonia
- If you run 4.2.xupdate to 4.2.5 or laterPatch update: breaking changes are unlikelyammonia 4.2.5 on its registry (opens in a new tab)
- If you run a version from 4.0.0 to before 4.1.9update to 4.1.9 or laterMinor version change: check the release notesammonia 4.1.9 on its registry (opens in a new tab)
- If you run a version from 0.0.0-0 to before 3.3.5update to 3.3.5 or laterMajor version change: expect breaking changesammonia 3.3.5 on its registry (opens in a new tab)
Taken from the version ranges the sources state. Check the vendor advisory: nothing is said about versions the ranges do not list. Breaking-change risk is read from the version numbers only.
Affected
ammoniacrates.io
Affected versions Fixed in from 4.2.0 to before 4.2.5 4.2.5 from 4.0.0 to before 4.1.9 4.1.9 from 0.0.0-0 to before 3.3.5 3.3.5
Timeline
- Published
Related news
No article from the followed outlets names this vulnerability.