Angular: Sanitization bypass via directive host bindings on concrete host elements in @angular/core and @angular/compiler
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:
hostDirectivescomposition,- Class inheritance of host bindings,
- Dynamic component instantiation (
createComponentwith customhostElementor dynamic directives), - Elements with SVG/MathML namespaces (e.g.
<svg:a>,<math>), or - Elements using tag-neutral selectors (e.g.
:not(...)),
the compiler either failed to associate a sanitizer with the host binding or attached an incorrect security context. As a result, untrusted inputs (e.g. javascript:... URLs) bound via the host binding would be written to the DOM attribute without passing through Angular's built-in sanitizer.
Impact
An attacker capable of controlling the value bound to an affected directive host binding could execute arbitrary JavaScript in the user's browser context (Cross-Site Scripting).
Patches
This issue has been resolved in versions:
22.1.021.2.2020.3.28
Workarounds
Ensure that any user-controlled values assigned to properties bound via directive host bindings are explicitly sanitized using DomSanitizer.sanitize(SecurityContext.URL, ...) before assignment, or restrict the input to validated safe URL schemes (e.g. http://, https://).
Affected software
Click a technology to see all vulnerabilities affecting it.
| Platform | Package | Vulnerable versions | Fixed in |
|---|---|---|---|
| npm package | @angular/compiler | >= 22.0.0, < 22.1.0, >= 21.0.0, < 21.2.20, >= 20.0.0, < 20.3.28, <= 19.2.25 | 22.1.0, 21.2.20, 20.3.28 |
| npm package | @angular/core | >= 22.0.0, < 22.1.0, >= 21.0.0, < 21.2.20, >= 20.0.0, < 20.3.28, <= 19.2.25 | 22.1.0, 21.2.20, 20.3.28 |
References
- https://github.com/angular/angular/security/advisories/GHSA-hh8m-fm6v-7cvg
- https://github.com/angular/angular/issues/69550
- https://github.com/angular/angular/pull/69558
- https://github.com/angular/angular/commit/2f96c8020f85ccb715a76de4b79a0c680c2c7264
- https://github.com/angular/angular/commit/6afe6fa781c2f0931f0aedd729b9884a8fe212ee
- https://github.com/angular/angular/commit/6caa298dee58319b2d674dc91364e26ffe3ecb2b
- https://github.com/angular/angular
- https://github.com/angular/angular/releases/tag/v20.3.28
- https://github.com/angular/angular/releases/tag/v21.2.20
- https://github.com/angular/angular/releases/tag/v22.1.0
- CVSS vector
CVSS:4.0/AV:N/AC:L/AT:N/PR:N/UI:P/VC:N/VI:N/VA:N/SC:L/SI:L/SA:N- Weakness (CWE)
CWE-79- Platform
- npm
- Package
@angular/compiler, @angular/core- Disclosed
- 10.09.2026
- Updated
- 11.10.2026 10:22
Sources and licenses
OSV / GitHub Advisory Database - GHSA-hh8m-fm6v-7cvg - CC BY 4.0
Vulnerability history: @angular/compiler
All published vulnerabilities of this package (npm package), newest first. Shows whether this is a one-off slip or a package that needs watching.
- Total entries
- 7
- First → latest
- 12.2025 09.2026
- Without a fix
- 0
- Exploited in attacks
- 0
Severity breakdown
- High 4
- Medium 3
Disclosures per year
- 2025: 1
- 2026: 6
-
Angular: Sanitization bypass via directive host bindings on concrete host elements in @angular/core and @angular/compiler this entry
Know which vulnerabilities affect your application
With the DockRay integration and software inventory enabled, DockRay checks reported component versions against known vulnerabilities and notifies you about confirmed matches. Coverage depends on the supported technology and available advisory data.