CVE-2026-50557: Angular Template Sanitization Bypass Leading to XSS
Angular versions prior to 22.0.0-rc.2, 21.2.15, 20.3.22, and 19.2.22 contain a template sanitization bypass vulnerability that allows attackers to inject malicious scripts through specially crafted namespace-based HTML elements. By using namespaced variants like <svg:script> or <:svg:script>, attackers can circumvent Angular's built-in protections against script injection, potentially leading to cross-site scripting (XSS) attacks. The vulnerability also extends to namespaced attributes in SVG and MathML elements, which can bypass attribute sanitizers. Any application using a vulnerable Angular version that processes user-supplied or dynamically rendered templates is at risk.
Source data · NVD / CISA · public domain
- CVSS
- 3.1 · 6.1 MEDIUM · CVSS:3.1/AV:N/AC:L/PR:N/UI:R/S:C/C:L/I:L/A:N
- Weaknesses (CWE)
- CWE-79
- Affected products
- 16 configuration(s)
- Published / Modified
- 2026-06-22 / 2026-07-09
NVD description (verbatim)
Angular is a development platform for building mobile and desktop web applications using TypeScript/JavaScript and other languages. Prior to 22.0.0-rc.2, 21.2.15, 20.3.22 and 19.2.22, an issue in the @angular/compiler and @angular/core packages allows bypassing element and attribute sanitization/validation through specific namespace workarounds. Specifically, namespaced script elements (e.g., <svg:script> or <:svg:script>) were not properly identified as script elements by the Angular template preparser, allowing them to pass through template compilation without being stripped. Furthermore, security context schema mappings for element attributes did not consistently handle attributes within namespaced elements (like SVG and MathML), opening up gaps where malicious namespaced attributes could bypass runtime and compile-time sanitizers. Combined, these flaws enable an attacker who can inject or supply a template/tag structure with custom namespaces to bypass Angular's script-stripping logic and attribute sanitizers, leading to client-side Cross-Site Scripting (XSS). This vulnerability is fixed in 22.0.0-rc.2, 21.2.15, 20.3.22 and 19.2.22.
3 reference(s) · View on NVD →
SEC.co analysis · AI-assisted, reviewed against source
Technical summary
The vulnerability stems from two distinct flaws in Angular's compiler and core packages. First, the template preparser fails to recognize namespaced script elements (e.g., <svg:script>, <:svg:script>) as actual script tags during template compilation, allowing them to bypass the script-stripping logic. Second, the security context schema mappings do not consistently validate attributes within namespaced elements like SVG and MathML. This inconsistency permits malicious attributes to evade both compile-time and runtime sanitization. An attacker who can influence template content—either directly through dynamic template injection or indirectly through content-management workflows—can exploit these gaps to inject JavaScript code that executes in the victim's browser with the privileges of the Angular application.
Business impact
This vulnerability enables XSS attacks that could lead to session hijacking, credential theft, malware distribution, or defacement of user interfaces. Organizations using Angular for customer-facing applications, internal tools, or single-page applications face elevated risk if user input can reach template rendering. The attack surface is particularly wide in applications that support dynamic templates, user-generated content, or third-party integrations. Remediation requires updating to patched versions, which may necessitate testing and staged rollouts depending on application complexity and customization.
Affected systems
All Angular versions before 22.0.0-rc.2, 21.2.15, 20.3.22, and 19.2.22 are affected. Organizations must verify their current Angular version and determine which release line they are using (v19, v20, v21, or v22) to identify the correct target patch version. The vulnerability affects both the @angular/compiler and @angular/core packages; both must be updated together to ensure complete protection.
Exploitability
The vulnerability is readily exploitable in scenarios where an attacker can supply or influence template content. No authentication is required, and user interaction is necessary only to the extent that the victim must visit or load an affected page. The attack does not require special network positioning. The CVSS score of 6.1 (MEDIUM) reflects that exploitation requires some degree of user interaction and produces limited direct impact, but the prevalence of template-driven Angular applications and the ease of crafting malicious namespace-based payloads make this a practical security concern.
Remediation
Update Angular to version 22.0.0-rc.2 or later, 21.2.15 or later, 20.3.22 or later, or 19.2.22 or later, depending on your current version line. Before deploying patches to production, test thoroughly in a staging environment to ensure template rendering, dynamic content, and third-party integrations continue to function correctly. Additionally, review any custom template logic or dynamic template generation to confirm it does not inadvertently rely on bypassed sanitization.
Patch guidance
Locate your package.json and identify the current @angular/core and @angular/compiler versions. Use npm update or yarn upgrade to move to the patched version appropriate for your version line. If you are on a long-term support (LTS) release, verify that the target version is still receiving security updates. Test all routes and features that render user input or dynamic content. Consider automated regression testing to validate that sanitization is working as expected. Deployment should follow your standard change-management process, with rollback procedures in place.
Detection guidance
Monitor package.json and lock files for @angular/core and @angular/compiler versions. Use Software Composition Analysis (SCA) tools to flag vulnerable versions in your codebase. Watch for template-rendering errors or console warnings after patching, which may indicate that previously bypassed content is now being blocked by enhanced sanitizers. In a security testing environment, attempt to inject namespaced script tags (e.g., <svg:script>alert('xss')</svg:script>) into dynamic templates; after patching, these should be stripped. Review server logs and network traffic for unusual template payloads if you suspect prior exploitation.
Why prioritize this
While the CVSS score is MEDIUM, this vulnerability should be prioritized for applications that render user-supplied content, support dynamic templates, or integrate third-party content. Organizations with public-facing Angular applications or those handling sensitive user data should patch quickly. Conversely, applications with strict Content Security Policy (CSP) headers or those that do not render dynamic templates may have lower immediate risk. Assess your attack surface before deprioritizing.
Risk score, explained
The CVSS 3.1 score of 6.1 (MEDIUM) reflects an attack vector that is network-accessible, requires no privileges, and has low attack complexity, but demands user interaction (the victim must visit a page containing malicious content). The impact is limited to confidentiality and integrity (no availability impact). The scope change (S:C) indicates that the compromised component can affect resources beyond its security scope, reflecting the nature of XSS in web browsers. The score would be higher for applications where user interaction is guaranteed or where stored XSS is possible.
Frequently asked questions
If I am on Angular v18 or earlier, am I unaffected?
The vulnerability affects versions before 19.2.22, 20.3.22, 21.2.15, and 22.0.0-rc.2. If you are on v18 or earlier, you are not listed as affected by this CVE. However, you should verify this against the official Angular security advisory and consider your long-term support roadmap.
Can Content Security Policy (CSP) prevent exploitation of this vulnerability?
A strict CSP that disallows inline scripts and dynamically inserted <script> tags can reduce risk, but it is not a complete mitigation. Namespace-based injection may interact unpredictably with CSP enforcement depending on browser behavior. Patching is the definitive remediation.
Do I need to update both @angular/compiler and @angular/core?
Yes. The vulnerability exists in both packages, and both must be updated to the patched versions. Verify in your package.json that both dependencies are updated and that lock files reflect the changes.
What should I do if I cannot immediately upgrade Angular?
Implement strict input validation and sanitization in your application layer, use a strict Content Security Policy, limit dynamic template injection, and audit any custom template logic. These measures reduce risk but do not eliminate it. Plan a patch deployment at your earliest opportunity.
This analysis is provided for informational purposes to assist security professionals in understanding and remediating CVE-2026-50557. SEC.co makes no guarantee regarding the completeness or accuracy of third-party vulnerability data. Always verify patch versions and affected systems against official vendor advisories before deployment. This document does not constitute legal advice, professional security assessment, or a substitute for vendor-supplied guidance. Readers are responsible for assessing their own risk and implementing appropriate controls within their environment. Source: NVD (public-domain), retrieved 2026-07-28. Analysis generated by SEC.co (claude-haiku-4-5).
Related vulnerabilities
- CVE-2026-50555MEDIUMAngular Server-Side Rendering XSS via Unicode Index Misalignment in Domino
- CVE-2026-50556MEDIUMAngular SSR XSS Vulnerability in noscript Element Serialization
- CVE-2026-52725MEDIUMAngular Script Injection via Dynamic Component Creation
- CVE-2026-54265MEDIUMAngular Compiler DOM Sanitization Bypass via Two-Way Bindings
- CVE-2026-54267MEDIUMAngular DOM Clobbering in SSR Hydration
- CVE-2026-49241HIGHAngular Language Service VS Code Extension Arbitrary Code Execution
- CVE-2026-50178HIGHAngular Language Service VS Code Extension Remote Code Execution via Malicious JSDoc
- CVE-2016-20070MEDIUMPrivilege Escalation & Stored XSS in WordPress Booking Calendar Contact Form 1.0.23