@angular/platform-server: Angular SSR: Denial of Service (DoS) via Infinite Loop on Malformed DOCTYPE
What fixes it
- 22.1.6@angular/platform-server, npmGitHub
npm install @angular/platform-server@22.1.6 - 21.2.23@angular/platform-server, npmGitHub
npm install @angular/platform-server@21.2.23 - 20.3.31@angular/platform-server, npmGitHub
npm install @angular/platform-server@20.3.31
A fixed version on one release line is not the upgrade target for every line. Check your exact version and any vendor backports.
Description
A Denial of Service (DoS) vulnerability exists in @angular/platform-server's DOM emulation parser (domino). When processing untrusted user input containing an incomplete DOCTYPE declaration ending with whitespace before EOF (such as <!DOCTYPE html ), the HTML parser enters an infinite synchronous loop, pegging CPU utilization at 100% and completely freezing the Node.js server process.
Technical Description
In Angular Server-Side Rendering (SSR), @angular/platform-server uses domino to parse and sanitize HTML bound through template bindings (such as [innerHTML]) or manipulated via DOM APIs.
In Domino's HTML parser (lib/HTMLParser.js), tokenizer states that specify fixed lookahead—such as after_doctype_name_state (lookahead = 6)—rely on the state handler function to explicitly advance the character index pointer (nextchar). While branches for whitespace, >, and keyword matching advance nextchar, the EOF branch (case -1: // EOF) emitted doctype and EOF tokens without advancing nextchar or transitioning out of the state:
case -1: // EOF forcequirks(); emitDoctype(); emitEOF(); break;
Because nextchar remained unchanged pointing to the EOF marker character (\uFFFF), the scanner loop (while (nextchar < numchars)) repeatedly re-invoked after_doctype_name_state with codepoint = EOF indefinitely. In Node.js's single-threaded runtime, this synchronous loop starves the event loop entirely.
Impact & Reachability
- Reachability: The vulnerability is reachable in any Angular SSR application where untrusted user input is bound to
[innerHTML], interpolated into markup, or sanitized on the server. - Impact: Successful exploitation allows an unauthenticated remote attacker to cause an immediate Denial of Service (DoS) by sending a payload containing an incomplete DOCTYPE (e.g.,
<!DOCTYPE html). The Node.js SSR process locks up at 100% CPU and ceases responding to all concurrent and subsequent HTTP requests.
Proof of Concept:
import { Component } from '@angular/core';
@Component({
selector: 'app-root',
standalone: true,
template: `<div [innerHTML]="payload"></div>`,
})
export class AppComponent {
// Attacker-controlled input containing an incomplete DOCTYPE ending with whitespace
payload = '<!DOCTYPE html ';
}Workarounds
- Avoid binding untrusted user input directly to
[innerHTML]in server-rendered templates; use standard text interpolation ({{ userInput }}) or[textContent]when raw HTML rendering is not required. - Validate or sanitize user input before passing it to
[innerHTML]on the server by stripping or rejecting strings matching/^<!DOCTYPE/i.
Text from GitHub Advisory Database
Affected versions 16
- @angular/platform-server, npm>= 22.0.0, < 22.1.6GitHub
- @angular/platform-server, npm>= 21.0.0, < 21.2.23GitHub
- @angular/platform-server, npm>= 20.0.0, < 20.3.31GitHub
- @angular/platform-server, npm<= 19.2.25GitHub
- angularaffected: <= 19.2.25CVE List
- angularaffected: >= 20.0.0, < 20.3.31CVE List
- angularaffected: >= 21.0.0, < 21.2.23CVE List
- angularaffected: >= 22.0.0, < 22.1.6CVE List
- platform-serveraffected: <= 19.2.25CVE List
- platform-serveraffected: >= 20.0.0, < 20.3.31CVE List
- platform-serveraffected: >= 21.0.0, < 21.2.23CVE List
- platform-serveraffected: >= 22.0.0, < 22.1.6CVE List
- @angular/platform-server, npmfrom 22.0.0, fixed in 22.1.6OSV
- @angular/platform-server, npmfrom 21.0.0, fixed in 21.2.23OSV
- @angular/platform-server, npmfrom 20.0.0, fixed in 20.3.31OSV
- @angular/platform-server, npmfrom first release, through 19.2.25OSV
References 8
- github.com/angular/angular/commit/3db26e2544964d07a520836ad01f02f36ec88e25Fixvia CVE List
- github.com/angular/angular/commit/fc2e8fbc0bda2f5c11585e8a0cbd88c074f5e567Fixvia CVE List
- github.com/angular/domino/commit/4d97473116d000e3fd4d6f75ec98cbd67576fa6fFixvia CVE List
- github.com/angular/angular/releases/tag/v20.3.31Fixvia CVE List
- github.com/angular/angular/releases/tag/v21.2.23Fixvia CVE List
- github.com/angular/angular/releases/tag/v22.1.6Fixvia CVE List
- github.com/advisories/GHSA-f67j-2jqw-jpq7Advisoryvia GitHub
- github.com/angular/angular/security/advisories/GHSA-f67j-2jqw-jpq7Exploitvia CVE List