Packages / @angular/platform-server / Security

HighVulnerabilityGHSA-j3r3-mxqp-r2p4CVE-2026-88058Published 28 Sep 2026

Angular SSR: XSS via Unescaped Processing Instruction (<?...?>) Nodes in Fallback Raw-Content Elements

Affected releases · @angular/platform-server

  • 22.x22.0.0 – 22.1.3Fixed in 22.1.4
  • 21.x21.0.0 – 21.2.21Fixed in 21.2.22
  • 20.x20.0.0 – 20.3.29Fixed in 20.3.30
  • 19.x19.0.0 – 19.2.25No fix on this line yet
  • 18.x and older2.0.0 – 18.2.14No fix, no longer updated

On 22.x, the newest line:

npm install @angular/platform-server@22.1.4
22.x
  1. Affected

    22.0.0 – 22.1.3

    13 releases

  2. Fixed

    22.1.4 – 22.2.3

    9 releases, latest

21.x
  1. Affected

    21.0.0 – 21.2.21

    39 releases

  2. Fixed

    21.2.22 – 21.2.25

    4 releases

20.x
  1. Affected

    20.0.0 – 20.3.29

    51 releases

  2. Fixed

    20.3.30 – 20.3.34

    5 releases

19.x
  1. Affected

    19.0.0 – 19.2.25

    43 releases

18.x
  1. Affected

    18.0.0 – 18.2.14

    29 releases

17.x
  1. Affected

    17.0.0 – 17.3.12

    32 releases

16.x
  1. Affected

    16.0.0 – 16.2.12

    30 releases

15.x
  1. Affected

    15.0.0 – 15.2.10

    22 releases

14.x
  1. Affected

    14.0.0 – 14.3.0

    26 releases

13.x
  1. Affected

    13.0.0 – 13.4.0

    30 releases

12.x
  1. Affected

    12.0.0 – 12.2.17

    30 releases

11.x
  1. Affected

    11.0.0 – 11.2.14

    28 releases

10.x
  1. Affected

    10.0.0 – 10.2.5

    28 releases

9.x
  1. Affected

    9.0.0 – 9.1.13

    22 releases

8.x
  1. Affected

    8.0.0 – 8.2.14

    23 releases

7.x
  1. Affected

    7.0.0 – 7.2.16

    27 releases

6.x
  1. Affected

    6.0.0 – 6.1.10

    20 releases

5.x
  1. Affected

    5.0.0 – 5.2.11

    22 releases

4.x
  1. Affected

    4.0.0 – 4.4.7

    29 releases

2.x
  1. Affected

    2.0.0 – 2.4.10

    24 releases

586 stable releases of @angular/platform-server, oldest to newest, one row per major.

Is your project affected?

Paste your package.json, or type the range you declare for @angular/platform-server. It is read in your browser and sent nowhere.

What happens

Summary

An XSS vulnerability exists in @angular/platform-server during server-side rendering (SSR) HTML serialization of ProcessingInstruction DOM nodes (<?target data?>, nodeType === 7) when nested inside fallback raw-content elements (<noscript>, <iframe>, <noembed>, <noframes>). While processing instruction data escaped > to &gt;, it did not check for or escape matching closing tags of ancestor fallback elements (e.g., </noscript>). When rendered in a browser with scripting enabled, an unescaped closing tag sequence in a processing instruction prematurely closes the fallback raw-content tag and causes subsequent sibling elements to execute as live HTML.

Technical Description

In HTML5 parsing, fallback raw-content elements (<noscript>, <iframe>, <noembed>, <noframes>) place the browser's HTML tokenizer into RAWTEXT mode. In RAWTEXT mode, processing instruction tokens (<?...?>) are treated as literal raw text rather than bogus comments, and the parser ignores > or ?>. The only token sequence that terminates the container is an end tag matching the container tag name (</noscript, </iframe, etc.).

During server-side HTML serialization, processing instruction nodes previously only replaced > with &gt; (preventing bogus comment breakouts in normal HTML data states) but left < untouched. Crucially, processing instruction serialization never inspected ancestor fallback raw-content tags. As a result, if a ProcessingInstruction node inside <noscript> contained </noscript in its data payload, it was emitted unescaped as <?x </noscript ?>.

Impact & Reachability

  • Reachability: Processing instruction nodes cannot be authored directly through standard Angular template syntax (which parses <?...> into comment nodes in DOM position). Reaching this vulnerability requires application or library code calling inject(DOCUMENT).createProcessingInstruction(target, data) or Renderer2 DOM insertion methods with untrusted user input passed to data inside a fallback raw-content container.

  • Impact: In applications that programmatically construct processing instruction nodes inside fallback elements during server-side rendering, an attacker controlling the processing instruction data can break out of the container and execute arbitrary JavaScript in victims' browsers.

Proof of Concept (Minimal Reproduction)

import { Component, ElementRef, Renderer2, inject, DOCUMENT, AfterViewInit } from '@angular/core';

@Component({
  selector: 'app-root',
  standalone: true,
  template: `<noscript id="host"></noscript>`
})
export class AppComponent implements AfterViewInit {
  private r = inject(Renderer2);
  private el = inject(ElementRef);
  private doc = inject(DOCUMENT);

  ngAfterViewInit() {
    const host = this.el.nativeElement.querySelector('#host');
    
    // Attacker-controlled input passed as Processing Instruction data
    const pi = this.doc.createProcessingInstruction('x', '</noscript ');
    this.r.appendChild(host, pi);
    
    // Sibling markup that should remain inert inside <noscript>
    const img = this.r.createElement('img');
    this.r.setAttribute(img, 'src', 'x');
    this.r.setAttribute(img, 'onerror', 'alert("SSR_PI_XSS")');
    this.r.appendChild(host, img);
  }
}

Vulnerable SSR Output:

<noscript><?x </noscript ?><img src="x" onerror="alert('SSR_PI_XSS')"></noscript>

Workarounds

  • Avoid passing untrusted user input into document.createProcessingInstruction(target, data) when the node is inserted into <noscript>, <iframe>, <noembed>, or <noframes> during server-side rendering.

  • Manually sanitize or replace < with &lt; in any untrusted data passed to processing instruction nodes on the server.