GHSA-v3p8-whq6-r5jg

Suggest an improvement
Source
https://github.com/advisories/GHSA-v3p8-whq6-r5jg
Import Source
https://github.com/github/advisory-database/blob/main/advisories/github-reviewed/2026/09/GHSA-v3p8-whq6-r5jg/GHSA-v3p8-whq6-r5jg.json
JSON Data
https://api.test.osv.dev/v1/vulns/GHSA-v3p8-whq6-r5jg
Aliases
Published
2026-09-10T20:25:25Z
Modified
2026-09-25T05:35:09Z
Severity
  • 8.6 (High) CVSS_V4 - CVSS:4.0/AV:N/AC:L/AT:N/PR:N/UI:P/VC:H/VI:H/VA:N/SC:N/SI:N/SA:N CVSS Calculator
Summary
Angular: SSR XSS via Unescaped <template> Content Across DocumentFragment Boundaries in Fallback Raw-Content Elements
Details

Summary

An XSS vulnerability exists in @angular/platform-server during server-side rendering (SSR) HTML serialization when traversing ancestor tags across <template> element boundaries. When an application renders untrusted user input within raw-text tags (<xmp>, <style>, <script>), comments, or text nodes inside a <template> that is nested within a fallback raw-content element (<noscript>, <iframe>, <noembed>, <noframes>), matching closing tags (e.g., </noscript>) are not escaped during HTML serialization. When rendered in a browser, this unescaped closing tag prematurely terminates the fallback container and executes trailing markup as active DOM elements.

Technical Description

In HTML5 parsing, fallback raw-content elements (<noscript>, <iframe>, <noembed>, <noframes>) place the browser's tokenizer into RAWTEXT mode. In this mode, inner content is parsed as literal text until an end tag matching the container tag name (e.g., </noscript>) is encountered.

To prevent XSS breakout vectors during SSR serialization, the DOM serializer inspects a node's ancestors to escape any matching fallback closing tags (</tag -> &lt;/tag). However:

  1. Per DOM specifications, the children of a <template> element reside in a separate DocumentFragment (template.content), whose own parentNode is null.
  2. The serializer's ancestor traversal previously only inspected element nodes. When traversing upward from a node inside template.content, traversal terminated immediately at the DocumentFragment boundary.
  3. Because traversal stopped before reaching the outer document tree, enclosing fallback raw-content ancestors (such as <noscript> or <iframe>) were not discovered. As a result, closing sequences like </noscript> within <template> content were emitted unescaped.

Impact & Reachability

  • Framework Guarantee Bypass: Angular guarantees that standard text interpolation ({{ userInput }} bound as element text content) is safe by default without manual sanitization. This vulnerability bypasses that guarantee during SSR HTML serialization when untrusted input is interpolated inside template content within fallback containers.
  • Template Authoring: Writing literal <xmp> or <style> directly inside a component's <template> markup requires relaxed template schema checks (CUSTOM_ELEMENTS_SCHEMA or NO_ERRORS_SCHEMA). However, standard HTML comments and text nodes inside <template> within <noscript> are reachable without relaxed schemas.
  • Imperative DOM Construction: Components or directives that construct DOM structures imperatively via Renderer2 bypass template compiler schema checks entirely and are unconditionally affected.

Proof of Concept (Minimal Reproduction)

import { Component } from '@angular/core';

@Component({
  selector: 'app-root',
  standalone: true,
  template: `
    <noscript>
      <template>
        <xmp>{{ payload }}</xmp>
      </template>
    </noscript>
  `
})
export class AppComponent {
  // Attacker-controlled input bound via standard text interpolation
  payload = '</noscript><img src=x onerror=alert("SSR_TEMPLATE_XSS")>';
}

Vulnerable SSR Output:

<noscript><template><xmp></noscript><img src=x onerror=alert("SSR_TEMPLATE_XSS")></xmp></template></noscript>

Workarounds

  • Avoid rendering untrusted user input inside <template> elements nested within <noscript>, <iframe>, <noembed>, or <noframes> in server-rendered templates.
  • Avoid programmatic DOM assembly of <template> elements inside fallback containers when handling untrusted data.
Database specific
{
    "cwe_ids": [
        "CWE-116",
        "CWE-79"
    ],
    "github_reviewed": true,
    "github_reviewed_at": "2026-09-10T20:25:25Z",
    "nvd_published_at": null,
    "severity": "HIGH"
}
References

Affected packages

npm / @angular/platform-server

Package

Name
@angular/platform-server
View open source insights on deps.dev
Purl
pkg:npm/%40angular/platform-server

Affected ranges

Type
SEMVER
Events
Introduced
22.0.0
Fixed
22.1.4

Database specific

source
"https://github.com/github/advisory-database/blob/main/advisories/github-reviewed/2026/09/GHSA-v3p8-whq6-r5jg/GHSA-v3p8-whq6-r5jg.json"

npm / @angular/platform-server

Package

Name
@angular/platform-server
View open source insights on deps.dev
Purl
pkg:npm/%40angular/platform-server

Affected ranges

Type
SEMVER
Events
Introduced
21.0.0
Fixed
21.2.22

Database specific

source
"https://github.com/github/advisory-database/blob/main/advisories/github-reviewed/2026/09/GHSA-v3p8-whq6-r5jg/GHSA-v3p8-whq6-r5jg.json"

npm / @angular/platform-server

Package

Name
@angular/platform-server
View open source insights on deps.dev
Purl
pkg:npm/%40angular/platform-server

Affected ranges

Type
SEMVER
Events
Introduced
20.0.0
Fixed
20.3.30

Database specific

source
"https://github.com/github/advisory-database/blob/main/advisories/github-reviewed/2026/09/GHSA-v3p8-whq6-r5jg/GHSA-v3p8-whq6-r5jg.json"

npm / @angular/platform-server

Package

Name
@angular/platform-server
View open source insights on deps.dev
Purl
pkg:npm/%40angular/platform-server

Affected ranges

Type
SEMVER
Events
Introduced
0 Unknown introduced version / All previous versions are affected
Last Affected
19.2.25

Database specific

source
"https://github.com/github/advisory-database/blob/main/advisories/github-reviewed/2026/09/GHSA-v3p8-whq6-r5jg/GHSA-v3p8-whq6-r5jg.json"