@angular/compiler
Affected
- introduced
21.0.0-next.0, fixed21.0.2(semver)
Fixed versions
21.0.2
Fix
- Fixed version
21.0.2npm install @angular/[email protected]
Advisory
Also known as: CVE-2025-66412
Angular Stored XSS Vulnerability via SVG Animation, SVG URL and MathML Attributes
A Stored Cross-Site Scripting ([XSS](https://angular.dev/best-practices/security#preventing-cross-site-scripting-xss)) vulnerability has been identified in the Angular Template Compiler. It occurs because the compiler's internal security schema is incomplete, allowing attackers to bypass Angular's built-in security sanitization. Specifically, the schema fails to classify certain URL-holding attributes (e.g., those that could contain `javascript:` URLs) as requiring strict URL security, enabling the injection of malicious scripts.
Additionally, a related vulnerability exists involving SVG animation elements (<animate>, <set>, <animateMotion>, <animateTransform>). The attributeName attribute on these elements was not properly validated, allowing attackers to dynamically target security-sensitive attributes like href or xlink:href on other elements. By binding attributeName to "href" and providing a javascript: URL in the values or to attribute, an attacker could bypass sanitization and execute arbitrary code.
Attributes confirmed to be vulnerable include:
xlink:href), and various MathML attributes (e.g., math|href, annotation|href).attributeName attribute when bound to "href" or "xlink:href".When template binding is used to assign untrusted, user-controlled data to these attributes (e.g., [attr.xlink:href]="maliciousURL" or <animate [attributeName]="'href'" [values]="maliciousURL">), the compiler incorrectly falls back to a non-sanitizing context or fails to block the dangerous attribute assignment. This allows an attacker to inject a javascript:URL payload. Upon user interaction (like a click) on the element, or automatically in the case of animations, the malicious JavaScript executes in the context of the application's origin.
Impact
When exploited, this vulnerability allows an attacker to execute arbitrary code within the context of the vulnerable application's domain. This enables:
Patches
Attack Preconditions
attributeName of an SVG animation element.Workarounds
If you cannot upgrade, you can workaround the issue by ensuring that any data bound to the vulnerable attributes is never sourced from untrusted user input (e.g., database, API response, URL parameters).
[attr.xlink:href]="maliciousURL") to assign untrusted data to the vulnerable SVG/MathML attributes.attributeName attribute of SVG animation elements (<animate>, <set>, etc.).javascript: URLs.High Basis: The source's own band: HIGH
21.0.0-next.0, fixed 21.0.2 (semver)21.0.2
21.0.2npm install @angular/[email protected]20.0.0-next.0, fixed 20.3.15 (semver)20.3.15
20.3.15npm install @angular/[email protected]19.0.0-next.0, fixed 19.2.17 (semver)19.2.17
19.2.17npm install @angular/[email protected]0, last affected 18.2.14 (semver)None listed
No fixed version is listed.
Fix 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