ammonia
Affected
- introduced
0, fixed3.3.2(semver)
Fixed versions
3.3.2
Fix
- Fixed version
3.3.2cargo update -p ammonia --precise 3.3.2
Advisory
Also known as: CVE-2026-63430, RUSTSEC-2026-0193
ammonia: mXSS via MathML annotation-xml encoding strip
If a certain set of MathML tags are enabled, an attacker can inject arbitrary JavaScript code into the user's browser.
The annotation-xml tag has slightly different behavior than the other "integration point"
tags in MathML and SVG, but ammonia didn't handle it, so it didn't correctly
strip the namespace-incompatible tags.
This vulnerability only has an effect when the math and annotation-xml tags
are both enabled, but the encoding attribute is disabled, because it relies
on the following sequence of steps:
<math><annotation-xml encoding="text/html"><gadget></annotation-xml></math>.<gadget> is parsed as HTML.<math><annotation-xml><gadget></annotation-xml></math>. Because the encoding attribute is gone, <gadget> is now parsed as MathML.Additionally, the gadget can only be written using a tag that is parsed as raw text in HTML.
These [elements] are:
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/045a0378f2b0f8d4a350793899cf722a2a9b3d11/html5ever/src/tree_builder/rules.rs
Impact
Low: Requires both MathML and at least one raw-text HTML tag to be enabled, and most websites don't enable either of those.
Patches
Workarounds
Call <code>builder.add_clean_content_tags("annotation-xml")</code> to remove the annotation-xml element and all of its children, including the XSS gadget.
Medium Basis: The source's own band: MODERATE
0, fixed 3.3.2 (semver)3.3.2
3.3.2cargo update -p ammonia --precise 3.3.24.0.0, fixed 4.0.2 (semver)4.0.2
4.0.2cargo update -p ammonia --precise 4.0.24.1.0, fixed 4.1.3 (semver)4.1.3
4.1.3cargo update -p ammonia --precise 4.1.3Fix commands are the export's own generic commands. Ojuju never runs them. Check them against your setup first.
Check your own computer: guard packages check
Source: GitHub Advisory Database (reviewed advisories) · CC BY 4.0