Angular: Sanitization bypass via directive host bindings on concrete host elements in @angular/core and @angular/compiler
angular
Affected versions
| Product | Affected | Fixed in |
|---|---|---|
| @angular/core npm |
|
|
| @angular/compiler |
angular
| Product | Affected | Fixed in |
|---|---|---|
| @angular/core npm |
|
|
| @angular/compiler |
|
|
Angular is a development platform for building mobile and desktop web applications using TypeScript/JavaScript and other languages. Prior to 20.3.28, 21.2.20, and 22.1.0, Angular's compiler and runtime in @angular/core and @angular/compiler could omit or select an incorrect sanitizer for security-sensitive directive host bindings because SecurityContext was derived from the declaring directive or component selector rather than the concrete host element. The mismatch is reachable through hostDirectives composition, inherited HostBinding declarations, createComponent with a custom hostElement or dynamic directives, SVG/MathML namespace elements, and tag-neutral selectors such as :not(...). Attacker-controlled href, src, action, xlink:href, or data values can therefore reach DOM attributes without Angular's built-in sanitizer and execute arbitrary JavaScript in the user's browser context. Applications unable to upgrade can use DomSanitizer.sanitize with SecurityContext.URL before assignment or restrict inputs to validated HTTP and HTTPS URL schemes. This issue is fixed in versions 20.3.28, 21.2.20, and 22.1.0.
From the CVE record · GitHub_M
Angular’s compiler and runtime can select the wrong sanitizer for security-sensitive directive host bindings when the binding’s declared selector differs from the actual host element. If attacker-controlled values reach affected DOM attributes, they can execute JavaScript in a user’s browser. The input does not specify an authentication requirement.
Teams using npm @angular/core or @angular/compiler at versions >=22.0.0 <22.1.0, >=21.0.0 <21.2.20, >=20.0.0 <20.3.28, or <=19.2.25 should check their applications.