Listen to this Post
Angular automatically sanitizes untrusted values bound to security-sensitive DOM sinks such as href, src, action, xlink:href, and data to protect against Cross-Site Scripting (XSS). Prior to the fix, the Angular compiler determined the SecurityContext for directive host bindings (host: {‘[attr.href]’: ‘value’} or @HostBinding(‘attr.href’)) based solely on the declaring directive or component selector at compile time, rather than the concrete host element that the directive was applied to. When a directive with a security-sensitive host binding was applied to a different concrete host element—such as through hostDirectives composition, Class inheritance of host bindings, Dynamic component instantiation (createComponent with custom hostElement or dynamic directives), Elements with SVG/MathML namespaces (e.g.
DailyCVE Form:
Platform: Angular
Version: 20.3.28 21.2.20 22.1.0
Vulnerability: Sanitization Bypass
Severity: Medium
date: 2026-09-10
Prediction: 2026-09-10
What Undercode Say:
Analytics:
- Check Angular version: `ng version`
– Verify vulnerable pattern: `grep -r “HostBinding.attr.href” src/`
– Test sanitization bypass with malicious URL: `javascript:alert(1)`
Exploit: (Educational Purposes!)
// Vulnerable directive
@Directive({ selector: 'a' })
export class LinkDirective {
@HostBinding('attr.href') href: string;
}
// Attacker-controlled input
// href = 'javascript:alert("XSS")'
Protection: from this CVE
import { DomSanitizer, SecurityContext } from '@angular/platform-browser';
constructor(private sanitizer: DomSanitizer) {}
const safeUrl = this.sanitizer.sanitize(SecurityContext.URL, userInput);
// Or validate: /^https?:\/\//i.test(userInput)
Impact:
Arbitrary JavaScript execution, session hijacking, data theft, and full Cross-Site Scripting within the user’s browser context.
🎯Let’s Practice Exploiting & Learn Patching For Free:
🎓 Live Courses & Certifications:
Join Undercode Academy for Verified Certifications
🚀 Request a Custom Project:
Secure, high-velocity infrastructure and disruptive technological engineering. Contact our engineering team for high-tier development and proprietary systems:
[email protected]
💎 Smart Architecture | 🛡️ Secure by Design | ⭐ Trusted by Thousands
Sources:
Reported By: github.com
Extra Source Hub:
Undercode

