Disclaimer: This content was generated using AI. While we strive for accuracy, please verify critical information with official sources.
Sources: National Vulnerability Database, CISA KEV, Exploit-DB
CVE-2026-102342 Overview
CVE-2026-102342 affects ammonia, a Rust library for repairing and securing untrusted HTML. The vulnerability allows stored cross-site scripting [CWE-79] through SVG animate and set elements. Attackers can craft an animation whose attributeName targets href and whose value uses the javascript: scheme. The sanitized SVG retains the animation, producing a script-bearing link. When a user clicks the resulting link, the attacker-controlled script executes in the application's origin.
The flaw exists in versions prior to 3.3.3, 4.0.3, and 4.1.4. Applications that opt into allowing SVG animation elements are affected.
Critical Impact
Attackers can achieve stored XSS in applications that allow SVG animate or set elements, executing script in the victim's browser context after a single click.
Affected Products
- ammonia Rust library versions prior to 3.3.3
- ammonia Rust library versions prior to 4.0.3
- ammonia Rust library versions prior to 4.1.4
Discovery Timeline
- 2026-10-13 - CVE-2026-102342 published to NVD
- 2026-10-13 - Last updated in NVD database
Technical Details for CVE-2026-102342
Vulnerability Analysis
ammonia sanitizes untrusted HTML by applying an allowlist of tags and attributes. When applications configure the sanitizer to permit SVG animate or set elements, the sanitizer fails to validate the combination of attributeName="href" with a javascript: scheme in the animation value.
SVG animations can mutate attributes of their target elements at runtime. By animating the href attribute of a link element, an attacker can inject a javascript: URL that was never present in the static markup. The sanitizer inspects attribute values statically and does not model this dynamic attribute mutation. Victim interaction is required: the user must click the animated link for the script to execute in the application's origin.
Root Cause
The root cause is incomplete attribute-value validation for SVG animation elements. The sanitizer allowlist for animate and set did not forbid attributeName values that target navigation attributes such as href, nor did it enforce URL-scheme restrictions on the resulting dynamic value. This gap permits stored XSS payloads to survive sanitization in the 3.x and early 4.x branches.
Attack Vector
An attacker submits HTML containing an SVG with an animate or set child whose attributeName is href and whose target value uses the javascript: scheme. The sanitizer preserves the markup. The content is stored and later rendered to other users. When a victim clicks the affected link, the browser evaluates the attacker's script in the application's origin, enabling session theft, defacement, or further client-side attacks.
// Patch excerpt from src/lib.rs - guards against configurations
// that re-enable the vulnerable SVG animation elements.
assert!(!self.tags.contains(tag_name));
assert!(!self.tag_attributes.contains_key(tag_name));
assert!(!self.tags.contains("animate"), "SVG animation is not supported: use 4.1.4 instead");
assert!(!self.tags.contains("set"), "SVG animation is not supported: use 4.1.4 instead");
let body = {
let children = dom.document.children.borrow();
children[0].clone()
};
// Source: https://github.com/rust-ammonia/ammonia/commit/9394bd81179e756cb911314deabd943f1a9c8989
Detection Methods for CVE-2026-102342
Indicators of Compromise
- Stored HTML content containing <animate> or <set> elements with attributeName="href".
- SVG payloads where animation values, to, or from attributes begin with javascript:.
- Application logs showing navigation events to javascript: URIs originating from sanitized user content.
Detection Strategies
- Scan stored user-generated HTML for SVG animation tags combined with href-targeting attributeName values.
- Audit application dependency manifests (Cargo.toml, Cargo.lock) for ammonia versions below 3.3.3, 4.0.3, or 4.1.4.
- Implement Content Security Policy (CSP) violation reporting to surface inline script execution from sanitized content.
Monitoring Recommendations
- Monitor outbound navigation and click telemetry for javascript: scheme URLs in rendered pages.
- Track CSP report-only violations referencing user content endpoints to catch sanitizer bypasses before enforcement.
- Alert on new or anomalous SVG payload patterns submitted to content endpoints that persist user HTML.
How to Mitigate CVE-2026-102342
Immediate Actions Required
- Upgrade ammonia to 3.3.3, 4.0.3, or 4.1.4 depending on the branch in use.
- Rebuild and redeploy applications after updating Cargo.lock to pick up the fixed version.
- Review sanitizer configurations and remove animate and set from allowed tag lists unless running 4.1.4 or later.
Patch Information
The maintainers released fixes in GitHub Release v3.3.3, GitHub Release v4.0.3, and GitHub Release v4.1.4. The 3.x and 4.0.x branches add assertions that prevent re-enabling the vulnerable animate and set tags, while 4.1.4 contains the full sanitization fix. See the GitHub Security Advisory GHSA-m6mh-2hw2-555x for details.
Workarounds
- Remove animate and set from any custom sanitizer allowlists until upgrading to a fixed release.
- Enforce a strict Content Security Policy that disallows javascript: URIs in navigation targets.
- Post-process sanitizer output to strip SVG animation elements that target navigation attributes.
# Update ammonia to a fixed version
cargo update -p ammonia --precise 4.1.4
# Verify no vulnerable versions remain in the lockfile
cargo tree -i ammonia
Disclaimer: This content was generated using AI. While we strive for accuracy, please verify critical information with official sources.
Sources: National Vulnerability Database, CISA KEV, Exploit-DB

